Package com.sun.xml.rpc.sp
Class Parser
java.lang.Object
com.sun.xml.rpc.sp.Parser
This implements a fast non-validating top down parser. This one always
processes external parsed entities, strictly adheres to the XML 1.0
specification, and provides useful diagnostics. It supports an optimization
allowing faster processing of valid standalone XML documents. For
multi-language applications (such as web servers using XML processing
to create dynamic content), a method supports choosing a locale for
parser diagnostics which is both understood by the message recipient
and supported by the parser.
- Author:
- David Brownell, Zhenghua Li, JAX-RPC RI Development Team
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new non-coalescing parser with the specified input file.Create a new parser with the specified input file.Parser(InputStream in) Create a new non-coalescing parser with the specified input stream.Parser(InputStream in, boolean coalescing, boolean namespaceAware) Create a new parser with the specified input stream and the coalescing property. -
Method Summary
Modifier and TypeMethodDescriptionchooseLocale(String[] languages) Chooses a client locale to use for diagnostics, using the first language specified in the list that is supported by this parser.intReturns the object used to resolve entitiesintReturns the diagnostic locale.booleanReturns true if standalone documents skip processing of all external DTD information.intparse()Parse and return the next parsing state.voidLets applications control entity resolution.voidsetFastStandalone(boolean value) Setting this flag enables faster processing of valid standalone documents: external DTD information is not processed, and no attribute normalization or defaulting is done.voidUsed by applications to request locale for diagnostics.
-
Constructor Details
-
Parser
Create a new parser with the specified input stream and the coalescing property.- Parameters:
in- the input stream.coalescing- the parser will coalesce character data if, and only if, this parameter is truenamespaceAware- the parser will support namespaces if, and only if, this parameter is true
-
Parser
Create a new non-coalescing parser with the specified input stream.- Parameters:
in- the input stream.
-
Parser
Create a new parser with the specified input file. and the coalescing property.- Parameters:
file- the input file.coalescing- the parser will coalesce character data if, and only if, this parameter is truenamespaceAware- the parser will support namespaces if, and only if, this parameter is true- Throws:
IOException
-
Parser
Create a new non-coalescing parser with the specified input file.- Parameters:
file- the input file.- Throws:
IOException
-
-
Method Details
-
setLocale
Used by applications to request locale for diagnostics.- Parameters:
l- The locale to use, or null to use system defaults (which may include only message IDs).- Throws:
ParseException- If no diagnostic messages are available in that locale.
-
getLocale
Returns the diagnostic locale. -
getCurName
-
getCurURI
-
getCurValue
-
getLineNumber
public int getLineNumber() -
getColumnNumber
public int getColumnNumber() -
getPublicId
-
getSystemId
-
chooseLocale
Chooses a client locale to use for diagnostics, using the first language specified in the list that is supported by this parser. That locale is then set using setLocale(). Such a list could be provided by a variety of user preference mechanisms, including the HTTP Accept-Language header field.- Parameters:
languages- Array of language specifiers, ordered with the most preferable one at the front. For example, "en-ca" then "fr-ca", followed by "zh_CN". Both RFC 1766 and Java styles are supported.- Returns:
- The chosen locale, or null.
- Throws:
ParseException- See Also:
-
setEntityResolver
Lets applications control entity resolution. -
getEntityResolver
Returns the object used to resolve entities -
setFastStandalone
public void setFastStandalone(boolean value) Setting this flag enables faster processing of valid standalone documents: external DTD information is not processed, and no attribute normalization or defaulting is done. This optimization is only permitted in non-validating parsers; for validating parsers, this mode is silently disabled.For documents which are declared as standalone, but which are not valid, a fatal error may be reported for references to externally defined entities. That could happen in any nonvalidating parser which did not read externally defined entities. Also, if any attribute values need normalization or defaulting, it will not be done.
-
isFastStandalone
public boolean isFastStandalone()Returns true if standalone documents skip processing of all external DTD information. -
parse
Parse and return the next parsing state. This is the entry point for higher level parsers like the StreamingParser.- Throws:
ParseExceptionIOException
-