|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.springsource.util.osgi.manifest.parse.standard.BasicHeaderToken
public final class BasicHeaderToken
Instances of BasicHeaderToken represent tokens lexed from the input data.
Internals:
A BasicHeaderToken effectively encapsulates the start and end of the token
within the input data and some bitflag information that was learned during
lexing that can benefit parsing. To avoid unnecessary chopping up of the
input data, each token holds a reference to the complete headertext - and
should the token ever need to be extracted we can grab the piece of interest.
Sometimes the token values are never used and it would be a waste to chop up
the data and create an unnecessary array.
Due to the way the grammar is defined to support parameter values, there is a
notion in a HeaderToken of extension. The grammar defines a token to be
([a-z][A-Z][0-9]_-)+ but in order to allow things like 1.2.3 and com.foo.bar
as parameter values without needing them to be quoted it defines an extended
token that is allowed for parameter values. The lexer only knows about
Tokens. However, it understands the notion of extension, which at its
simplest means a sequence of tokens with dots between them. So for any token
it can have the IS_EXTENDED bitflag set - and if that is set the token is the
start of an extended token, and it ends at the extendedEndOffset.
Concurrent Semantics
Threadsafe.
Field Summary | |
---|---|
private static byte |
ATTRIBUTE_NAME
|
private byte |
bits
|
private static byte |
DIRECTIVE_NAME
|
private int |
endoffset
|
private int |
extendedEndOffset
|
private static byte |
FOLLOWED_BY_SPACE
|
private char[] |
headerText
|
private static byte |
IS_EXTENDED
|
private HeaderTokenKind |
kind
|
private static byte |
SPACED
|
private static byte |
STARTED_WITH_LETTER
|
private int |
startoffset
|
Constructor Summary | |
---|---|
private |
BasicHeaderToken(char[] headerText,
HeaderTokenKind kind,
int start,
int end)
Private constructor, please use the factory method |
Method Summary | |
---|---|
char[] |
extendedValue()
This method creates a new array each time it is called - try not call it more than once. |
char |
firstChar()
|
boolean |
firstCharIsLetter()
|
int |
getEndOffset()
|
int |
getExtendedEndOffset()
|
HeaderTokenKind |
getKind()
|
int |
getStartOffset()
|
boolean |
hasFollowingSpace()
|
boolean |
isAttributeName()
|
boolean |
isAttributeOrDirectiveName()
|
boolean |
isDirectiveName()
|
boolean |
isExtended()
|
boolean |
isSpaced()
|
static BasicHeaderToken |
makeToken(char[] data,
HeaderTokenKind kind,
int start,
int end)
BasicHeaderToken factory method. |
void |
setExtendedOffset(int endOffset)
|
java.lang.String |
stringValue()
|
private char[] |
subarray(int start,
int end)
|
void |
tagAsAttributeName()
|
void |
tagAsDirectiveName()
|
void |
tagAsFollowedBySpace()
|
void |
tagAsSpaced()
|
void |
tagAsStartedWithLetter()
|
java.lang.String |
toString()
|
char[] |
value()
This method creates a new array each time it is called - try not call it more than once. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private HeaderTokenKind kind
private char[] headerText
private int startoffset
private int endoffset
private int extendedEndOffset
private byte bits
private static final byte STARTED_WITH_LETTER
private static final byte ATTRIBUTE_NAME
private static final byte DIRECTIVE_NAME
private static final byte SPACED
private static final byte IS_EXTENDED
private static final byte FOLLOWED_BY_SPACE
Constructor Detail |
---|
private BasicHeaderToken(char[] headerText, HeaderTokenKind kind, int start, int end)
Method Detail |
---|
public static BasicHeaderToken makeToken(char[] data, HeaderTokenKind kind, int start, int end)
data
- header textkind
- of headerstart
- offsetend
- offset
public char[] value()
value
in interface HeaderToken
public java.lang.String toString()
toString
in class java.lang.Object
public HeaderTokenKind getKind()
getKind
in interface HeaderToken
public int getEndOffset()
getEndOffset
in interface HeaderToken
public int getStartOffset()
getStartOffset
in interface HeaderToken
public java.lang.String stringValue()
stringValue
in interface HeaderToken
public char[] extendedValue()
extendedValue
in interface HeaderToken
private final char[] subarray(int start, int end)
public boolean isExtended()
isExtended
in interface HeaderToken
public void setExtendedOffset(int endOffset)
public int getExtendedEndOffset()
getExtendedEndOffset
in interface HeaderToken
public boolean isSpaced()
isSpaced
in interface HeaderToken
public boolean firstCharIsLetter()
firstCharIsLetter
in interface HeaderToken
public boolean isAttributeOrDirectiveName()
isAttributeOrDirectiveName
in interface HeaderToken
public boolean hasFollowingSpace()
hasFollowingSpace
in interface HeaderToken
public char firstChar()
firstChar
in interface HeaderToken
public boolean isAttributeName()
isAttributeName
in interface HeaderToken
public boolean isDirectiveName()
isDirectiveName
in interface HeaderToken
public void tagAsDirectiveName()
public void tagAsAttributeName()
public void tagAsStartedWithLetter()
public void tagAsSpaced()
public void tagAsFollowedBySpace()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |