net.rim.device.api.im
Class TextHitInfo

java.lang.Object
  extended by net.rim.device.api.im.TextHitInfo

public final class TextHitInfo
extends Object

Information about a document position returned by an enquiry ('hit-test') function, for example one taking an x-y point as its input. The information consists of a position, and a flag indicating whether the position is in left-to-right or right-to-left text. This flag

The position itself consists of an index into the document, which is a character edge defined by the number of UTF16 characters from the start of the document, and whether the position is a leading or trailing edge. In a document containing the three characters 'abc' the following distinct positions exist (l = leading, t = trailing)

0l a 1t 1l b 2t 2l c 3t

If the document contains bidirectional text, shown here as capitals, leading and trailing edges allow us to decide where to position the caret for editing text in one or the other script. For example, for the text 'abcDEFghi', displayed as 'abcFEDghi', we have

0l a 1t 1l b 2t 2l c 3t 6t F 5l 5t E 4l 4t D 3l 6l g 7t 7l h 8t 8l i 9t

Since:
BlackBerry API 6.0.0

Constructor Summary
TextHitInfo(int aIndex, boolean aLeadingEdge)
          Create a TextHitInfo instance given an index and a boolean indicating whether or not the index is a leading edge.
TextHitInfo(int aIndex, boolean aLeadingEdge, boolean aRightToLeft)
          Create a TextHitInfo instance given an index and booleans indicating whether or not the index is a leading edge, and whether or not the position is in right-to-left text.
 
Method Summary
 Object clone()
          Create a new TextHitInfo object by copying this object.
 boolean docPosLess(TextHitInfo aInfo)
          Return a boolean indicating whether or not the document position of this TextHitInfo object is less than the document position of the specified TextHitInfo object.
 boolean equals(TextHitInfo aInfo)
          Return a boolean indicating whether or not the specified TextHitInfo's document position is equal to this object.
 int getIndex()
          Returns the current index.
 boolean getLeadingEdge()
          Returns the leading edge of the current TextHitInfo instance.
static TextHitInfo leading(int aIndex)
          Return a TextHitInfo on the leading edge of the character at the specified charIndex.
 void set(int aIndex, boolean aLeadingEdge)
          Set the TextHitInfo instance given the new index and leading edge values.
 void set(int aIndex, boolean aLeadingEdge, boolean aRightToLeft)
          Set the TextHitInfo instance given the new index, leading edge and right-to-left values.
 String toString()
          Returns a string representation of the current TextHitInfo instance.
static TextHitInfo trailing(int aIndex)
          Return a TextHitInfo on the trailing edge of the character at the specified aIndex.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 



Constructor Detail

TextHitInfo

public TextHitInfo(int aIndex,
                   boolean aLeadingEdge)
Create a TextHitInfo instance given an index and a boolean indicating whether or not the index is a leading edge. Set the flag indicating whether the position is in a right-to-left run of text, to false.

Parameters:
aIndex - An index.
aLeadingEdge - true if the index is a leading edge, otherwise false.
Since:
BlackBerry API 6.0.0

TextHitInfo

public TextHitInfo(int aIndex,
                   boolean aLeadingEdge,
                   boolean aRightToLeft)
Create a TextHitInfo instance given an index and booleans indicating whether or not the index is a leading edge, and whether or not the position is in right-to-left text.

Parameters:
aIndex - An index.
aLeadingEdge - true if the index is a leading edge, otherwise false.
aRightToLeft - true if the position is in right-to-left text, otherwise false.
Since:
BlackBerry API 6.0.0


Method Detail

set

public void set(int aIndex,
                boolean aLeadingEdge)
Set the TextHitInfo instance given the new index and leading edge values. Set the flag indicating whether the position is in a right-to-left run of text, to false.

Parameters:
aIndex - The index value to set.
aLeadingEdge - true if the index is a leading edge, false otherwise.
Since:
BlackBerry API 6.0.0

set

public void set(int aIndex,
                boolean aLeadingEdge,
                boolean aRightToLeft)
Set the TextHitInfo instance given the new index, leading edge and right-to-left values.

Parameters:
aIndex - The index value to set.
aLeadingEdge - true if the index is a leading edge, false otherwise.
aRightToLeft - true if the position is in right-to-left text, otherwise false.
Since:
BlackBerry API 6.0.0

docPosLess

public boolean docPosLess(TextHitInfo aInfo)
Return a boolean indicating whether or not the document position of this TextHitInfo object is less than the document position of the specified TextHitInfo object. The value of the flag indicating whether the position is in a right-to-left run of text is irrelevant for this function because in a particular state of a document it will be invariant for a given position.

Parameters:
aInfo - The TextHitInfo instance to compare.
Returns:
A boolean indicating whether or not this object is less than the specified object.
Since:
BlackBerry API 6.0.0

clone

public Object clone()
Create a new TextHitInfo object by copying this object.

Returns:
A copy of this object.
Since:
BlackBerry API 6.0.0

equals

public boolean equals(TextHitInfo aInfo)
Return a boolean indicating whether or not the specified TextHitInfo's document position is equal to this object. The value of the flag indicating whether the position is in a right-to-left run of text is irrelevant for this function because in a particular state of a document it will be invariant for a given position.

Parameters:
aInfo - The TextHitInfo instance to check.
Returns:
A boolean indicating whether or not the two objects are equal.
Since:
BlackBerry API 6.0.0

getIndex

public int getIndex()
Returns the current index.

Returns:
An integer representing the current index.
Since:
BlackBerry API 6.0.0

getLeadingEdge

public boolean getLeadingEdge()
Returns the leading edge of the current TextHitInfo instance.

Returns:
A boolean indicating whether or not the TextHitInfo object has a leading edge.
Since:
BlackBerry API 6.0.0

leading

public static TextHitInfo leading(int aIndex)
Return a TextHitInfo on the leading edge of the character at the specified charIndex. The same object is returned for every call of this function.

Parameters:
aIndex - The index of the character hit.
Returns:
A TextHitInfo on the leading edge of the character at the specified charIndex.
Since:
BlackBerry API 6.0.0

trailing

public static TextHitInfo trailing(int aIndex)
Return a TextHitInfo on the trailing edge of the character at the specified aIndex. The same object is returned for every call of this function.

Parameters:
aIndex - The index of the character hit.
Returns:
A TextHitInfo on the trailing edge of the character at the specified charIndex.
Since:
BlackBerry API 6.0.0

toString

public String toString()
Returns a string representation of the current TextHitInfo instance.

Overrides:
toString in class Object
Returns:
A string representing this instance.
Since:
BlackBerry API 6.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal