asd
Class ASDGrammarReader

java.lang.Object
  extended by asd.ASDGrammarReader

public class ASDGrammarReader
extends java.lang.Object

Instances can create an ASDGrammar from a character file.

Author:
James A. Mason

Constructor Summary
ASDGrammarReader(java.lang.String fileName)
          Initializes a new ASDGrammarReader on a given file or URL.
ASDGrammarReader(java.lang.String fileName, boolean includeCoords)
          Initializes a new ASDGrammarReader on a given file or URL.
 
Method Summary
 void close()
          Closes the InputStream used by the ASDGrammarReader, if the InputStream was opened from a URL.
 java.util.HashMap<java.lang.String,java.util.ArrayList<ASDGrammarNode>> getGrammar()
          Gets an ASD grammar from the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ASDGrammarReader

public ASDGrammarReader(java.lang.String fileName)
                 throws java.io.IOException,
                        java.net.MalformedURLException
Initializes a new ASDGrammarReader on a given file or URL. Throws an IOException or malformedURLException if the file or URL can't be opened. By default, pixel coordinates of grammar nodes are NOT loaded.

Parameters:
fileName - the name of the file or URL
Throws:
java.io.IOException
java.net.MalformedURLException

ASDGrammarReader

public ASDGrammarReader(java.lang.String fileName,
                        boolean includeCoords)
                 throws java.io.IOException,
                        java.net.MalformedURLException
Initializes a new ASDGrammarReader on a given file or URL. Throws an IOException or malformedURLException if the file or URL can't be opened.

Parameters:
fileName - the name of the file or URL
includeCoords - indicates whether or not to include pixel coordinates in the grammar loaded, if they are present. They are needed by the graphical grammar editor but not by the parser.
Throws:
java.io.IOException
java.net.MalformedURLException
Method Detail

close

public void close()
           throws java.io.IOException
Closes the InputStream used by the ASDGrammarReader, if the InputStream was opened from a URL.

Throws:
java.io.IOException

getGrammar

public java.util.HashMap<java.lang.String,java.util.ArrayList<ASDGrammarNode>> getGrammar()
                                                                                   throws java.io.IOException,
                                                                                          ASDInputException
Gets an ASD grammar from the file. Throws an ASDInputException if the grammar representation in the file is ill-formed.

Returns:
a HashMap of words and ArrayLists of ASDGrammarNodes that represent their instances.
Throws:
java.io.IOException
ASDInputException