org.apache.xerces.readers
Class XMLDeclRecognizer

java.lang.Object
  |
  +--org.apache.xerces.readers.XMLDeclRecognizer

public abstract class XMLDeclRecognizer
extends java.lang.Object

Abstract base class for encoding recognizers. When we encounter an external entity, including the document entity, and do not know what the encoding of the underlying byte stream is, we need to look at the contents of the stream to find out. We do this by asking a set of "recognizers" to look at the stream data and if the recognizer can understand the encoding it will try to read an XML or text declaration, if present, and construct the appropriate reader for that encoding. The recognizer subclasses will typically use the prescanXMLDeclOrTextDecl() method if the stream looks like it does begin with such a declaration using a temporary reader that can support the calls needed to scan through the encoding declaration.


Constructor Summary
XMLDeclRecognizer()
           
 
Method Summary
protected  int prescanXMLDeclOrTextDecl(XMLEntityHandler.EntityReader entityReader, boolean xmlDecl)
          Support for getting the value of an EncodingDecl using an XMLReader.
abstract  XMLEntityHandler.EntityReader recognize(XMLEntityReaderFactory readerFactory, XMLEntityHandler entityHandler, XMLErrorReporter errorReporter, boolean sendCharDataAsCharArray, StringPool stringPool, ChunkyByteArray data, boolean xmlDecl, boolean allowJavaEncodingName)
          Subclasses override this method to support recognizing their encodings.
static void registerDefaultRecognizers(java.util.Stack recognizerStack)
          Register the standard recognizers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLDeclRecognizer

public XMLDeclRecognizer()
Method Detail

registerDefaultRecognizers

public static void registerDefaultRecognizers(java.util.Stack recognizerStack)
Register the standard recognizers.
Parameters:
recognizerStack - The stack of recognizers used by the parser.

recognize

public abstract XMLEntityHandler.EntityReader recognize(XMLEntityReaderFactory readerFactory,
                                                        XMLEntityHandler entityHandler,
                                                        XMLErrorReporter errorReporter,
                                                        boolean sendCharDataAsCharArray,
                                                        StringPool stringPool,
                                                        ChunkyByteArray data,
                                                        boolean xmlDecl,
                                                        boolean allowJavaEncodingName)
                                                 throws java.lang.Exception
Subclasses override this method to support recognizing their encodings.
Parameters:
readerFactory - the factory object to use when constructing the entity reader.
entityHandler - the entity handler to get entity readers from
errorReporter - where to report errors
sendCharDataAsCharArray - true if the reader should use char arrays, not string handles.
stringPool - the StringPool to put strings in
data - initial bytes to perform recognition on
xmlDecl - true if attempting to recognize fron an XMLDecl, false if trying to recognize from a TextDecl.
allowJavaEncodingName - true if Java's encoding names are allowed, false if they are not.
Returns:
The reader that will be used to process the contents of the data stream.
Throws:
java.lang.Exception -  

prescanXMLDeclOrTextDecl

protected int prescanXMLDeclOrTextDecl(XMLEntityHandler.EntityReader entityReader,
                                       boolean xmlDecl)
                                throws java.lang.Exception
Support for getting the value of an EncodingDecl using an XMLReader. This is the minimal logic from the scanner to recognize an XMLDecl or TextDecl using the XMLReader interface.
Parameters:
entityReader - data source for prescan
xmlDecl - true if attempting to recognize from an XMLDecl, false if trying to recognize from a TextDecl.
Returns:
StringPool handle to the name of the encoding recognized
Throws:
java.lang.Exception -  


Copyright 1999-2001 Apache XML Project. All Rights Reserved.