Packages
 In this topic

*Constructors

*Methods

*Fields

 

Packages   PreviousThis PackageNext
Package com.ms.fx   Previous This
Package
Next

 


Class FxText

public class FxText
{
  // Fields
  public char buffer[];
  public int nBuffSize;
  public int nChars;

  // Constructors
  public FxText();
  public FxText(String newBuff);
  public FxText(char newBuff[]);
  public FxText(char newBuff[], int offset, int length);

  // Methods
  public void append(char key);
  public void append(char key[]);
  public void append(char key[], int offs, int len);
  public void ensureResize(int amountNeeded);
  public char getChar(int idx);
  public int getLength();
  public int getWordBreak( int iChar );
  public void insert(char key, int iPos);
  public void insert(char key[], int offs, int keyLen, int iPos);
  public void insert(char key[], int iPos);
  public boolean isDelimiter(int iPos);
  public boolean isWhite(int i);
  public boolean isWhite(int i, boolean treatLFasWhite);
  public void remove(int iPos, int numberToRemove);
  public void setText(char newBuff[]);
  public void setText(String s);
  public void setText(char newBuff[], int offset, int nCharsNew);
}

This class performs basic insertion and deletion operations on a text buffer. The FxText class is similar to the java.lang.StringBuffer class, but there is no synchronization on the buffer in the FxText class, which makes it much more efficient. FxText buffers, which are designed to be plugged into UI components, are the basis for FxFormattedText.

As with the StringBuffer class, append and insert are the principle operations of the FxText class, and the setText method allows buffer substitution.

Warning Because the FxTextclass has no synchronization, it is not thread safe and should not be used in multithreaded applications. To avoid a possible conflict with multiple threads, synchronize the FxFormattedTextobject.

Constructors

FxText

public FxText();

Creates an empty text buffer.

FxText

public FxText(String newBuff);

Creates a text buffer based on a string.

ParameterDescription
newBuff The string that the new text buffer is based on.

FxText

public FxText(char newBuff[]);

Creates a text buffer based on a character array.

ParameterDescription
newBuff The array of characters that the new text buffer is based on.

FxText

public FxText(char newBuff[], int offset, int length);

Creates a text buffer based on a portion of a character array.

ParameterDescription
newBuff The array of characters that the new text buffer is based on.
offset The offset to use.
length The length of the array to be used.

Methods

append

public void append(char key);

Appends a character to the end of the buffer.

Return Value:

No return value.

ParameterDescription
key The character to append.

append

public void append(char key[]);

Appends an array of characters to the end of the buffer.

Return Value:

No return value.

ParameterDescription
key The array of characters to append.

append

public void append(char key[], int offs, int len);

Appends an array of characters, or a subsection of an array, to the end of the buffer.

Return Value:

No return value.

ParameterDescription
key The array of characters to append.
offs The offset of the array to copy from.
len The length of the array or length of the array subsection to copy.

ensureResize

public void ensureResize(int amountNeeded);

Ensures that the current text buffer has enough room to handle any changes. If the buffer is too small, a larger text buffer is created by using the amountNeeded parameter. Use this method before insert, append, and setText operations to check bounds on a text buffer.

Return Value:

No return value.

ParameterDescription
amountNeeded The number of characters needed for expanded text buffer operations.

getChar

public char getChar(int idx);

Retrieves the character at the given location.

Return Value:

Returns the character at position idx.

ParameterDescription
idx The index of the character in an array.

getLength

public int getLength();

Retrieves the number of characters in the buffer.

Return Value:

Returns the number of characters in the buffer.

getWordBreak

public int getWordBreak( int iChar );

Retrieves the number of characters in the next word.

Return Value:

Returns the number of characters in the next word.

ParameterDescription
iChar The location to start searching for the next word.

Remarks:

The next word includes leading white space, but not trailing white space.

insert

public void insert(char key, int iPos);

Inserts a single character into the buffer.

Return Value:

No return value.

ParameterDescription
key The character to insert.
iPos The position in the buffer to insert the character.

insert

public void insert(char key[], int offs, int keyLen, int iPos);

Inserts an array of characters or an array fragment into the buffer.

Return Value:

No return value.

ParameterDescription
key The array of characters to insert.
offs The offset in the array or array fragment to start from.
keyLen The length of the character array fragment.
iPos The position in the buffer to insert the character.

insert

public void insert(char key[], int iPos);

Inserts an array of characters into the buffer.

Return Value:

No return value.

ParameterDescription
key The array of characters to insert.
iPos The position in the buffer to insert the characters.

isDelimiter

public boolean isDelimiter(int iPos);

Checks if the character is a delimiter.

Return Value:

Returns true if it is a delimiter; otherwise, returns false.

ParameterDescription
iPos The character position to check.

isWhite

public boolean isWhite(int i);

Determines if a character is a white space.

Return Value:

Returns true if it is a white space; otherwise, returns false.

ParameterDescription
i The offset in buffer.

isWhite

public boolean isWhite(int i, boolean treatLFasWhite);

Determines if a character is a white space and whether to treat line feed characters as white spaces.

Return Value:

Returns true if it is considered white space; otherwise, returns false.

ParameterDescription
i The offset in buffer.
treatLFasWhite Set this value to true if a line feed character should be treated as a white space.

Remarks:

This method is useful for marking the end of a line of text.

remove

public void remove(int iPos, int numberToRemove);

Deletes one or more characters in the text buffer.

Return Value:

No return value.

ParameterDescription
iPos The position at which to start the deletion.
numberToRemove The number of characters to remove.

setText

public void setText(char newBuff[]);

Replaces the text in the sentence with that of a character array.

Return Value:

No return value.

ParameterDescription
newBuff[] A character array.

setText

public void setText(String s);

Replaces the text in the sentence with that of a specified string.

Return Value:

No return value.

ParameterDescription
s The string that replaces the text buffer.

setText

public void setText(char newBuff[], int offset, int nCharsNew);

Replaces the text in the sentence with that of a character array, starting at a specified offset.

Return Value:

No return value.

ParameterDescription
newBuff A character array.
offset The specified starting offset.
nCharsNew The length of the new character array.

Fields

buffer[]
The buffer containing the sentence.
nBuffSize
The current maximum size of the buffer (in characters).
nChars
The number of characters in the buffer.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.