Eclipse Platform
2.1

org.eclipse.jface.text
Class TextUtilities

java.lang.Object
  |
  +--org.eclipse.jface.text.TextUtilities

public class TextUtilities
extends Object

Collection of text functions.


Field Summary
static String[] fgDelimiters
          Default line delimiters used by these text functions.
 
Constructor Summary
TextUtilities()
           
 
Method Summary
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 int[] indexOf(String[] searchStrings, String text, int offset)
          Returns the starting position and the index of the longest 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fgDelimiters

public static final String[] fgDelimiters
Default line delimiters used by these text functions.
Constructor Detail

TextUtilities

public TextUtilities()
Method Detail

determineLineDelimiter

public static String determineLineDelimiter(String text,
                                            String hint)
Determines which one of default line delimiters appears first in the list. If none of them the hint is returned.
Parameters:
text - the text to be checked
hint - the line delimiter hint

indexOf

public static int[] indexOf(String[] searchStrings,
                            String text,
                            int offset)
Returns the starting position and the index of the longest matching search string in the given text that is greater than the given offset. Returns [-1, -1] if no match can be found.
Parameters:
searchStrings - the strings to search for
text - the text to be searched
offset - the offset at which to start the search
Returns:
an int[] with two elements" 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 exists

endsWith

public 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.
Parameters:
searchStrings - the strings to search for
text - the text to search
Returns:
the index in searchStrings of the longest string with which text ends or -1

startsWith

public 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.
Parameters:
searchStrings - the strings to search for
text - the text to search
Returns:
the index in searchStrings of the longest string with which text starts or -1

equals

public 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.
Parameters:
compareStrings - the strings to compare with
text - the text to check
Returns:
the index of the first equal compare string or -1

mergeUnprocessedDocumentEvents

public static DocumentEvent mergeUnprocessedDocumentEvents(IDocument unprocessedDocument,
                                                           List documentEvents)
                                                    throws BadLocationException
Returns a document event which is an accumulation of a list of document events, null if the list of documentEvents is empty. The document of the document events are ignored.
Parameters:
unprocessedDocument - the document to which the document events would be applied
documentEvents - the list of document events to merge
Returns:
returns the merged document event
Throws:
BadLocationException - might be thrown if document is not in the correct state with respect to document events

mergeProcessedDocumentEvents

public static DocumentEvent mergeProcessedDocumentEvents(List documentEvents)
                                                  throws BadLocationException
Returns a document event which is an accumulation of a list of document events, 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.
Parameters:
documentEvents - the list of document events to merge
Returns:
returns the merged document event
Throws:
BadLocationException - might be thrown if document is not in the correct state with respect to document events

Eclipse Platform
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.