public class TextUtilities extends Object
This class is neither intended to be instantiated nor subclassed.
Modifier and Type | Field and Description |
---|---|
static String[] |
DELIMITERS
Default line delimiters used by the text functions of this class.
|
static String[] |
fgDelimiters
Deprecated.
use DELIMITERS instead
|
Constructor and Description |
---|
TextUtilities() |
Modifier and Type | Method and Description |
---|---|
static void |
addDocumentPartitioners(IDocument document,
Map partitioners)
Connects the given document with all document partitioners stored in the given map under
their partitioning name.
|
static ITypedRegion[] |
computePartitioning(IDocument document,
String partitioning,
int offset,
int length,
boolean includeZeroLengthPartitions)
Computes and returns the partitioning for the given region of the given
document for the given partitioning name.
|
static String[] |
computePartitionManagingCategories(IDocument document)
Computes and returns the partition managing position categories for the
given document or
null if this was impossible. |
static int[] |
copy(int[] array)
Returns a copy of the given integer array.
|
static String[] |
copy(String[] array)
Returns a copy of the given string array.
|
static String |
determineLineDelimiter(String text,
String hint)
Determines which one of default line delimiters appears first in the list.
|
static int |
endsWith(String[] searchStrings,
String text)
Returns the index of the longest search string with which the given text ends or
-1 if none matches. |
static int |
equals(String[] compareStrings,
String text)
Returns the index of the first compare string that equals the given text or
-1
if none is equal. |
static String |
getContentType(IDocument document,
String partitioning,
int offset,
boolean preferOpenPartitions)
Returns the content type at the given offset of the given document.
|
static String |
getDefaultLineDelimiter(IDocument document)
Returns the default line delimiter for the given document.
|
static ITypedRegion |
getPartition(IDocument document,
String partitioning,
int offset,
boolean preferOpenPartitions)
Returns the partition of the given offset of the given document.
|
static int[] |
indexOf(String[] searchStrings,
String text,
int offset)
Returns the starting position and the index of the first matching search string
in the given text that is greater than the given offset.
|
static DocumentEvent |
mergeProcessedDocumentEvents(List documentEvents)
Returns a document event which is an accumulation of a list of document events,
null if the list of document events is empty. |
static DocumentEvent |
mergeUnprocessedDocumentEvents(IDocument unprocessedDocument,
List documentEvents)
Returns a document event which is an accumulation of a list of document events,
null if the list of documentEvents is empty. |
static boolean |
overlaps(IRegion left,
IRegion right)
Returns
true if the two regions overlap. |
static Map |
removeDocumentPartitioners(IDocument document)
Removes all connected document partitioners from the given document and stores them
under their partitioning name in a map.
|
static int |
startsWith(String[] searchStrings,
String text)
Returns the index of the longest search string with which the given text starts or
-1
if none matches. |
public static final String[] DELIMITERS
public static final String[] fgDelimiters
public static String determineLineDelimiter(String text, String hint)
text
- the text to be checkedhint
- the line delimiter hintpublic static int[] indexOf(String[] searchStrings, String text, int offset)
searchStrings
- the strings to search fortext
- the text to be searchedoffset
- the offset at which to start the searchint[]
with two elements where the first is the starting offset, the second the index of the found
search string in the given searchStrings
array, returns [-1, -1]
if no match existspublic static int endsWith(String[] searchStrings, String text)
-1
if none matches.searchStrings
- the strings to search fortext
- the text to searchsearchStrings
of the longest string with which text
ends or -1
public static int startsWith(String[] searchStrings, String text)
-1
if none matches.searchStrings
- the strings to search fortext
- the text to searchsearchStrings
of the longest string with which text
starts or -1
public static int equals(String[] compareStrings, String text)
-1
if none is equal.compareStrings
- the strings to compare withtext
- the text to check-1
public static DocumentEvent mergeUnprocessedDocumentEvents(IDocument unprocessedDocument, List documentEvents) throws BadLocationException
null
if the list of documentEvents is empty.
The document of the document events are ignored.unprocessedDocument
- the document to which the document events would be applieddocumentEvents
- the list of document events to mergeBadLocationException
- might be thrown if document is not in the correct state with respect to document eventspublic static DocumentEvent mergeProcessedDocumentEvents(List documentEvents) throws BadLocationException
null
if the list of document events is empty.
The document events being merged must all refer to the same document, to which
the document changes have been already applied.documentEvents
- the list of document events to mergeBadLocationException
- might be thrown if document is not in the correct state with respect to document eventspublic static Map removeDocumentPartitioners(IDocument document)
document
- the documentString
, value type:
IDocumentPartitioner
)public static void addDocumentPartitioners(IDocument document, Map partitioners)
document
- the documentpartitioners
- the map containing the partitioners to be connected (key type: String
, value type:
IDocumentPartitioner
)public static String getContentType(IDocument document, String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException
document
- the documentpartitioning
- the partitioning to be usedoffset
- the offsetpreferOpenPartitions
- true
if precedence should be
given to a open partition ending at offset
over a
closed partition starting at offset
BadLocationException
- if offset is invalid in the documentpublic static ITypedRegion getPartition(IDocument document, String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException
document
- the documentpartitioning
- the partitioning to be usedoffset
- the offsetpreferOpenPartitions
- true
if precedence should be
given to a open partition ending at offset
over a
closed partition starting at offset
BadLocationException
- if offset is invalid in the given documentpublic static ITypedRegion[] computePartitioning(IDocument document, String partitioning, int offset, int length, boolean includeZeroLengthPartitions) throws BadLocationException
document
- the documentpartitioning
- the partitioning nameoffset
- the region offsetlength
- the region lengthincludeZeroLengthPartitions
- whether to include zero-length partitionsBadLocationException
- if the given region is invalid for the given
documentpublic static String[] computePartitionManagingCategories(IDocument document)
null
if this was impossible.document
- the documentnull
public static String getDefaultLineDelimiter(IDocument document)
document
- the documentpublic static boolean overlaps(IRegion left, IRegion right)
true
if the two regions overlap. Returns false
if one of the
arguments is null
.left
- the left regionright
- the right regiontrue
if the two regions overlap, false
otherwisepublic static String[] copy(String[] array)
array
- the string array to be copiednull
when array
is null
public static int[] copy(int[] array)
array
- the integer array to be copiednull
when array
is null
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.