com.tagtraum.perf.xml
Class BSAXEncoder

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--com.tagtraum.perf.xml.BSAXEncoder
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class BSAXEncoder
extends org.xml.sax.helpers.DefaultHandler

Encodes SAX-Events in a binary format.

This class is not threadsafe.

Version:
$Id: $
Author:
Hendrik Schreiber
See Also:
BSAXDecoder

Constructor Summary
BSAXEncoder(java.io.OutputStream out)
          Sets the outputstream and the default blocksize of 8k.
BSAXEncoder(java.io.OutputStream out, int blockSize)
          Sets the outputstream and the blocksize.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endDocument()
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 void endPrefixMapping(java.lang.String prefix)
           
 void fatalError(org.xml.sax.SAXParseException e)
           
 void flushCharacters()
           
 void ignorableWhitespace(char[] ch, int start, int length)
           
 boolean isIgnoreIgnorableWhitespace()
           
static void main(java.lang.String[] args)
          Encodes a given XML file.
 void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
           
 void processingInstruction(java.lang.String target, java.lang.String data)
           
 void setIgnoreIgnorableWhitespace(boolean ignoreIgnorableWhitespace)
          Set this flag to true, if you want to ignore 'ignorable whitespace', i.e.
 void skippedEntity(java.lang.String name)
           
 void startDocument()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
           
 void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, resolveEntity, setDocumentLocator, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BSAXEncoder

public BSAXEncoder(java.io.OutputStream out)
Sets the outputstream and the default blocksize of 8k.


BSAXEncoder

public BSAXEncoder(java.io.OutputStream out,
                   int blockSize)
Sets the outputstream and the blocksize. Blocksize corresponds to the size of the internally used buffer.

Method Detail

isIgnoreIgnorableWhitespace

public boolean isIgnoreIgnorableWhitespace()
See Also:
setIgnoreIgnorableWhitespace(boolean)

setIgnoreIgnorableWhitespace

public void setIgnoreIgnorableWhitespace(boolean ignoreIgnorableWhitespace)
Set this flag to true, if you want to ignore 'ignorable whitespace', i.e. whitespace that appears in element content as defined in XML 1.0 §3.2.1. Setting this flag to true potentially reduces the size of the document dramatically, if you are using a validating parser.

By default this is set to false

See Also:
isIgnoreIgnorableWhitespace()

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

flushCharacters

public void flushCharacters()
                     throws org.xml.sax.SAXException
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Overrides:
processingInstruction in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Overrides:
skippedEntity in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
endPrefixMapping in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

notationDecl

public void notationDecl(java.lang.String name,
                         java.lang.String publicId,
                         java.lang.String systemId)
                  throws org.xml.sax.SAXException
Specified by:
notationDecl in interface org.xml.sax.DTDHandler
Overrides:
notationDecl in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

unparsedEntityDecl

public void unparsedEntityDecl(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId,
                               java.lang.String notationName)
                        throws org.xml.sax.SAXException
Specified by:
unparsedEntityDecl in interface org.xml.sax.DTDHandler
Overrides:
unparsedEntityDecl in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        javax.xml.parsers.ParserConfigurationException,
                        org.xml.sax.SAXException
Encodes a given XML file. The file is validated and the parser for reading the file is aware of namespaces. Ignorable whitespace will be ignored - i.e. is not part of the encoded file.

java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException


Copyright © 2002 Hendrik Schreiber
http://www.tagtraum.com/performance/
This software can be distributed under LGPL