com.springsource.util.parser.manifest
Class RecoveringManifestParser

java.lang.Object
  extended by com.springsource.util.parser.manifest.RecoveringManifestParser
All Implemented Interfaces:
ManifestParser

public class RecoveringManifestParser
extends java.lang.Object
implements ManifestParser

Builds upon the ManifestLexer that breaks a bunch of text data into a series of tokens

Concurrent Semantics
This class is thread safe.

Author:
Andy Clement

Field Summary
private static java.lang.String NAME_HEADER
           
(package private)  TokenStream tokenStream
           
(package private)  ManifestVisitor visitor
           
 
Constructor Summary
RecoveringManifestParser()
           
RecoveringManifestParser(ManifestVisitor visitor)
           
 
Method Summary
private  void checkForRogueNewlinesProceedingInput()
           
private  void confirmEnd()
           
 void eatAttribute(boolean isMain)
           
 void eatColon()
           
 boolean eatNameAttribute()
          Expects to eat "Name" ":" ""
 void eatNewline()
           
 boolean eatSection(boolean isMain)
          Eat a section from the input data.
 void eatVersionInfo()
           
 void eatVersionNumber()
           
 boolean foundProblems()
           
 ManifestContents getManifestContents()
           
 java.util.List<ManifestProblem> getProblems()
           
private  boolean maybeEatHeaderName(java.lang.String expectedName)
          Consume a specific Name token from the token stream, report an error if it is the wrong kind or the wrong name.
private  boolean maybeEatNewline()
           
 ManifestContents parse(java.io.Reader reader)
          Parse a manifest from the supplied reader.
 ManifestContents parse(java.lang.String manifestString)
          Parse an input string of data as a manifest.
(package private)  ManifestContents parseManifest()
           
private  void recordProblem(ManifestProblemKind parseProblem, int startOffset, int endOffset, java.lang.String... inserts)
          Record a problem with parsing.
 void setTerminateAfterMainSection(boolean shouldTerminate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_HEADER

private static final java.lang.String NAME_HEADER
See Also:
Constant Field Values

visitor

ManifestVisitor visitor

tokenStream

TokenStream tokenStream
Constructor Detail

RecoveringManifestParser

public RecoveringManifestParser()

RecoveringManifestParser

public RecoveringManifestParser(ManifestVisitor visitor)
Method Detail

parse

public ManifestContents parse(java.lang.String manifestString)
Description copied from interface: ManifestParser
Parse an input string of data as a manifest.

Specified by:
parse in interface ManifestParser
Returns:
manifest contents

parse

public ManifestContents parse(java.io.Reader reader)
                       throws java.io.IOException
Description copied from interface: ManifestParser
Parse a manifest from the supplied reader.

Specified by:
parse in interface ManifestParser
Returns:
ManifestContents
Throws:
java.io.IOException - if there is a problem with the Reader

parseManifest

ManifestContents parseManifest()

getManifestContents

public ManifestContents getManifestContents()

confirmEnd

private void confirmEnd()

checkForRogueNewlinesProceedingInput

private void checkForRogueNewlinesProceedingInput()

eatNewline

public void eatNewline()

eatSection

public boolean eatSection(boolean isMain)
Eat a section from the input data. The boolean indicates if it is expected to be the main section. The main section starts with the version and then some number of attributes, whilst the other sections should start with a name and then attributes.

Parameters:
isMain - is this expected to be the main section?
Returns:
continue?

eatVersionInfo

public void eatVersionInfo()

maybeEatHeaderName

private boolean maybeEatHeaderName(java.lang.String expectedName)
Consume a specific Name token from the token stream, report an error if it is the wrong kind or the wrong name.

Parameters:
expectedName -
Returns:

eatColon

public void eatColon()

eatAttribute

public void eatAttribute(boolean isMain)

eatVersionNumber

public void eatVersionNumber()

maybeEatNewline

private boolean maybeEatNewline()
Returns:
true if able to consume a Newline token from the tokenstream

eatNameAttribute

public boolean eatNameAttribute()
Expects to eat "Name" ":" ""

Returns:
continue?

foundProblems

public boolean foundProblems()
Specified by:
foundProblems in interface ManifestParser
Returns:
true if problems were found during parsing

getProblems

public java.util.List<ManifestProblem> getProblems()
Specified by:
getProblems in interface ManifestParser
Returns:
the list of problems that occurred during parsing

recordProblem

private void recordProblem(ManifestProblemKind parseProblem,
                           int startOffset,
                           int endOffset,
                           java.lang.String... inserts)
Record a problem with parsing.

Parameters:
parseProblem - the kind of problem that occurred
startOffset - the start offset of the problem
endOffset - the end offset of the problem
inserts - the inserts for the problem message text

setTerminateAfterMainSection

public void setTerminateAfterMainSection(boolean shouldTerminate)
Specified by:
setTerminateAfterMainSection in interface ManifestParser