com.springsource.util.osgi.manifest.parse.standard
Class StandardHeaderLexer

java.lang.Object
  extended by com.springsource.util.osgi.manifest.parse.standard.StandardHeaderLexer

public class StandardHeaderLexer
extends java.lang.Object

Lex an input string into a series of tokens. The possible tokens are defined in HeaderTokenKind Basic token descriptions:

header ::= clause ( ?,? clause ) * clause ::= path ( ?;? path ) * ( ?;? parameter ) * path ::= path-unquoted | (?"? path-unquoted ?"?) path-unquoted ::= path-sep | path-sep? path-element (path-sep path-element)* path-element ::= [^/"\#x0D#x0A#x00]+ path-sep ::= ?/? Concurrent Semantics
Threadsafe.

Author:
Andy Clement

Field Summary
private  boolean allowsPathToken
           
private static int ALPHABETIC
           
private static int ALPHANUMERIC
           
(package private)  char[] data
           
private  int datalen
           
private  int datapos
           
private static int DIGITS
           
private  BasicHeaderToken extensionStart
           
private  boolean foundSpace
           
private static int IDENTIFIER
           
private static byte IS_ALPHA
           
private static byte IS_ALPHANUM
           
private static byte IS_DIGIT
           
private static byte IS_TOKEN
           
private static byte IS_UNDERLINE_OR_MINUS
           
private  BasicHeaderToken lastEmittedToken
           
private static byte[] lookup
           
private static int PATHELEMENT
           
private static int QUOTEDSTRING
           
private  int state
           
private static HeaderTokenKind[] stateToTokenMap
           
private static int TOKEN
           
private static boolean[] tokenExtension
           
private  int tokenStart
           
private  boolean tokenStartedWithLetter
           
private  HeaderTokenStream tokenStream
           
private static int UNKNOWN
           
 
Constructor Summary
StandardHeaderLexer()
           
StandardHeaderLexer(boolean allowsPathToken)
           
 
Method Summary
private  void emitColonEquals(int pos)
           
private  void emitDotStar(int pos)
           
private  void emitToken(HeaderTokenKind kind, int pos)
           
private  void emitToken(int tokenEnd)
           
private  void emitToken2(HeaderTokenKind kind, int pos)
           
 HeaderTokenStream getTokenStream()
           
private  void initializeLexer(java.lang.String header)
           
private  boolean isAlphabetic(int ch)
           
private  boolean isAlphanumeric(int ch)
           
private  boolean isDigit(int ch)
           
private  boolean isToken(int ch)
           
private  boolean isUnderlineMinus(int ch)
           
private  boolean pathEnd(char ch)
           
 void process(java.lang.String header)
          Start in the UNKNOWN state where anything may come next, as characters are encountered and consumed the state will transition amongst other states.
private  void processAlphabetic()
           
private  void processColon()
           
private  void processDigit()
           
private  void processDot()
           
private  void processJavaIdentifierPart()
           
private  void processJavaIdentifierStart()
           
private  void processNul()
           
private  void processQuote()
           
private  void processSlash()
           
private  void processSpace()
           
private  void processStar()
           
private  void processUnderlineMinus()
           
private  void processUnexpected()
           
private  void pushExtensionToken(BasicHeaderToken token)
           
private  void pushToken(BasicHeaderToken token)
           
private  void recordProblem(HeaderProblemKind parseProblem, int startOffset, int endOffset, java.lang.String... inserts)
          Record a problem with lexing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tokenStream

private HeaderTokenStream tokenStream

tokenStart

private int tokenStart

tokenStartedWithLetter

private boolean tokenStartedWithLetter

data

char[] data

state

private int state

datapos

private int datapos

datalen

private int datalen

extensionStart

private BasicHeaderToken extensionStart

lastEmittedToken

private BasicHeaderToken lastEmittedToken

foundSpace

private boolean foundSpace

allowsPathToken

private boolean allowsPathToken

UNKNOWN

private static final int UNKNOWN
See Also:
Constant Field Values

DIGITS

private static final int DIGITS
See Also:
Constant Field Values

ALPHABETIC

private static final int ALPHABETIC
See Also:
Constant Field Values

ALPHANUMERIC

private static final int ALPHANUMERIC
See Also:
Constant Field Values

TOKEN

private static final int TOKEN
See Also:
Constant Field Values

IDENTIFIER

private static final int IDENTIFIER
See Also:
Constant Field Values

QUOTEDSTRING

private static final int QUOTEDSTRING
See Also:
Constant Field Values

PATHELEMENT

private static final int PATHELEMENT
See Also:
Constant Field Values

stateToTokenMap

private static final HeaderTokenKind[] stateToTokenMap

tokenExtension

private static final boolean[] tokenExtension

lookup

private static final byte[] lookup

IS_DIGIT

private static final byte IS_DIGIT
See Also:
Constant Field Values

IS_ALPHA

private static final byte IS_ALPHA
See Also:
Constant Field Values

IS_UNDERLINE_OR_MINUS

private static final byte IS_UNDERLINE_OR_MINUS
See Also:
Constant Field Values

IS_ALPHANUM

private static final byte IS_ALPHANUM
See Also:
Constant Field Values

IS_TOKEN

private static final byte IS_TOKEN
See Also:
Constant Field Values
Constructor Detail

StandardHeaderLexer

public StandardHeaderLexer()

StandardHeaderLexer

public StandardHeaderLexer(boolean allowsPathToken)
Method Detail

getTokenStream

public HeaderTokenStream getTokenStream()

initializeLexer

private void initializeLexer(java.lang.String header)

process

public void process(java.lang.String header)
Start in the UNKNOWN state where anything may come next, as characters are encountered and consumed the state will transition amongst other states. It is operating on a maximal munch approach where we eat as much data as we can before being forced into a new state and onto a new token.

Parameters:
header - string

processSpace

private void processSpace()

processDot

private void processDot()

processSlash

private void processSlash()

processStar

private void processStar()

processUnexpected

private void processUnexpected()

pathEnd

private boolean pathEnd(char ch)

processNul

private void processNul()

processDigit

private void processDigit()

processAlphabetic

private void processAlphabetic()

processUnderlineMinus

private void processUnderlineMinus()

processQuote

private void processQuote()

processJavaIdentifierPart

private void processJavaIdentifierPart()

processColon

private void processColon()

processJavaIdentifierStart

private void processJavaIdentifierStart()

isDigit

private boolean isDigit(int ch)

isAlphabetic

private boolean isAlphabetic(int ch)

isAlphanumeric

private boolean isAlphanumeric(int ch)

isUnderlineMinus

private boolean isUnderlineMinus(int ch)

isToken

private boolean isToken(int ch)

emitToken

private void emitToken(HeaderTokenKind kind,
                       int pos)

emitToken2

private void emitToken2(HeaderTokenKind kind,
                        int pos)

emitDotStar

private void emitDotStar(int pos)

emitColonEquals

private void emitColonEquals(int pos)

emitToken

private void emitToken(int tokenEnd)

pushExtensionToken

private void pushExtensionToken(BasicHeaderToken token)

pushToken

private void pushToken(BasicHeaderToken token)

recordProblem

private void recordProblem(HeaderProblemKind parseProblem,
                           int startOffset,
                           int endOffset,
                           java.lang.String... inserts)
Record a problem with lexing.

Parameters:
parseProblem - the kind of problem that occurred
startOffset - the start offset of the problem
endOffset - the end offset of the problem
inserts - the inserts for the problem message text