net.jini.config
Class ConfigurationFile.Parser

java.lang.Object
  extended by net.jini.config.ConfigurationFile.Parser
Enclosing class:
ConfigurationFile

private class ConfigurationFile.Parser
extends Object

Parses the input from the specified Reader and options, storing information about imports and entries by side effect.


Field Summary
private  StreamTokenizer st
          The tokenizer to use for parsing
 
Constructor Summary
ConfigurationFile.Parser(Reader reader, String[] options)
          Adds the imports and entries parsed from the specified input stream, as well as overrides parsed from the specified options, starting with the second element.
 
Method Summary
private  void createTokenizer(Reader reader)
          Creates and sets the tokenizer using the specified reader.
private  String describeCurrentToken()
          Returns a String that describes the current token.
private  ConfigurationFile.Literal getNumber(String val)
          Parses a numeric literal and returns the value as a Literal.
private  void oops(String what)
          Throws a ConfigurationException for an error described by the what argument.
private  ConfigurationFile.ParseNode[] parseArgs(ConfigurationFile.Entry inEntry, char close)
          Parses an ExprList and the trailing token specified by close.
private  void parseComponent(String component)
          Parses a Component.
private  void parseEntry(String component, String name)
          Parses an Entry.
(package private)  ConfigurationFile.ParseNode parseExpr(ConfigurationFile.Entry inEntry)
          Parses a string concatenation
private  void parseImport()
          Parses an Import, updating classImports and onDemandImports.
private  ConfigurationFile.MethodCall parseMethodCall(ConfigurationFile.Entry inEntry, String name)
          Resolves a static method call and returns a MethodCall instance that describes the method and arguments for the call.
private  ConfigurationFile.ParseNode parseNewInstance(ConfigurationFile.Entry inEntry)
          Parses a NewExpr except for the leading "new", and returns the constructed object.
private  void parseOverride()
          Parses an Override .
private  void parseSource()
          Parses imports and components from the source, and stores the results.
(package private)  ConfigurationFile.ParseNode parseSubExpr(ConfigurationFile.Entry inEntry)
          Parses an Expr.
private  void syntax(String what)
          Throws a ConfigurationException for a syntax error described by the what argument.
private  void token(char c)
          Parses the next token from the stream, and generates a syntax error if the token does not equal the specified character.
private  String token(String what)
          Parses the next token from the stream, and generates a syntax error if the token is not a TT_WORD.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

st

private StreamTokenizer st
The tokenizer to use for parsing

Constructor Detail

ConfigurationFile.Parser

ConfigurationFile.Parser(Reader reader,
                         String[] options)
                   throws ConfigurationException
Adds the imports and entries parsed from the specified input stream, as well as overrides parsed from the specified options, starting with the second element.

Throws:
ConfigurationException
Method Detail

createTokenizer

private void createTokenizer(Reader reader)
Creates and sets the tokenizer using the specified reader.


parseSource

private void parseSource()
                  throws ConfigurationException,
                         IOException
Parses imports and components from the source, and stores the results.

Throws:
ConfigurationException
IOException

parseImport

private void parseImport()
                  throws ConfigurationException,
                         IOException
Parses an Import, updating classImports and onDemandImports.

Throws:
ConfigurationException
IOException

parseComponent

private void parseComponent(String component)
                     throws ConfigurationException,
                            IOException
Parses a Component.

Throws:
ConfigurationException
IOException

parseEntry

private void parseEntry(String component,
                        String name)
                 throws ConfigurationException,
                        IOException
Parses an Entry.

Throws:
ConfigurationException
IOException

parseOverride

private void parseOverride()
                    throws ConfigurationException,
                           IOException
Parses an Override .

Throws:
ConfigurationException
IOException

parseArgs

private ConfigurationFile.ParseNode[] parseArgs(ConfigurationFile.Entry inEntry,
                                                char close)
                                         throws ConfigurationException,
                                                IOException
Parses an ExprList and the trailing token specified by close.

Throws:
ConfigurationException
IOException

parseExpr

ConfigurationFile.ParseNode parseExpr(ConfigurationFile.Entry inEntry)
                                throws ConfigurationException,
                                       IOException
Parses a string concatenation

Throws:
ConfigurationException
IOException

parseSubExpr

ConfigurationFile.ParseNode parseSubExpr(ConfigurationFile.Entry inEntry)
                                   throws ConfigurationException,
                                          IOException
Parses an Expr.

Throws:
ConfigurationException
IOException

getNumber

private ConfigurationFile.Literal getNumber(String val)
                                     throws ConfigurationException,
                                            IOException
Parses a numeric literal and returns the value as a Literal.

Throws:
ConfigurationException
IOException

parseNewInstance

private ConfigurationFile.ParseNode parseNewInstance(ConfigurationFile.Entry inEntry)
                                              throws ConfigurationException,
                                                     IOException
Parses a NewExpr except for the leading "new", and returns the constructed object.

Throws:
ConfigurationException
IOException

parseMethodCall

private ConfigurationFile.MethodCall parseMethodCall(ConfigurationFile.Entry inEntry,
                                                     String name)
                                              throws ConfigurationException,
                                                     IOException
Resolves a static method call and returns a MethodCall instance that describes the method and arguments for the call.

Throws:
ConfigurationException
IOException

token

private void token(char c)
            throws ConfigurationException,
                   IOException
Parses the next token from the stream, and generates a syntax error if the token does not equal the specified character. Expands references to system properties if the token is a String.

Throws:
ConfigurationException
IOException

token

private String token(String what)
              throws ConfigurationException,
                     IOException
Parses the next token from the stream, and generates a syntax error if the token is not a TT_WORD. The what argument describes what kind of token is expected. Combines multiple TT_WORD tokens if they are separated by '.' at the boundaries and are not reserved words.

Throws:
ConfigurationException
IOException

syntax

private void syntax(String what)
             throws ConfigurationException
Throws a ConfigurationException for a syntax error described by the what argument.

Throws:
ConfigurationException

describeCurrentToken

private String describeCurrentToken()
Returns a String that describes the current token.


oops

private void oops(String what)
           throws ConfigurationException
Throws a ConfigurationException for an error described by the what argument.

Throws:
ConfigurationException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.