com.globalphasing.startools
Class StarToken

java.lang.Object
  extended by com.globalphasing.startools.StarToken

public class StarToken
extends Object

Class representing a token from a STAR file. Normally, this class is not instantiated directly, but instances are returned by successive invocations of the StarTokeniser.nextToken() method.

Author:
Peter Keller

Method Summary
 int getLineNumberEnd()
          Ending line number of the match operation that produced this token.
 int getLineNumberStart()
          Starting line number of the match operation that produced this token.
 int getMatchEnd()
          Character offset from the start of the line returned by getLineNumberStart() that corresponds to the character immediately after the last one of the match that produced this token.
 int getMatchStart()
          Character offset from the start of the line returned by getLineNumberStart() that corresponds to the first character of the match that produced this token.
 int getType()
          Getter for token's numeric type.
 String getTypeString()
          Getter for token's type as a descriptive string.
 String getValue()
          Getter for token's value as a string.
 boolean starOnly()
          Return true if token is a valid STAR token, but not allowed in CIF's or mmCIF's.
 String toString()
          Returns a human-readable summary of the token's contents.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getType

public int getType()
Getter for token's numeric type.

Returns:
Numeric type of token, as defined by one of the constants in StarTokenTypes

getTypeString

public String getTypeString()
Getter for token's type as a descriptive string.

Returns:
Descriptive name of token's type (the name of one of the constants in StarTokenTypes with the initial TOKEN_ removed).

getValue

public String getValue()
Getter for token's value as a string.

Returns:
Token's value. Any enclosing quotes/semi-colons will have been removed.

starOnly

public boolean starOnly()
Return true if token is a valid STAR token, but not allowed in CIF's or mmCIF's.

Returns:
Whether or not token is only valid in a STAR context.

getLineNumberStart

public int getLineNumberStart()
Starting line number of the match operation that produced this token. This is not necessarily the line number where the token is located. When the token was produced from character data (by using StarTokeniser.startMatching(CharSequence)) or by matching the entire file contents in a single operation (by using StarTokeniser.startMatching(java.io.File, boolean)), the match operation will always have started at the beginning of the data. Accordingly, this method will return a value of 1.

Returns:
Starting line number of match operation.

getLineNumberEnd

public int getLineNumberEnd()
Ending line number of the match operation that produced this token. When the token was produced by tokenising a file in line-oriented mode (i.e. by invoking StarTokeniser.startMatching(java.io.File) or StarTokeniser.startMatching(java.io.File, int) this method returns the line number of the last line of the data that was being matched when this token was produced. When the token was produced from character data (by using StarTokeniser.startMatching(CharSequence)) or by matching the entire file contents in a single operation (by using StarTokeniser.startMatching(java.io.File, boolean)), this method returns StarTokenTypes.EOF

Returns:
Ending line number of match operation or StarTokenTypes.EOF

getMatchStart

public int getMatchStart()
Character offset from the start of the line returned by getLineNumberStart() that corresponds to the first character of the match that produced this token. Note that this value may not be meaningful when processing very large files using StarTokeniser.startMatching(java.io.File, boolean)

Returns:
character offset of start of match

getMatchEnd

public int getMatchEnd()
Character offset from the start of the line returned by getLineNumberStart() that corresponds to the character immediately after the last one of the match that produced this token. Note that this value may not be meaningful when processing very large files using StarTokeniser.startMatching(java.io.File, boolean)

Returns:
character offset of end of match

toString

public String toString()
Returns a human-readable summary of the token's contents.

Overrides:
toString in class Object


Copyright and Licence