站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

CharSequenceUtilities (Editor Utilities) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.util/1 1.17

org.netbeans.lib.editor.util
Class CharSequenceUtilities

java.lang.Object
  extended by org.netbeans.lib.editor.util.CharSequenceUtilities

public final class CharSequenceUtilities
extends Object

Utility methods related to character sequences.


Method Summary
static void append(StringBuffer sb, CharSequence text)
          Append character sequence to the given string buffer.
static void append(StringBuffer sb, CharSequence text, int start, int end)
          Append part of the character sequence to the given string buffer.
static void checkIndexesValid(CharSequence text, int start, int end)
          Ensure that the given start and end parameters are valid indices of the given text.
static void checkIndexNonNegative(int index)
          Ensure that the given index is >=0 and lower than the given length.
static void checkIndexValid(int index, int length)
          Ensure that the given index is >=0 and lower than the given length.
static String debugChar(char ch)
          Return the text description of the given character translating the special characters (and '\') into escape sequences.
static void debugChar(StringBuffer sb, char ch)
          Append the character description to the given string buffer translating the special characters (and '\') into escape sequences.
static void debugChar(StringBuilder sb, char ch)
          Append the character description to the given string builder translating the special characters (and '\') into escape sequences.
static String debugText(CharSequence text)
          Create text description as String translating the special characters (and '\') into escape sequences.
static void debugText(StringBuffer sb, CharSequence text)
          Append the text description to the given string buffer translating the special characters (and '\') into escape sequences.
static void debugText(StringBuilder sb, CharSequence text)
          Append the text description to the given string builder translating the special characters (and '\') into escape sequences.
static boolean endsWith(CharSequence text, CharSequence suffix)
          Implementation of String.endsWith(String) for character sequences.
static boolean equals(CharSequence text, Object o)
          Method that compares a given character sequence to another object.
static int indexOf(CharSequence text, CharSequence seq)
          Implementation of String.indexOf(String) for character sequences.
static int indexOf(CharSequence text, CharSequence seq, int fromIndex)
          Implementation of String.indexOf(String,int) for character sequences.
static int indexOf(CharSequence text, int ch)
          Implementation of String.indexOf(int) for character sequences.
static int indexOf(CharSequence text, int ch, int fromIndex)
          Implementation of String.indexOf(int,int) for character sequences.
static int lastIndexOf(CharSequence text, CharSequence seq)
          Implementation of String.lastIndexOf(String) for character sequences.
static int lastIndexOf(CharSequence text, CharSequence seq, int fromIndex)
          Implementation of String.lastIndexOf(String,int) for character sequences.
static int lastIndexOf(CharSequence text, int ch)
          Implementation of String.lastIndexOf(int) for character sequences.
static int lastIndexOf(CharSequence text, int ch, int fromIndex)
          Implementation of String.lastIndexOf(int,int) for character sequences.
static boolean startsWith(CharSequence text, CharSequence prefix)
          Implementation of String.startsWith(String) for character sequences.
static int stringLikeHashCode(CharSequence text)
          Compute String-like hashcode over given CharSequence.
static boolean textEquals(CharSequence text1, CharSequence text2)
          Test whether whether the given character sequences represent the same text.
static String toString(CharSequence text)
          Create a string from the given character sequence by first creating a StringBuilder and appending the whole character sequence to it.
static String toString(CharSequence text, int start, int end)
          Create string for the given portion of the character sequence.
static CharSequence trim(CharSequence text)
          Implementation of String.trim() for character sequences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

stringLikeHashCode

public static int stringLikeHashCode(CharSequence text)
Compute String-like hashcode over given CharSequence.

Parameters:
text - character sequence for which the hashcode is being computed.
Returns:
hashcode of the given character sequence.

equals

public static boolean equals(CharSequence text,
                             Object o)
Method that compares a given character sequence to another object. The match is successful if the other object is a character sequence as well and both character sequences contain the same characters.

Parameters:
text - character sequence being compared to the given object. It must not be null.
o - object to be compared to the character sequence. It can be null.
Returns:
true if both parameters are non-null and they are equal in String-like manner.

textEquals

public static boolean textEquals(CharSequence text1,
                                 CharSequence text2)
Test whether whether the given character sequences represent the same text.
The match is successful if the contained characters of the two character sequences are the same.

Parameters:
text1 - first character sequence being compared. It must not be null.
text2 - second character sequence being compared. It must not be null.
Returns:
true if both parameters are equal in String-like manner.

toString

public static String toString(CharSequence text)
Create a string from the given character sequence by first creating a StringBuilder and appending the whole character sequence to it.
The method does not call toString() on the given character sequence.

Parameters:
text - character sequence for which the String form should be created.
Returns:
string representation of the character sequence.

toString

public static String toString(CharSequence text,
                              int start,
                              int end)
Create string for the given portion of the character sequence.

Parameters:
text - non-null text.
start - >=0 and end - >=start and

append

public static void append(StringBuffer sb,
                          CharSequence text)
Append character sequence to the given string buffer.
This method is no longer needed in JDK 1.5 where the implementation does not create an extra java.lang.String instance.


append

public static void append(StringBuffer sb,
                          CharSequence text,
                          int start,
                          int end)
Append part of the character sequence to the given string buffer.
This method is no longer needed in JDK 1.5 where the implementation of the same functionality is available in the StringBuffer directly.


indexOf

public static int indexOf(CharSequence text,
                          int ch)
Implementation of String.indexOf(int) for character sequences.


indexOf

public static int indexOf(CharSequence text,
                          int ch,
                          int fromIndex)
Implementation of String.indexOf(int,int) for character sequences.


indexOf

public static int indexOf(CharSequence text,
                          CharSequence seq)
Implementation of String.indexOf(String) for character sequences.


indexOf

public static int indexOf(CharSequence text,
                          CharSequence seq,
                          int fromIndex)
Implementation of String.indexOf(String,int) for character sequences.


lastIndexOf

public static int lastIndexOf(CharSequence text,
                              CharSequence seq)
Implementation of String.lastIndexOf(String) for character sequences.


lastIndexOf

public static int lastIndexOf(CharSequence text,
                              CharSequence seq,
                              int fromIndex)
Implementation of String.lastIndexOf(String,int) for character sequences.


lastIndexOf

public static int lastIndexOf(CharSequence text,
                              int ch)
Implementation of String.lastIndexOf(int) for character sequences.


lastIndexOf

public static int lastIndexOf(CharSequence text,
                              int ch,
                              int fromIndex)
Implementation of String.lastIndexOf(int,int) for character sequences.


startsWith

public static boolean startsWith(CharSequence text,
                                 CharSequence prefix)
Implementation of String.startsWith(String) for character sequences.


endsWith

public static boolean endsWith(CharSequence text,
                               CharSequence suffix)
Implementation of String.endsWith(String) for character sequences.


trim

public static CharSequence trim(CharSequence text)
Implementation of String.trim() for character sequences.


debugChar

public static void debugChar(StringBuffer sb,
                             char ch)
Append the character description to the given string buffer translating the special characters (and '\') into escape sequences.

Parameters:
sb - non-null string buffer to append to.
ch - character to be debugged.

debugChar

public static void debugChar(StringBuilder sb,
                             char ch)
Append the character description to the given string builder translating the special characters (and '\') into escape sequences.

Parameters:
sb - non-null string buffer to append to.
ch - character to be debugged.

debugChar

public static String debugChar(char ch)
Return the text description of the given character translating the special characters (and '\') into escape sequences.

Parameters:
ch - char to debug.
Returns:
non-null debug text.

debugText

public static void debugText(StringBuffer sb,
                             CharSequence text)
Append the text description to the given string buffer translating the special characters (and '\') into escape sequences.

Parameters:
sb - non-null string buffer to append to.
text - non-null text to be debugged.

debugText

public static void debugText(StringBuilder sb,
                             CharSequence text)
Append the text description to the given string builder translating the special characters (and '\') into escape sequences.

Parameters:
sb - non-null string builder to append to.
text - non-null text to be debugged.

debugText

public static String debugText(CharSequence text)
Create text description as String translating the special characters (and '\') into escape sequences.

Parameters:
text - non-null text to be debugged.
Returns:
non-null string containing the debug text.

checkIndexNonNegative

public static void checkIndexNonNegative(int index)
Ensure that the given index is >=0 and lower than the given length.

Throws:
IndexOutOfBoundsException - if the index is not within bounds.

checkIndexValid

public static void checkIndexValid(int index,
                                   int length)
Ensure that the given index is >=0 and lower than the given length.

Throws:
IndexOutOfBoundsException - if the index is not within bounds.

checkIndexesValid

public static void checkIndexesValid(CharSequence text,
                                     int start,
                                     int end)
Ensure that the given start and end parameters are valid indices of the given text.

Throws:
IndexOutOfBoundsException - if the start or end are not within bounds of the given text.

org.netbeans.modules.editor.util/1 1.17

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.