public class XmlParserSession extends ReaderParserSession
XmlParser.
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 |
XmlParserSession(XmlParser ctx,
ParserSessionArgs args)
Create a new session using properties specified in the context.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
decodeString(String s)
Decodes and trims the specified string.
|
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)
Returns the text content of the current XML element.
|
protected XMLEventAllocator |
getEventAllocator()
Configuration property: XML event allocator.
|
protected XMLReporter |
getReporter()
Configuration property: XML reporter.
|
protected XMLResolver |
getResolver()
Configuration property: XML resolver.
|
protected XmlReader |
getXmlReader(ParserPipe pipe)
Wrap the specified reader in a STAX reader based on settings in this context.
|
protected boolean |
isPreserveRootElement()
Configuration property: Preserve root element during generalized parsing.
|
protected boolean |
isValidating()
Configuration property: Enable validation.
|
protected boolean |
isWhitespaceElement(XmlReader r)
Returns
|
protected <T> T |
parseAnything(ClassMeta<T> eType,
String currAttr,
XmlReader r,
Object outer,
boolean isRoot,
BeanPropertyMeta pMeta)
Workhorse method.
|
protected String |
parseText(XmlReader r)
Parses the current element as text.
|
protected String |
parseWhitespaceElement(XmlReader r)
Parses the current whitespace element.
|
ObjectMap |
toMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
createPipe, getFileCharset, getStreamCharset, isReaderParsercast, convertAttrToType, getClassMeta, getDebugOutputLines, getInputAsString, getJavaMethod, getLastLocation, getListener, getListener, getListenerClass, getOuter, getPosition, isAutoCloseStreams, isStrict, isTrimStrings, isUnbuffered, mark, onUnknownProperty, parse, parse, parse, parse, parse, parse, parseArgs, parseIntoCollection, parseIntoMap, setCurrentClass, setCurrentProperty, setName, setParent, setPipe, trim, trim, unmark, unswap_class, checkForWarnings, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionaryClasses, getBeanFieldVisibility, getBeanFilters, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getBpi, getBpro, getBpwo, getBpx, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getExamples, getImplClasses, getLocale, getMediaType, getNotBeanClasses, getNotBeanPackagesNames, getNotBeanPackagesPrefixes, getPojoSwaps, getPropertyNamer, getSchema, getStringBuilder, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isDebug, isFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnorePropertiesWithoutSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, object, returnStringBuilder, string, toArray, toBeanMap, toBeanMapaddToCache, addToCache, addWarning, getClassProperty, getFromCache, getInstanceArrayProperty, getInstanceProperty, getLogger, getProperties, getProperty, getProperty, getProperty, getPropertyKeys, getWarnings, hasProperty, hasWarnings, toStringprotected XmlParserSession(XmlParser 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 final XmlReader getXmlReader(ParserPipe pipe) throws IOException, XMLStreamException
pipe - The parser input.IOException - Thrown by underlying stream.XMLStreamException - Unexpected XML processing error.protected final String decodeString(String s)
Any
s - The string to be decoded.protected String getElementText(XmlReader r) throws XMLStreamException, IOException, ParseException
Any
Leading and trailing whitespace (unencoded) will be trimmed from the result.
r - The reader to read the element text from.XMLStreamException - Thrown by underlying reader.IOException - Thrown by underlying stream.ParseException - Malformed input encountered.protected String parseText(XmlReader r) throws IOException, XMLStreamException, ParseException
r - The input reader.XMLStreamException - Thrown by underlying reader.IOException - Thrown by underlying stream.ParseException - Malformed input encountered.protected boolean isWhitespaceElement(XmlReader r)
For the XML parser, this always returns
r - The XML stream reader to read the current event from.protected String parseWhitespaceElement(XmlReader r) throws IOException, XMLStreamException, ParseException
For the XML parser, this always returns
r - The XML stream reader to read the current event from.XMLStreamException - Thrown by underlying reader.IOException - Thrown by underlying stream.ParseException - Malformed input encountered.protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws IOException, ParseException, ExecutableException
ParserSessionSubclasses are expected to implement this method.
doParse in class ParserSessionT - 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 IOException - Thrown by underlying stream.ParseException - Malformed input encountered.ExecutableException - Exception occurred on invoked constructor/method/field.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 ParserSessionpipe - 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 ParserSessionpipe - 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 <T> T parseAnything(ClassMeta<T> eType, String currAttr, XmlReader r, Object outer, boolean isRoot, BeanPropertyMeta pMeta) throws IOException, ParseException, ExecutableException, XMLStreamException
T - The expected type of object.eType - The expected type of object.currAttr - The current bean property name.r - The reader.outer - The outer object.isRoot - If pMeta - The bean property metadata.IOException - Thrown by underlying stream.ParseException - Malformed input encountered.ExecutableException - Exception occurred on invoked constructor/method/field.XMLStreamException - Malformed XML encountered.protected final XMLEventAllocator getEventAllocator()
XMLEventAllocator associated with this parser, or XmlParser.XML_eventAllocatorprotected final boolean isPreserveRootElement()
ObjectMap, the map will contain a single entry whose key
is the root element name.XmlParser.XML_preserveRootElementprotected final XMLReporter getReporter()
XMLReporter associated with this parser, or XmlParser.XML_reporterprotected final XMLResolver getResolver()
XMLResolver associated with this parser, or XmlParser.XML_resolverprotected final boolean isValidating()
XmlParser.XML_validatingpublic ObjectMap toMap()
SessiontoMap in class ReaderParserSessionCopyright © 2016–2019 The Apache Software Foundation. All rights reserved.