public class ContentHandlerImpl extends java.lang.Object implements ContentHandler
| Modifier and Type | Class and Description |
|---|---|
static class |
ContentHandlerImpl.Describer
An implementation of a describer that delegates to a
ContentHandler. |
ContentHandler.ByteOrderMark, ContentHandler.Registry, ContentHandler.ValidityBYTE_ORDER_MARK_PROPERTY, CHARSET_PROPERTY, CONTENT_TYPE_PROPERTY, INVALID_CONTENT_DESCRIPTION, LINE_DELIMITER_PROPERTY, OPTION_REQUESTED_PROPERTIES, UNSPECIFIED_CONTENT_TYPE, VALIDITY_PROPERTY| Constructor and Description |
|---|
ContentHandlerImpl()
Creates an instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canHandle(URI uri)
This implementations always return true; clients are generally expected to override this.
|
java.util.Map<java.lang.String,java.lang.Object> |
contentDescription(URI uri,
java.io.InputStream inputStream,
java.util.Map<?,?> options,
java.util.Map<java.lang.Object,java.lang.Object> context)
This base implementation handles computing the
ContentHandler.BYTE_ORDER_MARK_PROPERTY,
the character set property,
and the line delimiter property. |
static java.util.Map<java.lang.String,java.lang.Object> |
createContentDescription(ContentHandler.Validity validity)
Creates a map with a single entry from
ContentHandler.VALIDITY_PROPERTY to the given validity value. |
protected ContentHandler.ByteOrderMark |
getByteOrderMark(URI uri,
java.io.InputStream inputStream,
java.util.Map<?,?> options,
java.util.Map<java.lang.Object,java.lang.Object> context)
Returns the byte order marker at the start of the input stream.
|
protected java.lang.String |
getCharset(URI uri,
java.io.InputStream inputStream,
java.util.Map<?,?> options,
java.util.Map<java.lang.Object,java.lang.Object> context)
Returns the character set of the input stream; this implementation simply returns null.
|
static java.lang.String |
getLineDelimiter(java.io.InputStream inputStream,
java.lang.String charset)
Returns the line delimiter of the input stream interpreted using the specified character set.
|
protected java.lang.String |
getLineDelimiter(URI uri,
java.io.InputStream inputStream,
java.util.Map<?,?> options,
java.util.Map<java.lang.Object,java.lang.Object> context)
Returns the line delimiter of the input stream; it's computed from the bytes interpreted using the
appropriate character set. |
protected java.util.Set<java.lang.String> |
getRequestedProperties(java.util.Map<?,?> options)
Returns the value of
ContentHandler.OPTION_REQUESTED_PROPERTIES in the options map. |
protected boolean |
isRequestedProperty(java.lang.String property,
java.util.Map<?,?> options)
Returns whether the named property is one requested in the options.
|
public static java.util.Map<java.lang.String,java.lang.Object> createContentDescription(ContentHandler.Validity validity)
ContentHandler.VALIDITY_PROPERTY to the given validity value.validity - the value of the validity property.ContentHandler.VALIDITY_PROPERTY to the given validity value.protected java.util.Set<java.lang.String> getRequestedProperties(java.util.Map<?,?> options)
ContentHandler.OPTION_REQUESTED_PROPERTIES in the options map.options - the options in which to look up the property.ContentHandler.OPTION_REQUESTED_PROPERTIES in the options map.protected boolean isRequestedProperty(java.lang.String property,
java.util.Map<?,?> options)
property - the property in question.options - the options in which to look for the requested property.getRequestedProperties(Map)public boolean canHandle(URI uri)
canHandle in interface ContentHandleruri - the URI in questions.public java.util.Map<java.lang.String,java.lang.Object> contentDescription(URI uri,
java.io.InputStream inputStream,
java.util.Map<?,?> options,
java.util.Map<java.lang.Object,java.lang.Object> context)
throws java.io.IOException
ContentHandler.BYTE_ORDER_MARK_PROPERTY,
the character set property,
and the line delimiter property.
for each such requested property.contentDescription in interface ContentHandleruri - the URI for which to determine the content description.inputStream - the input stream associated with the given URI.options - a map of options to direct what kind of description is needed.context - a map of contextual information that content handlers use to store partially computed results.java.io.IOException - if there is a problem reading the stream.protected java.lang.String getCharset(URI uri,
java.io.InputStream inputStream,
java.util.Map<?,?> options,
java.util.Map<java.lang.Object,java.lang.Object> context)
throws java.io.IOException
uri - the URI of the input stream.inputStream - the input stream.options - any options that might influence the interpretation of the content.context - a cache for previously computed information.java.io.IOException - if there is a problem loading the content.protected java.lang.String getLineDelimiter(URI uri,
java.io.InputStream inputStream,
java.util.Map<?,?> options,
java.util.Map<java.lang.Object,java.lang.Object> context)
throws java.io.IOException
appropriate character set.uri - the URI of the input stream.inputStream - the input stream.options - any options that might influence the interpretation of the content.context - a cache for previously computed information.java.io.IOException - if there is a problem loading the content.public static java.lang.String getLineDelimiter(java.io.InputStream inputStream,
java.lang.String charset)
throws java.io.IOException
java.io.IOExceptionprotected ContentHandler.ByteOrderMark getByteOrderMark(URI uri, java.io.InputStream inputStream, java.util.Map<?,?> options, java.util.Map<java.lang.Object,java.lang.Object> context) throws java.io.IOException
uri - the URI of the input stream.inputStream - the input stream to scan.options - any options to influence the behavior; this base implementation ignores this.context - the cache for fetching and storing a previous computation of the byte order marker; this base implementation caches ContentHandler.BYTE_ORDER_MARK_PROPERTY.java.io.IOExceptionCopyright © 2018. Licensed under the Eclipse Public License v1.0. All rights reserved.
Submit a bug or feature