org.jomc.util
Class VersionParser

Package class diagram package VersionParser
java.lang.Object
  extended by org.jomc.util.VersionParser
All Implemented Interfaces:
VersionParserConstants

public final class VersionParser
extends Object
implements VersionParserConstants

Parses and compares version identifiers.

 Version    ::= Token ( ( <SEPARATOR> )* Token )* <EOF>
 Token      ::= <INTEGER>
              | <IDENTIFIER>
 

A separator character is defined as

 [".","_","-","@","/","\\"," ","\t","\n","\r","\f","\b","\"","\'"]
An integer is a sequence of digits. An identifier is everything else, not a separator character or an integer.

Version:
$Id: VersionParser.jj 573 2009-09-25 16:05:05Z schulte2005 $
Author:
Christian Schulte
See Also:
compare(String, String)

Field Summary
private  List jj_expentries
           
private  int[] jj_expentry
           
private  int jj_gen
           
(package private)  SimpleCharStream jj_input_stream
           
private  int jj_kind
           
private  int[] jj_la1
           
private static int[] jj_la1_0
           
 Token jj_nt
          Next token.
private  int jj_ntk
           
 Token token
          Current token.
 VersionParserTokenManager token_source
          Generated Token Manager.
 
Fields inherited from interface org.jomc.util.VersionParserConstants
DEFAULT, EOF, IDENTIFIER, INTEGER, SEPARATOR, tokenImage
 
Constructor Summary
VersionParser(InputStream stream)
          Constructor with InputStream.
VersionParser(InputStream stream, String encoding)
          Constructor with InputStream and supplied encoding
VersionParser(Reader stream)
          Constructor.
VersionParser(VersionParserTokenManager tm)
          Constructor with generated Token Manager.
 
Method Summary
static int compare(String v1, String v2)
          Compares two versions for order.
 void disable_tracing()
          Disable tracing.
 void enable_tracing()
          Enable tracing.
 ParseException generateParseException()
          Generate ParseException.
private static String getMessage(String key)
           
 Token getNextToken()
          Get the next Token.
 Token getToken(int index)
          Get the specific Token.
private  Token jj_consume_token(int kind)
           
private static void jj_la1_init_0()
           
private  int jj_ntk()
           
 Token[] parse()
          Parses the input to produce an array of tokens.
 void ReInit(InputStream stream)
          Reinitialise.
 void ReInit(InputStream stream, String encoding)
          Reinitialise.
 void ReInit(Reader stream)
          Reinitialise.
 void ReInit(VersionParserTokenManager tm)
          Reinitialise.
private  void Token(List tokens)
           
private  Token[] Version()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public VersionParserTokenManager token_source
Generated Token Manager.


jj_input_stream

SimpleCharStream jj_input_stream

token

public Token token
Current token.


jj_nt

public Token jj_nt
Next token.


jj_ntk

private int jj_ntk

jj_gen

private int jj_gen

jj_la1

private final int[] jj_la1

jj_la1_0

private static int[] jj_la1_0

jj_expentries

private List jj_expentries

jj_expentry

private int[] jj_expentry

jj_kind

private int jj_kind
Constructor Detail

VersionParser

public VersionParser(InputStream stream)
Constructor with InputStream.


VersionParser

public VersionParser(InputStream stream,
                     String encoding)
Constructor with InputStream and supplied encoding


VersionParser

public VersionParser(Reader stream)
Constructor.


VersionParser

public VersionParser(VersionParserTokenManager tm)
Constructor with generated Token Manager.

Method Detail

parse

public Token[] parse()
              throws ParseException,
                     TokenMgrError
Parses the input to produce an array of tokens.

Returns:
The parsed tokens.
Throws:
ParseException - if the parse fails.
TokenMgrError - for any invalid tokens.

compare

public static int compare(String v1,
                          String v2)
                   throws ParseException,
                          TokenMgrError
Compares two versions for order.

This method parses the given strings to produce a sequence of tokens and then compares these tokens for order.

Parameters:
v1 - The version to compare with.
v2 - The version to compare to.
Returns:
A negative integer, zero, or a positive integer as the first version is less than, equal to, or greater than the second.
Throws:
NullPointerException - if v1 or v2 is null.
ParseException - if parsing fails.
TokenMgrError - for any invalid tokens.

getMessage

private static String getMessage(String key)

Version

private final Token[] Version()
                       throws ParseException
Throws:
ParseException

Token

private final void Token(List tokens)
                  throws ParseException
Throws:
ParseException

jj_la1_init_0

private static void jj_la1_init_0()

ReInit

public void ReInit(InputStream stream)
Reinitialise.


ReInit

public void ReInit(InputStream stream,
                   String encoding)
Reinitialise.


ReInit

public void ReInit(Reader stream)
Reinitialise.


ReInit

public void ReInit(VersionParserTokenManager tm)
Reinitialise.


jj_consume_token

private Token jj_consume_token(int kind)
                        throws ParseException
Throws:
ParseException

getNextToken

public final Token getNextToken()
Get the next Token.


getToken

public final Token getToken(int index)
Get the specific Token.


jj_ntk

private int jj_ntk()

generateParseException

public ParseException generateParseException()
Generate ParseException.


enable_tracing

public final void enable_tracing()
Enable tracing.


disable_tracing

public final void disable_tracing()
Disable tracing.



Copyright © 2005-2009 The JOMC Project. All Rights Reserved.