XML for Java Compatibility API 2.0.11

com.ibm.xml.parser
Class Stderr

java.lang.Object
  |
  +--com.ibm.xml.parser.Stderr

public class Stderr
extends java.lang.Object
implements ErrorListener, StreamProducer

Stderr provides the XML4J parser's default implementations of the ErrorListener and StreamProducer interfaces.

Version:
Revision: 88 1.6 src/com/ibm/xml/parser/Stderr.java, parser, xml4j2, xml4j2_0_11
See Also:
ErrorListener, StreamProducer

Field Summary
protected  java.util.Hashtable catalog
           
protected  boolean isPrintWarning
           
protected  java.lang.String name
           
static java.io.PrintWriter printer
           
protected  java.lang.String publicId
          Public id of last call to getInputStream().
protected  java.util.Stack stack
           
protected  java.lang.String systemId
          System id of last call to getInputStream().
protected  java.net.URL url
           
 
Constructor Summary
Stderr(java.lang.String name)
          Constructor.
 
Method Summary
 void closeInputStream(Source source)
          Removes the input stream currently in use.
 int error(java.lang.String file, int lineNo, int charOffset, java.lang.Object key, java.lang.String msg)
          Listen for XML4J parser errors, and reports these errors through the standard error stream (System.err).
static java.net.URL file2URL(java.lang.String file)
          Returns a file-protocol URL constructed from a context of the specified file and the JVM's system property "user.dir".
 Source getInputStream(java.lang.String name, java.lang.String publicID, java.lang.String systemID)
          Returns the source of the input stream (could be a character stream or a byte stream) based on this constructor's name parameter and the URL specification given by systemID and publicID.
 java.lang.String getPublicId()
          Returns the current public id.
 java.lang.String getSystemId()
          Returns the current system id.
 void loadCatalog(java.io.Reader reader)
          Loads a catalog which provides mapping between public IDs to system IDs or URNs to URLs.
 void setPrintWarning(boolean isPrintWarning)
          Sets whether prints warnings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

printer

public static java.io.PrintWriter printer

name

protected java.lang.String name

url

protected java.net.URL url

stack

protected java.util.Stack stack

catalog

protected java.util.Hashtable catalog

isPrintWarning

protected boolean isPrintWarning

publicId

protected java.lang.String publicId
Public id of last call to getInputStream().

systemId

protected java.lang.String systemId
System id of last call to getInputStream().
Constructor Detail

Stderr

public Stderr(java.lang.String name)
Constructor. This class supports only URL that java.net.URL can handles.
Parameters:
name - URL or filespec to use as the default input stream; if a filespec is provided, this value can include a drive and directory spec. This value is also used to associate a name with errors reported to the default error listener (i.e. error() method) that have a file parameter =null.
See Also:
error(java.lang.String, int, int, java.lang.Object, java.lang.String)
Method Detail

setPrintWarning

public void setPrintWarning(boolean isPrintWarning)
Sets whether prints warnings.

By default, prints warnings.

Parameters:
isPrintWarning - =true means prints warnings; =false means prints no warnings.

file2URL

public static java.net.URL file2URL(java.lang.String file)
                             throws java.net.MalformedURLException
Returns a file-protocol URL constructed from a context of the specified file and the JVM's system property "user.dir".
Parameters:
file - The file to use in constructing the URL; this value can include a drive and directory spec.
Throws:
java.net.MalformedURLException - Thrown if unable to construct a URL based on the specified file.

error

public int error(java.lang.String file,
                 int lineNo,
                 int charOffset,
                 java.lang.Object key,
                 java.lang.String msg)

Listen for XML4J parser errors, and reports these errors through the standard error stream (System.err).

This method is defined by ErrorListener.

Specified by:
error in interface ErrorListener
Parameters:
file - Processing file, or null if this constructor's name parameter is to be used.
lineNo - The line number where the current document event ends, or -1 if not available. Note that this is the line position of the first character after the text associated with the document event. Do NOT trust this value when the input stream includes invalid octet as its encoding.
charOffset - The column number where the current document event ends, or -1 if not available. Note that this is the column number of the first character after the text associated with the document event. The first column in a line is position 1. Do NOT trust this value when the input stream includes invalid octet as its encoding.
key - The object may be an instance of String or Exception. When this object is String, this value may help classify msg as an error (begins with "E_") or warning (begins with "W_") or a validation error (begins with "V_").
msg - The error or warning message.
See Also:
ErrorListener

getInputStream

public Source getInputStream(java.lang.String name,
                             java.lang.String publicID,
                             java.lang.String systemID)
                      throws java.io.IOException

Returns the source of the input stream (could be a character stream or a byte stream) based on this constructor's name parameter and the URL specification given by systemID and publicID.

This method is defined by StreamProducer.

Specified by:
getInputStream in interface StreamProducer
Parameters:
name - CURRENTLY NOT IMPLEMENTED.
publicID - Entity's public ID which is to be used in preference to systemID, or null if no catalog is available.
systemID - Entity's URI (URL or URN).
Returns:
The resolved source of the input stream, or null if unable to resolve.
Throws:
java.io.IOException - Thrown if unable to open the source defined by the specified IDs.
See Also:
loadCatalog(java.io.Reader), closeInputStream(com.ibm.xml.parser.Source), ExternalID, StreamProducer

closeInputStream

public void closeInputStream(Source source)

Removes the input stream currently in use.

This method is defined by StreamProducer.

Specified by:
closeInputStream in interface StreamProducer
Parameters:
source - CURRENTLY NOT IMPLEMENTED.
See Also:
getInputStream(java.lang.String, java.lang.String, java.lang.String), StreamProducer

loadCatalog

public void loadCatalog(java.io.Reader reader)
                 throws java.io.IOException
Loads a catalog which provides mapping between public IDs to system IDs or URNs to URLs.

This method reads data until it reaches the end of the stream, but it does not close the stream.

Catalog file format:
 public ID<TAB>URI
 public ID<TAB>URI
 URN<TAB>URL
  :
  :
 

Note: Public IDs can not contain #xD or #xA.

Specified by:
loadCatalog in interface StreamProducer
Parameters:
reader - Character input stream reader.
Throws:
java.io.IOException - Thrown if reader is invalid.
See Also:
getInputStream(java.lang.String, java.lang.String, java.lang.String), ExternalID, Parser.loadCatalog(java.io.Reader), StreamProducer.loadCatalog(java.io.Reader)

getPublicId

public java.lang.String getPublicId()
Returns the current public id.

getSystemId

public java.lang.String getSystemId()
Returns the current system id.

XML for Java Compatibility API 2.0.11