public final class HtmlParserSession extends XmlParserSession
HtmlParser
.
This class is NOT thread safe. It is typically discarded after one-time use although it can be reused against multiple inputs.
Modifier | Constructor and Description |
---|---|
protected |
HtmlParserSession(HtmlParser ctx,
ParserSessionArgs args)
Create a new session using properties specified in the context.
|
Modifier and Type | Method and Description |
---|---|
protected <T> T |
doParse(ParserPipe pipe,
ClassMeta<T> type)
Workhorse method.
|
protected <E> Collection<E> |
doParseIntoCollection(ParserPipe pipe,
Collection<E> c,
Type elementType)
Implementation method.
|
protected <K,V> Map<K,V> |
doParseIntoMap(ParserPipe pipe,
Map<K,V> m,
Type keyType,
Type valueType)
Implementation method.
|
protected String |
getElementText(XmlReader r)
Identical to
parseText(XmlReader) except assumes the current event is the opening tag. |
protected boolean |
isWhitespaceElement(XmlReader r)
Returns
|
protected String |
parseText(XmlReader r)
Parses CHARACTERS data.
|
protected String |
parseWhitespaceElement(XmlReader r)
Parses the current whitespace element.
|
asMap, decodeString, getEventAllocator, getReporter, getResolver, getXmlReader, isPreserveRootElement, isValidating, parseAnything
createPipe, getFileCharset, getInputStreamCharset, isReaderParser
cast, convertAttrToType, getClassMeta, getDebugOutputLines, getInputAsString, getJavaMethod, getLastLocation, getListener, getListener, getListenerClass, getOuter, getPosition, isAutoCloseStreams, isStrict, isTrimStrings, isUnbuffered, mark, onUnknownProperty, parse, parse, parse, parseArgs, parseIntoCollection, parseIntoMap, setCurrentClass, setCurrentProperty, setName, setParent, setPipe, trim, trim, unmark
_class, checkForWarnings, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionaryClasses, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassMeta, getClassMeta, getClassMetaForObject, getLocale, getMediaType, getPropertyNamer, getSchema, getStringBuilder, getTimeZone, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isDebug, isFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnorePropertiesWithoutSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, newInstance, newInstance, newInstanceFromOuter, object, returnStringBuilder, string, toArray, toBeanMap, toBeanMap
addToCache, addToCache, addWarning, getClassProperty, getFromCache, getInstanceArrayProperty, getInstanceProperty, getLogger, getProperties, getProperty, getProperty, getProperty, getPropertyKeys, getWarnings, hasProperty, hasWarnings, toString
protected HtmlParserSession(HtmlParser ctx, ParserSessionArgs args)
ctx
- The context creating this session object.
The context contains all the configuration settings for this object.args
- Runtime session arguments.protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception
ParserSession
Subclasses are expected to implement this method.
doParse
in class XmlParserSession
T
- The class type of the object to create.pipe
- Where to get the input from.type
- The class type of the object to create.
If Object.class
, object type is based on what's being parsed.
For example, when parsing JSON text, it may return a String
, Number
,
ObjectMap
, etc...Exception
- If thrown from underlying stream, or if the input contains a syntax error or is malformed.protected <K,V> Map<K,V> doParseIntoMap(ParserPipe pipe, Map<K,V> m, Type keyType, Type valueType) throws Exception
ParserSession
Default implementation throws an UnsupportedOperationException
.
doParseIntoMap
in class XmlParserSession
pipe
- The parser input.m
- The map being loaded.keyType
- The class type of the keys, or String.class
.valueType
- The class type of the values, or Exception
- If thrown from underlying stream, or if the input contains a syntax error or is malformed.protected <E> Collection<E> doParseIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) throws Exception
ParserSession
Default implementation throws an UnsupportedOperationException
.
doParseIntoCollection
in class XmlParserSession
pipe
- The parser input.c
- The collection being loaded.elementType
- The class type of the elements, or Exception
- If thrown from underlying stream, or if the input contains a syntax error or is malformed.protected final String parseText(XmlReader r) throws Exception
Precondition: Pointing to event immediately following opening tag. Postcondition: Pointing to closing tag.
parseText
in class XmlParserSession
r
- The stream being read from.XMLStreamException
Exception
protected final String getElementText(XmlReader r) throws Exception
parseText(XmlReader)
except assumes the current event is the opening tag.
Precondition: Pointing to opening tag. Postcondition: Pointing to closing tag.
getElementText
in class XmlParserSession
r
- The stream being read from.XMLStreamException
Exception
protected final boolean isWhitespaceElement(XmlReader r)
XmlParserSession
For the XML parser, this always returns
isWhitespaceElement
in class XmlParserSession
r
- The XML stream reader to read the current event from.protected final String parseWhitespaceElement(XmlReader r) throws Exception
XmlParserSession
For the XML parser, this always returns
parseWhitespaceElement
in class XmlParserSession
r
- The XML stream reader to read the current event from.XMLStreamException
Exception
Copyright © 2018 Apache. All rights reserved.