edu.neu.ccs.parser
Class ParserUtilities

java.lang.Object
  extended byedu.neu.ccs.parser.ParserUtilities

public class ParserUtilities
extends Object

Provides access to the current default parser and static utility methods for use with parser operations.

As of 2.5.0, requires the default parser to be a parser derived from class BaseParser rather than simply to be a parser that implements Parser. This guarantees that certain parser functionality is available.

This class contains only static data and methods and may not be instantiated.

Version:
2.5
See Also:
BaseParser, JPTParser

Field Summary
private static BaseParser parser
          Default parser used by JPT classes.
 
Constructor Summary
private ParserUtilities()
          Prevent instantiation.
 
Method Summary
static BaseParser getDefaultParser()
          Returns the default parser used by JPT classes.
static boolean isXBoolean(Object x)
          Return true if x is XBoolean.
static boolean isXFloating(Object x)
          Return true if x is floating, that is, if x is one of the types: XBigDecimal, XDouble, XFloat.
static boolean isXIntegral(Object x)
          Return true if x is integral, that is, if x is one of the types: XBigInteger, XLong, XInt, XShort, XByte.
static boolean isXNumber(Object x)
          Return true if x is an XNumber.
static void setDefaultParser(BaseParser p)
          Sets the default parser used by JPT classes to the given parser.
static XBigDecimal toXBigDecimal(XNumber value)
          Converts the given value to XBigDecimal.
static XBigInteger toXBigInteger(XNumber value)
          Converts the given value to XBigInteger.
static XDouble toXDouble(XNumber value)
          Converts the given value to XDouble.
static XLong toXLong(XNumber value)
          Converts the given value to XLong.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

private static BaseParser parser
Default parser used by JPT classes.

Constructor Detail

ParserUtilities

private ParserUtilities()
Prevent instantiation.

Method Detail

getDefaultParser

public static BaseParser getDefaultParser()
Returns the default parser used by JPT classes.


setDefaultParser

public static void setDefaultParser(BaseParser p)

Sets the default parser used by JPT classes to the given parser.

If null, the default parser is set to a new standard default parser for JPT, that is, a new JPTParser.

Parameters:
p - the desired default parser

isXNumber

public static boolean isXNumber(Object x)
Return true if x is an XNumber.


isXIntegral

public static boolean isXIntegral(Object x)
Return true if x is integral, that is, if x is one of the types: XBigInteger, XLong, XInt, XShort, XByte.


isXFloating

public static boolean isXFloating(Object x)
Return true if x is floating, that is, if x is one of the types: XBigDecimal, XDouble, XFloat.


isXBoolean

public static boolean isXBoolean(Object x)
Return true if x is XBoolean.


toXLong

public static XLong toXLong(XNumber value)
Converts the given value to XLong.

Parameters:
value - the value to be converted

toXDouble

public static XDouble toXDouble(XNumber value)
Converts the given value to XDouble.

Parameters:
value - the value to be converted

toXBigInteger

public static XBigInteger toXBigInteger(XNumber value)
Converts the given value to XBigInteger.

Parameters:
value - the value to be converted

toXBigDecimal

public static XBigDecimal toXBigDecimal(XNumber value)
Converts the given value to XBigDecimal.

Parameters:
value - the value to be converted