edu.harvard.hul.ois.mets.helper.parser
Class Parser

java.lang.Object
  extended byedu.harvard.hul.ois.mets.helper.parser.Parser

public class Parser
extends java.lang.Object

XML non-validating pull parser.

The parser does not preserve all white space in an instance document; round-tripping may not be possible. Except for the contents of attribute values, none of the whitespace within tag bodies (i.e., between the '<' and '>') is reported back to the invoking system. Also, the use of quotation marks (") or apostrophes (') to demarcate attribute values is not reported back to the invoking system.

References to productions in the XML grammar are bracketed, e.g. "[3]", and are defined in Extensible Markup Language (XML) 1.0 (Second Edition), W3C Recommendation 6 October 2000 <http://www.w3.org/TR/2000/REC-xml-20001006>.

Unicode character values are defined in The Unicode Standard, Version 3.0 (Reading, MA: Addison-Wesley, 2000) <http://www.unicode.org/unicode/uni2book/u2.html>.


Constructor Summary
Parser()
          Instantiate a Parser object.
 
Method Summary
 Token getToken()
          Consume current token.
 Token getToken(boolean debug)
          Consume current token.
 Token peekAtToken()
          Return current token.
 Token peekAtToken(boolean debug)
          Return current token.
 void setInput(java.io.File file)
          Set the input file.
 void setInput(java.io.InputStream in)
          Set the input stream.
 void setInput(java.io.Reader reader)
          Set the input reader.
 void setInput(java.lang.String name)
          Set the input file name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

public Parser()
Instantiate a Parser object.

Method Detail

getToken

public Token getToken()
               throws ParserException
Consume current token. Note: This method is consumming; it can be invoked for a given token once. If no more tokens are present in the document, the method returns null;

Returns:
Current token or null
Throws:
ParserException

getToken

public Token getToken(boolean debug)
               throws ParserException
Consume current token. Note: This method is consumming; it can be invoked for a given token once. If no more tokens are present in the document, the method returns null;

Returns:
Current token or null
Throws:
ParserException

peekAtToken

public Token peekAtToken()
                  throws ParserException
Return current token. Note: This method is non-consumming; repeated invocations will return the same type for the same current token. If no more tokens are present in the document, the method returns null.

Returns:
Current token or null
Throws:
ParserException

peekAtToken

public Token peekAtToken(boolean debug)
                  throws ParserException
Return current token. Note: This method is non-consumming; repeated invocations will return the same type for the same current token. If no more tokens are present in the document, the method returns null.

Returns:
Current token or null
Throws:
ParserException

setInput

public void setInput(java.io.File file)
              throws ParserException
Set the input file.

Parameters:
file - Input file
Throws:
ParserException - I/O exception

setInput

public void setInput(java.io.InputStream in)
              throws ParserException
Set the input stream.

Parameters:
in - Open input stream
Throws:
ParserException - I/O exception

setInput

public void setInput(java.io.Reader reader)
              throws ParserException
Set the input reader.

Parameters:
reader - Open reader
Throws:
ParserException - I/O exception

setInput

public void setInput(java.lang.String name)
              throws ParserException
Set the input file name.

Parameters:
name - File name
Throws:
ParserException - I/O exception