Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


oracle.ide.util
Class FastStringBuffer

java.lang.Object
  extended by oracle.ide.util.FastStringBuffer


public final class FastStringBuffer
extends java.lang.Object

This FastStringBuffer class was invented to use instead of StringBuffer in those instances when we know a buffer is not shared. It gets away from some of the complications of synchronization and sharing. Note: This class should be considered deprecated since the 11.1.1 release, even though it is not marked as such. The core Java platform provides an unsynchronized character buffer in StringBuilder, which you should use in preference to this class.


Field Summary
static int NOT_A_CHAR
           
static int NOTACHAR
          FastStringBuffer.NOTACHAR is used as a return value to indicate when a fetch has run out of bounds

 

Constructor Summary
FastStringBuffer()
           
FastStringBuffer(char[] cArray)
           
FastStringBuffer(char[] cArray, int offset, int len)
           
FastStringBuffer(char c, int nChars)
           
FastStringBuffer(int length)
           
FastStringBuffer(java.lang.String str)
           

 

Method Summary
 FastStringBuffer append(char c)
           
 FastStringBuffer append(char[] str)
           
 FastStringBuffer append(char[] str, int offset, int len)
           
 FastStringBuffer append(char c, int appendCount)
           
 FastStringBuffer append(FastStringBuffer fsb)
           
 FastStringBuffer append(java.lang.Object obj)
           
 FastStringBuffer append(java.lang.String str)
           
 int capacity()
           
 char charAt(int index)
           
static char charFromString(java.lang.String s)
          This method returns the first "logical" char value from the given String.
static java.lang.String charToUnicodeEscape(char ch)
          Returns a String containing a unicode escape sequence representing the given character.
 char currentChar()
           
 void empty()
           
static FastStringBuffer expandDelimiters(java.lang.String sourceString, java.lang.String delimiters)
          Creates a copy of the given FastStringBuffer, but will translate any characters in the specified delimiter set into unicode "escape" sequences (e.g.
 char firstChar()
           
 char[] getChars()
          Retrieves the contents of this FastStringBuffer.
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
           
 int getLength()
           
 int getOffset()
           
 char[] getValue()
           
 int indexOf(FastStringBuffer subStr, int fromIndex)
          Just like String.indexOf but uses FastStringBuffer
 int indexOfSubstring(FastStringBuffer buffer, int fromIndex)
           
 int IndexOfSubString(FastStringBuffer subStr, int fromIndex)
          Deprecated. since 11.1.1. Use indexOfSubstring(FastStringBuffer,int).
 FastStringBuffer insert(int offset, boolean b)
           
 FastStringBuffer insert(int offset, char c)
           
 FastStringBuffer insert(int offset, char[] str)
           
 FastStringBuffer insert(int offset, java.lang.Object obj)
           
 FastStringBuffer insert(int offset, java.lang.String str)
           
 char lastChar()
          Returns the last character in the string and positions the offset there.
 int lastIndexOf(FastStringBuffer subStr, int fromIndex)
          Just like String.lastIndexOf but uses FastStringBuffer
 int length()
           
 void makeroom(int minimumCapacity)
           
 char nextChar()
           
 FastStringBuffer normalizeDelimiters(java.lang.String delimiters)
          The opposite of expandDelimiters, this method will turn any unicode escape sequences that would result in one of the given delimiters characters into the displayable form of that delimiters.
 int offset()
           
 char parseBackSlash()
          Given a FastStringBuffer where charAt(), nextChar() or priorChar() have just returned the backslash character (in other words, where value[offset] == '\\', this routine will parse the rest as a single character backslash value (e.g.
 FastStringBuffer parseLiteral()
          Given a string which needs to be parsed as a literal string (including backslash characters), and assuming value[offset] is currently pointing at the starting delimiter of this string, this routine will buffer everything up to (but not including) another delimiter like the first.
 FastStringBuffer parseLiteral(char delimiter, boolean allowDouble)
          Given a string which needs to be parsed as a literal string (including backslash characters), and assuming value[offset] is currently pointing at the starting delimiter of this string, this routine will buffer everything up to (but not including) another delimiter like the first.
 char peekNextChar()
          To be used in a firstChar()/nextChar() sort of loop, this method peeks at the next character WITHOUT advancing any pointers.
 char priorChar()
           
 void removeChar()
          This method removes the "current" character from the buffer, where "current" is defined by 'offset'.
 void removeCharAt(int index)
          This method removes the character from the buffer at value[offset].
 void removeChars(int removeCount)
          This method removes the specified number of characters from the current position (where "current" is defined as value[offset].
 void removeCharsAt(int index, int removeCount)
          This method will remove a number of characters from the buffer
 void replaceCharAt(int index, char c)
           
 void setCharAt(int index, char ch)
           
 void setLength(int newLength)
           
 void setOffset(int offset)
           
static FastStringBuffer sourceToText(java.lang.String source)
          Translates a String which is compatible with source code (including leading and trailing quote, expands backslash charaters, etc.) into its actual String representation (e.g.
static java.lang.String stringFromChar(char c)
          The opposite of charFromString, this method will return a String which best represents the given char.
 FastStringBuffer substring(int startPos, int endPos)
          Just like String.substring() but uses FastStringBuffer
static FastStringBuffer textToSource(java.lang.String text, boolean hasEscapes)
          Converts a String into a form that will compile (translating special characters into backslash-something and adding leading and trailing quotes.
static FastStringBuffer textToSource(java.lang.String text, boolean hasEscapes, java.lang.String indentString)
           
 java.lang.String toString()
           
 char[] value()
           

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

NOTACHAR

public static final int NOTACHAR
FastStringBuffer.NOTACHAR is used as a return value to indicate when a fetch has run out of bounds
See Also:
Constant Field Values

NOT_A_CHAR

public static final int NOT_A_CHAR
See Also:
Constant Field Values

Constructor Detail

FastStringBuffer

public FastStringBuffer()

FastStringBuffer

public FastStringBuffer(int length)

FastStringBuffer

public FastStringBuffer(java.lang.String str)

FastStringBuffer

public FastStringBuffer(char[] cArray)

FastStringBuffer

public FastStringBuffer(char[] cArray,
                        int offset,
                        int len)

FastStringBuffer

public FastStringBuffer(char c,
                        int nChars)

Method Detail

empty

public void empty()

value

public char[] value()

getValue

public char[] getValue()

length

public int length()

getLength

public int getLength()

capacity

public int capacity()

offset

public int offset()

getOffset

public int getOffset()

setOffset

public void setOffset(int offset)

makeroom

public void makeroom(int minimumCapacity)

setLength

public void setLength(int newLength)

charAt

public char charAt(int index)

firstChar

public char firstChar()

lastChar

public char lastChar()
Returns the last character in the string and positions the offset there. Meant to be used as lastChar()/priorChar() loop
Returns:
The final char (or FastStringBuffer.NOTACHAR) if empty)

currentChar

public char currentChar()

nextChar

public char nextChar()

priorChar

public char priorChar()

peekNextChar

public char peekNextChar()
To be used in a firstChar()/nextChar() sort of loop, this method peeks at the next character WITHOUT advancing any pointers.

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)

getChars

public char[] getChars()
Retrieves the contents of this FastStringBuffer.

setCharAt

public void setCharAt(int index,
                      char ch)

removeCharAt

public void removeCharAt(int index)
This method removes the character from the buffer at value[offset]. It adjusts 'offset' so a nextChar() loop will find the character immediately following the one removed.

removeChar

public void removeChar()
This method removes the "current" character from the buffer, where "current" is defined by 'offset'. It is intended to be used in a firstChar/nextChar loop. It will adjust 'offset' so that the next nextChar() will function properly.

removeCharsAt

public void removeCharsAt(int index,
                          int removeCount)
This method will remove a number of characters from the buffer

removeChars

public void removeChars(int removeCount)
This method removes the specified number of characters from the current position (where "current" is defined as value[offset]. It adjusts 'offset' so the next nextChar() will encounter the next character in the buffer.

replaceCharAt

public void replaceCharAt(int index,
                          char c)

append

public FastStringBuffer append(java.lang.Object obj)

append

public FastStringBuffer append(char c)

append

public FastStringBuffer append(char c,
                               int appendCount)

append

public FastStringBuffer append(java.lang.String str)

append

public FastStringBuffer append(FastStringBuffer fsb)

append

public FastStringBuffer append(char[] str)

append

public FastStringBuffer append(char[] str,
                               int offset,
                               int len)

insert

public FastStringBuffer insert(int offset,
                               java.lang.Object obj)

insert

public FastStringBuffer insert(int offset,
                               java.lang.String str)

insert

public FastStringBuffer insert(int offset,
                               char[] str)

insert

public FastStringBuffer insert(int offset,
                               boolean b)

insert

public FastStringBuffer insert(int offset,
                               char c)

IndexOfSubString

public int IndexOfSubString(FastStringBuffer subStr,
                            int fromIndex)
Deprecated. since 11.1.1. Use indexOfSubstring(FastStringBuffer,int).

indexOfSubstring

public int indexOfSubstring(FastStringBuffer buffer,
                            int fromIndex)

indexOf

public int indexOf(FastStringBuffer subStr,
                   int fromIndex)
Just like String.indexOf but uses FastStringBuffer

lastIndexOf

public int lastIndexOf(FastStringBuffer subStr,
                       int fromIndex)
Just like String.lastIndexOf but uses FastStringBuffer

substring

public FastStringBuffer substring(int startPos,
                                  int endPos)
Just like String.substring() but uses FastStringBuffer

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

parseBackSlash

public char parseBackSlash()
Given a FastStringBuffer where charAt(), nextChar() or priorChar() have just returned the backslash character (in other words, where value[offset] == '\\', this routine will parse the rest as a single character backslash value (e.g. "?"), advancing offset. It will return that character and leave the FastStringBuffer pointing at the next character after the value.
Returns:
The single character value.

parseLiteral

public FastStringBuffer parseLiteral(char delimiter,
                                     boolean allowDouble)
Given a string which needs to be parsed as a literal string (including backslash characters), and assuming value[offset] is currently pointing at the starting delimiter of this string, this routine will buffer everything up to (but not including) another delimiter like the first. It will advance offset past that delimiter so subsequent string processing can continue.
Parameters:
delimiter - the char value which will mark the end of the literal
allowDouble - true means two delimiters in a row evaluate to a single occurance of that literal in the string (and it is not a delimiter)
Returns:
It returns a new FastStringBuffer containing the literal.

parseLiteral

public FastStringBuffer parseLiteral()
Given a string which needs to be parsed as a literal string (including backslash characters), and assuming value[offset] is currently pointing at the starting delimiter of this string, this routine will buffer everything up to (but not including) another delimiter like the first. It will advance offset past that delimiter so subsequent string processing can continue.
Returns:
It returns a new FastStringBuffer containing the literal.

expandDelimiters

public static FastStringBuffer expandDelimiters(java.lang.String sourceString,
                                                java.lang.String delimiters)
Creates a copy of the given FastStringBuffer, but will translate any characters in the specified delimiter set into unicode "escape" sequences (e.g. ',' becomes ','). This will allow the new FastStringBuffer to use the normal StringTokenizer for parsing.
Parameters:
sourceString - Contains a String to be scanned and converted (though this String itself will not be altered).
delimiters - Contains a String consisting of the delimiters you don't want to see in the output StringBuffer (e.g. new String("\t\r\n,"). Wherever these occur in the sourceString, they will be converted to a unicode escape sequence.
Returns:
A new FastStringBuffer containing all the characters of sourceString, but with all delimiters expanded to unicode escape sequences.

normalizeDelimiters

public FastStringBuffer normalizeDelimiters(java.lang.String delimiters)
The opposite of expandDelimiters, this method will turn any unicode escape sequences that would result in one of the given delimiters characters into the displayable form of that delimiters. Do NOT pass in a nondisplayable delimiter (like '\r')

charToUnicodeEscape

public static java.lang.String charToUnicodeEscape(char ch)
Returns a String containing a unicode escape sequence representing the given character. For example charToUnicodeEscape('1') would return new String("\\u0031").
Parameters:
ch - The character to be converted to a unicode escape sequence
Returns:
A new String containing the escape sequence

charFromString

public static char charFromString(java.lang.String s)
This method returns the first "logical" char value from the given String. This means it handles backslashes, unicode escape sequences, etc.

stringFromChar

public static java.lang.String stringFromChar(char c)
The opposite of charFromString, this method will return a String which best represents the given char. This means it expands it into a unicode escape sequence if needed.

sourceToText

public static FastStringBuffer sourceToText(java.lang.String source)
Translates a String which is compatible with source code (including leading and trailing quote, expands backslash charaters, etc.) into its actual String representation (e.g. the literal "\n" becomes the real linefeed character, etc.)

textToSource

public static FastStringBuffer textToSource(java.lang.String text,
                                            boolean hasEscapes)
Converts a String into a form that will compile (translating special characters into backslash-something and adding leading and trailing quotes.

textToSource

public static FastStringBuffer textToSource(java.lang.String text,
                                            boolean hasEscapes,
                                            java.lang.String indentString)

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


Copyright © 1997, 2012, Oracle. All rights reserved.