Package jsyntaxpane
Class Token
- java.lang.Object
-
- jsyntaxpane.Token
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable
public class Token extends java.lang.Object implements java.io.Serializable, java.lang.Comparable
A Token in a Document. Tokens do NOT store a reference to the underlying SyntaxDocument, and must generally be obtained from the SyntaxDocument methods. The reason for not storing the SyntaxDocument is simply for memory, as the number of Tokens per document can be large, you may end up with twice the memory in a SyntaxDocument with Tokens than a simple PlainDocument.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description short
kind
The kind of the Document.int
length
byte
pairValue
the pair value to use if this token is one of a pair: This is how it is used: The openning part will have a positive number X The closing part will have a negative number X X should be unique for a pair: e.g.int
start
TokenType
type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(java.lang.Object o)
int
end()
return the end position of the token.boolean
equals(java.lang.Object obj)
java.lang.String
getString(javax.swing.text.Document doc)
java.lang.CharSequence
getText(javax.swing.text.Document doc)
Get the text of the token from this documentint
hashCode()
java.lang.String
toString()
-
-
-
Field Detail
-
type
public final TokenType type
-
start
public final int start
-
length
public final int length
-
pairValue
public final byte pairValue
the pair value to use if this token is one of a pair: This is how it is used: The openning part will have a positive number X The closing part will have a negative number X X should be unique for a pair: e.g. for [ pairValue = +1 for ] pairValue = -1
-
kind
public final short kind
The kind of the Document. This is only needed if proper Parsing of a document is needed and it makes certain operations faster. You can use any of the supplied Generic Values, or create your language specific uses by using USER_FIRST + x;- See Also:
- Constant Field Values
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(java.lang.Object o)
- Specified by:
compareTo
in interfacejava.lang.Comparable
-
end
public int end()
return the end position of the token.- Returns:
- start + length
-
getText
public java.lang.CharSequence getText(javax.swing.text.Document doc)
Get the text of the token from this document- Parameters:
doc
-- Returns:
-
getString
public java.lang.String getString(javax.swing.text.Document doc)
-
-