com.metamatrix.query.processor.xml
Class SAXDocumentInProgress

java.lang.Object
  extended by com.metamatrix.query.processor.xml.SAXDocumentInProgress
All Implemented Interfaces:
DocumentInProgress

public class SAXDocumentInProgress
extends java.lang.Object
implements DocumentInProgress

This class is used to build XML document and stream the output as chunks. The class holds one chunk of the document in memory at one time.


Constructor Summary
SAXDocumentInProgress()
           
 
Method Summary
 boolean addAttribute(NodeDescriptor descriptor, java.lang.String attributeValue)
          Add an attribute with content for the given NodeDescriptor.
 boolean addAttribute(NodeDescriptor descriptor, java.lang.String attributeValue, com.metamatrix.query.processor.xml.Element element)
           
 boolean addComment(java.lang.String commentText)
          Adds a comment to the current document node
 boolean addElement(NodeDescriptor descriptor, NodeDescriptor nillableDescriptor)
          Add an element for the given NodeDescriptor.
 boolean addElement(NodeDescriptor descriptor, java.lang.String content)
          Add an element with content for the given NodeDescriptor.
 char[] getNextChunk(int sizeInBytes)
          Retrieve the next chunk of document.
 boolean isFinished()
          This flag indicates the document is finished and requires no more processing.
 void markAsFinished()
          This marks the document as finished, requiring no more processing.
 boolean moveToLastChild()
           
 boolean moveToParent()
          Move to the parent of this element.
static java.lang.String normalizeText(java.lang.String content, java.lang.String textNormalizationMode)
           
 void setDocumentEncoding(java.lang.String documentEncoding)
          Sets the document encoding property of the XML document, typically something like UTF-8
 void setDocumentFormat(boolean isFormatted)
          Sets whether the document will be formatted in human-readable form (multi-line, with tabs) or compact form (no line breaks or tabs).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXDocumentInProgress

public SAXDocumentInProgress()
                      throws MetaMatrixComponentException
Throws:
MetaMatrixComponentException
Method Detail

setDocumentEncoding

public void setDocumentEncoding(java.lang.String documentEncoding)
Description copied from interface: DocumentInProgress
Sets the document encoding property of the XML document, typically something like UTF-8

Specified by:
setDocumentEncoding in interface DocumentInProgress
See Also:
DocumentInProgress.setDocumentEncoding(java.lang.String)

setDocumentFormat

public void setDocumentFormat(boolean isFormatted)
Description copied from interface: DocumentInProgress
Sets whether the document will be formatted in human-readable form (multi-line, with tabs) or compact form (no line breaks or tabs).

Specified by:
setDocumentFormat in interface DocumentInProgress
Parameters:
isFormatted - true for human-readable form, false for compact form
See Also:
DocumentInProgress.setDocumentFormat(boolean)

moveToParent

public boolean moveToParent()
                     throws org.xml.sax.SAXException
Move to the parent of this element. The parent of this element becomes the current object. Need to process the current and child object before moving to the parent.

Specified by:
moveToParent in interface DocumentInProgress
Throws:
org.xml.sax.SAXException
See Also:
DocumentInProgress.moveToParent()

moveToLastChild

public boolean moveToLastChild()
Specified by:
moveToLastChild in interface DocumentInProgress
See Also:
DocumentInProgress.moveToLastChild()

addElement

public boolean addElement(NodeDescriptor descriptor,
                          NodeDescriptor nillableDescriptor)
Description copied from interface: DocumentInProgress
Add an element for the given NodeDescriptor.

Specified by:
addElement in interface DocumentInProgress
Parameters:
descriptor - NodeDescriptor of the element
Returns:
whether operation was a success or not

addElement

public boolean addElement(NodeDescriptor descriptor,
                          java.lang.String content)
Description copied from interface: DocumentInProgress
Add an element with content for the given NodeDescriptor. If the content is either a null or an empty String, use the other addElement method.

Specified by:
addElement in interface DocumentInProgress
Parameters:
descriptor - NodeDescriptor of the element
content - Content of the element
Returns:
whether operation was a success or not

addAttribute

public boolean addAttribute(NodeDescriptor descriptor,
                            java.lang.String attributeValue,
                            com.metamatrix.query.processor.xml.Element element)

addAttribute

public boolean addAttribute(NodeDescriptor descriptor,
                            java.lang.String attributeValue)
Description copied from interface: DocumentInProgress
Add an attribute with content for the given NodeDescriptor.

Specified by:
addAttribute in interface DocumentInProgress
Parameters:
descriptor - NodeDescriptor of the attribute
attributeValue - String content of the attribute, this must be a non-null, non-empty String. Otherwise, no attribute will be added.
Returns:
whether operation was a success or not
See Also:
com.metamatrix.query.processor.xml.DocumentInProgress#addAttribute(java.lang.String, java.lang.String, java.lang.String, boolean)

addComment

public boolean addComment(java.lang.String commentText)
Description copied from interface: DocumentInProgress
Adds a comment to the current document node

Specified by:
addComment in interface DocumentInProgress
Parameters:
commentText - text of the comment
Returns:
whether operation was a success or not
Throws:
MetaMatrixComponentException
See Also:
DocumentInProgress.addComment(java.lang.String)

isFinished

public boolean isFinished()
Description copied from interface: DocumentInProgress
This flag indicates the document is finished and requires no more processing.

Specified by:
isFinished in interface DocumentInProgress
See Also:
DocumentInProgress.isFinished()

markAsFinished

public void markAsFinished()
                    throws MetaMatrixComponentException
Description copied from interface: DocumentInProgress
This marks the document as finished, requiring no more processing. (It will not, however, prevent any more processing from being done.)

Specified by:
markAsFinished in interface DocumentInProgress
Throws:
MetaMatrixComponentException - if there is any problem ending the document
See Also:
DocumentInProgress.markAsFinished()

getNextChunk

public char[] getNextChunk(int sizeInBytes)
Description copied from interface: DocumentInProgress
Retrieve the next chunk of document.

Specified by:
getNextChunk in interface DocumentInProgress
Parameters:
sizeInBytes - size of the chunk in bytes. No limit if it is 0.
Returns:
character array containing the specfied number of characters, or less if it has reached the end of the document. Return null if there is not enough characters and it has not reached the end of the document.
See Also:
DocumentInProgress.getNextChunk(int)

normalizeText

public static java.lang.String normalizeText(java.lang.String content,
                                             java.lang.String textNormalizationMode)
Parameters:
content -
textNormalizationMode - preserve No normalization is done, the value is not changed for element content replace All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage return) are replaced with #x20 (space) collapse After the processing implied by replace, contiguous sequences of #x20's are collapsed to a single #x20, and leading and trailing #x20's are removed.
Returns:
Since:
4.3


Copyright © 2009. All Rights Reserved.