Stellent
HowToComponents
JavaDoc

intradoc.common
Class ParseOutput

java.lang.Object
  |
  +--intradoc.common.ParseOutput

public class ParseOutput
extends java.lang.Object

Holds current state of parsing. This class is used to optimize the parsing of a stream by doing its own buffering and buffer management.


Field Summary
 boolean m_failOnDecodeError
          Set to true to cause an IOException to be thrown when a Unicode replacement character shows up.
 boolean m_hasTracedUnicodeReplacementCharacter
          This is set by parser to note that it has already complained.
 boolean m_hasUnicodeReplacementCharacter
          This is set to true by intradoc.common.Parser so it only complains once per file.
 boolean m_isEOF
          Set to true if EOF is reached while reading in characters.
 boolean m_isXmlLiteralEscape
          Turn to true if the escaping mechanism in literal strings uses the XML/HTML &XXX; approach.
 ParseLocationInfo m_markParseInfo
          Start parse location of block currently being parsed.
 boolean m_noLiteralStrings
          Turn to true if parsing should not respect rules for enclosing literal strings.
 int m_numPending
          Number of characters waiting in pending output buffer waiting to be written.
 int m_numRead
          Indicates how many bytes have been read in from the reader.
 int m_numWaiting
          Indicates the number of characters temporarily being held in the output buffer that need to be written to the output writer.
 char[] m_outputBuf
          Temporary buffer that holds data before it is sent to the pending buffer, from which it is sent to the output writer.
 ParseLocationInfo m_parseInfo
          Parse location, used for tracking so that more information can be reported about errors.
 char[] m_pendingBuf
          Buffer holding data pending write to output writer.
 int m_readOffset
          Offset into read buffer where processing has started.
 boolean m_stopWriting
          Temporarily suspend the output
 boolean m_traceOnDecodeError
          Set to true to cause a tracing message to be created when a Unicode replacement character shows up.
 java.io.Writer m_writer
          Output is written to.
static int MAX_ALREADY_READ
          Maximum read.
static int MAX_PENDING
          Pending maximum.
static int OUTPUT_BUF_SIZE
          Size of output buffer.
 
Constructor Summary
ParseOutput()
           
ParseOutput(ParseLocationInfo parseInfo)
           
 
Method Summary
 void clearPending()
          Clears out any data that might be written to the output buffer.
 void copyToPending(boolean writeToOutput, boolean excludeLast)
          Copies over all the characters waiting to be sent to the output writer.
 void createMarkedParsingException(java.lang.String msg)
          Similar to 'createParsingException(...)' except that it uses the saved location.
 void createParsingException(java.lang.String msg)
          Creates an exception that reports a message and location at which error occurred.
protected  void initAttributes()
           
 boolean isBufferEqualNoCase(char[] buf, int len)
          Method provides optimized comparison of byte buffer against a given string up to 'len' number of characters.
 void markParseLocation()
          Used to save parse location for later reporting.
 int removeNextChar()
          Gets the next byte that is not waiting and removes it.
 void reset()
           
 void updateParseLocation(char ch)
          Used to update Parse Location for a single character.
 void updateParseLocation(char[] buf, int offset, int numchars)
          Used to update Parse Location.
 java.lang.String waitingBufferAsString()
          Returns parsed tag between open and close tag elements.
 java.lang.String waitingBufferAsStringSuffix(int offset)
          Returns parsed tag between open and close tag elements, but offsets from beginning of tag.
 void writePending()
          Commits any remaining pending.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_isXmlLiteralEscape

public boolean m_isXmlLiteralEscape
Turn to true if the escaping mechanism in literal strings uses the XML/HTML &XXX; approach. The default is the C/Javascript/Java escaping mechanism which uses the \ character to escape special characters. In a truly complex file, this boolean may shift back and forth (for example in an HTML file when inside the context of a javascript area, the escape character temporarily uses the C coding style).


m_noLiteralStrings

public boolean m_noLiteralStrings
Turn to true if parsing should not respect rules for enclosing literal strings.


m_writer

public java.io.Writer m_writer
Output is written to. If NULL, then no output is generated.


m_outputBuf

public char[] m_outputBuf
Temporary buffer that holds data before it is sent to the pending buffer, from which it is sent to the output writer. This attribute allows the user of this class to substitute found tokens with data into the output writer.


m_pendingBuf

public char[] m_pendingBuf
Buffer holding data pending write to output writer.


m_readOffset

public int m_readOffset
Offset into read buffer where processing has started.


m_numPending

public int m_numPending
Number of characters waiting in pending output buffer waiting to be written.


m_numWaiting

public int m_numWaiting
Indicates the number of characters temporarily being held in the output buffer that need to be written to the output writer.


m_numRead

public int m_numRead
Indicates how many bytes have been read in from the reader. If this attribute is greater than m_numWaiting, than there are some bytes yet to be parsed.


m_parseInfo

public ParseLocationInfo m_parseInfo
Parse location, used for tracking so that more information can be reported about errors.


m_markParseInfo

public ParseLocationInfo m_markParseInfo
Start parse location of block currently being parsed.


m_isEOF

public boolean m_isEOF
Set to true if EOF is reached while reading in characters.


m_stopWriting

public boolean m_stopWriting
Temporarily suspend the output


m_hasUnicodeReplacementCharacter

public boolean m_hasUnicodeReplacementCharacter
This is set to true by intradoc.common.Parser so it only complains once per file.


m_hasTracedUnicodeReplacementCharacter

public boolean m_hasTracedUnicodeReplacementCharacter
This is set by parser to note that it has already complained.


m_traceOnDecodeError

public boolean m_traceOnDecodeError
Set to true to cause a tracing message to be created when a Unicode replacement character shows up.


m_failOnDecodeError

public boolean m_failOnDecodeError
Set to true to cause an IOException to be thrown when a Unicode replacement character shows up.


OUTPUT_BUF_SIZE

public static final int OUTPUT_BUF_SIZE
Size of output buffer. Used to derive other buffer manipulation lengths.

See Also:
Constant Field Values

MAX_PENDING

public static final int MAX_PENDING
Pending maximum. If number pending is greater than this than copy pending to output buffer.

See Also:
Constant Field Values

MAX_ALREADY_READ

public static final int MAX_ALREADY_READ
Maximum read. Maximum number already previously read and parsed accumulating in pending buffer before contents of pending buffer need to be shuffled to the left to promote content not yet fully parsed.

See Also:
Constant Field Values
Constructor Detail

ParseOutput

public ParseOutput()

ParseOutput

public ParseOutput(ParseLocationInfo parseInfo)
Method Detail

initAttributes

protected void initAttributes()

reset

public void reset()

copyToPending

public void copyToPending(boolean writeToOutput,
                          boolean excludeLast)
                   throws java.io.IOException
Copies over all the characters waiting to be sent to the output writer.

java.io.IOException

writePending

public void writePending()
                  throws java.io.IOException
Commits any remaining pending.

java.io.IOException

clearPending

public void clearPending()
Clears out any data that might be written to the output buffer.


removeNextChar

public int removeNextChar()
Gets the next byte that is not waiting and removes it. Returns -1 if there is not byte to retrieve.


waitingBufferAsString

public java.lang.String waitingBufferAsString()
Returns parsed tag between open and close tag elements.


waitingBufferAsStringSuffix

public java.lang.String waitingBufferAsStringSuffix(int offset)
Returns parsed tag between open and close tag elements, but offsets from beginning of tag.


isBufferEqualNoCase

public boolean isBufferEqualNoCase(char[] buf,
                                   int len)
Method provides optimized comparison of byte buffer against a given string up to 'len' number of characters.


updateParseLocation

public void updateParseLocation(char[] buf,
                                int offset,
                                int numchars)
Used to update Parse Location.


updateParseLocation

public void updateParseLocation(char ch)
Used to update Parse Location for a single character.


markParseLocation

public void markParseLocation()
Used to save parse location for later reporting.


createParsingException

public void createParsingException(java.lang.String msg)
                            throws ParseSyntaxException
Creates an exception that reports a message and location at which error occurred.

ParseSyntaxException

createMarkedParsingException

public void createMarkedParsingException(java.lang.String msg)
                                  throws ParseSyntaxException
Similar to 'createParsingException(...)' except that it uses the saved location.

ParseSyntaxException


(c) 1996-2005  All rights reserved.  Stellent, Inc.