net.sf.jga.parser
Class GenericParser

java.lang.Object
  extended by net.sf.jga.parser.FunctorParser
      extended by net.sf.jga.parser.GenericParser
All Implemented Interfaces:
FunctorParserConstants

public class GenericParser
extends FunctorParser

FunctorParser that add runtime type-safe entry points (to the degree that runtime type-safe is not an oxymoron). This class maps between the inherently typeunsafe baseclass and the generic functors that are returned: if the returned functor does not return the correct type, then a ClassCastException will be thrown by the entry point.

Copyright © 2004 David A. Hall

Author:
David A. Hall

Field Summary
 
Fields inherited from class net.sf.jga.parser.FunctorParser
ARG_NAME, jj_nt, lookingAhead, token, token_source
 
Fields inherited from interface net.sf.jga.parser.FunctorParserConstants
CHARACTER_LITERAL, DECIMAL_LITERAL, DEFAULT, DIGIT, EOF, EXPONENT, FALSE, FLOATING_POINT_LITERAL, HEX_LITERAL, IDENTIFIER, INTEGER_LITERAL, LETTER, LPAREN, NEW, NULL, OCTAL_LITERAL, STRING_LITERAL, tokenImage, TRUE
 
Constructor Summary
GenericParser()
           
GenericParser(FunctorParserTokenManager tm)
           
GenericParser(java.io.InputStream is)
           
GenericParser(java.io.Reader reader)
           
 
Method Summary
static GenericParser getInstance()
           
<T1,T2,R> BinaryFunctor<T1,T2,R>
parseBinary(java.lang.String str, java.lang.Class<T1> arg1Type, java.lang.Class<T2> arg2Type, java.lang.Class<R> returnType)
          Parses the string to create a BinaryFunctor that takes arguments of the given types.
<R> Generator<R>
parseGenerator(java.lang.String str, java.lang.Class<R> returnType)
          Parses the string to create a Generator.
<T,R> UnaryFunctor<T,R>
parseUnary(java.lang.String str, java.lang.Class<T> argType, java.lang.Class<T> returnType)
          Parses the string to create a UnaryFunctor that takes an argument of the given type.
 
Some of the Methods inherited from class net.sf.jga.parser.FunctorParser
checkReservedNames, getReturnType, parseBinary, parseBinary, parseGenerator, parseGenerator, parseUnary, parseUnary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericParser

public GenericParser()

GenericParser

public GenericParser(java.io.InputStream is)

GenericParser

public GenericParser(java.io.Reader reader)

GenericParser

public GenericParser(FunctorParserTokenManager tm)
Method Detail

getInstance

public static GenericParser getInstance()

parseGenerator

public <R> Generator<R> parseGenerator(java.lang.String str,
                                       java.lang.Class<R> returnType)
                            throws java.lang.ClassCastException,
                                   
Parses the string to create a Generator.

Throws:
java.lang.ClassCastException
ParseException

parseUnary

public <T,R> UnaryFunctor<T,R> parseUnary(java.lang.String str,
                                          java.lang.Class<T> argType,
                                          java.lang.Class<T> returnType)
                             throws java.lang.ClassCastException,
                                    ParseException
Parses the string to create a UnaryFunctor that takes an argument of the given type.

Throws:
java.lang.ClassCastException
ParseException

parseBinary

public <T1,T2,R> BinaryFunctor<T1,T2,R> parseBinary(java.lang.String str,
                                                    java.lang.Class<T1> arg1Type,
                                                    java.lang.Class<T2> arg2Type,
                                                    java.lang.Class<R> returnType)
                                   throws java.lang.ClassCastException,
                                          ParseException
Parses the string to create a BinaryFunctor that takes arguments of the given types.

Throws:
java.lang.ClassCastException
ParseException


Copyright © 2002-2004 David A. Hall. All Rights Reserved.