Class XmlParserSession
- Direct Known Subclasses:
- HtmlParserSession
XmlParser.
 Notes:
- This class is not thread safe and is typically discarded after one use.
See Also:
- 
Nested Class SummaryNested Classes
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedXmlParserSession(XmlParserSession.Builder builder) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionstatic XmlParserSession.BuilderCreates a new builder for this object.protected final StringDecodes and trims the specified string.protected <T> TdoParse(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 StringReturns the text content of the current XML element.protected final XMLEventAllocatorXML event allocator.protected final XMLReporterXML reporter.protected final XMLResolverXML resolver.protected XmlBeanMetagetXmlBeanMeta(BeanMeta<?> bm) Returns the language-specific metadata on the specified bean.protected XmlBeanPropertyMetaReturns the language-specific metadata on the specified bean property.protected XmlClassMetagetXmlClassMeta(ClassMeta<?> cm) Returns the language-specific metadata on the specified class.protected final XmlReadergetXmlReader(ParserPipe pipe) Wrap the specified reader in a STAX reader based on settings in this context.protected final booleanPreserve root element during generalized parsing.protected final booleanEnable validation.protected booleanReturnstrue if the current element is a whitespace element.protected <T> TparseAnything(ClassMeta<T> eType, String currAttr, XmlReader r, Object outer, boolean isRoot, BeanPropertyMeta pMeta) Workhorse method.protected StringParses the current element as text.protected StringParses the current whitespace element.Methods inherited from class org.apache.juneau.parser.ReaderParserSessioncreate, createPipe, getFileCharset, getStreamCharset, isReaderParser, propertiesMethods inherited from class org.apache.juneau.parser.ParserSessioncast, convertAttrToType, create, getClassMeta, getDebugOutputLines, getInputAsString, getJavaMethod, getLastLocation, getListener, getListener, getListenerClass, getOuter, getPosition, getSchema, getStringBuilder, isAutoCloseStreams, isStrict, isTrimStrings, isUnbuffered, mark, onBeanSetterException, onUnknownProperty, parse, parse, parse, parse, parse, parse, parseArgs, parseIntoCollection, parseIntoMap, returnStringBuilder, setCurrentClass, setCurrentProperty, setName, setParent, setPipe, trim, trim, unmark, unswapMethods inherited from class org.apache.juneau.BeanSession_class, addWarning, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, create, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionary, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getLocale, getMediaType, getNamePropertyName, getNotBeanClasses, getNotBeanPackagesNames, getNotBeanPackagesPrefixes, getPropertyNamer, getSwaps, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFindFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnoreMissingSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, newGenericMap, object, string, toArray, toBeanMap, toBeanMap, toBeanMapMethods inherited from class org.apache.juneau.ContextSessioncheckForWarnings, getContext, getSessionProperties, getWarnings, isDebug, toString
- 
Constructor Details- 
XmlParserSessionConstructor.- Parameters:
- builder- The builder for this object.
 
 
- 
- 
Method Details- 
createCreates a new builder for this object.- Parameters:
- ctx- The context creating this session.
- Returns:
- A new builder.
 
- 
getXmlReaderWrap the specified reader in a STAX reader based on settings in this context.- Parameters:
- pipe- The parser input.
- Returns:
- The new STAX reader.
- Throws:
- IOException- Thrown by underlying stream.
- XMLStreamException- Unexpected XML processing error.
 
- 
decodeStringDecodes and trims the specified string.Any '_x####_' sequences in the string will be decoded.- Parameters:
- s- The string to be decoded.
- Returns:
- The decoded string.
 
- 
getElementTextReturns the text content of the current XML element.Any '_x####_' sequences in the string will be decoded.Leading and trailing whitespace (unencoded) will be trimmed from the result. - Parameters:
- r- The reader to read the element text from.
- Returns:
- The decoded text.  null if the text consists of the sequence'_x0000_' .
- Throws:
- XMLStreamException- Thrown by underlying reader.
- IOException- Thrown by underlying stream.
- ParseException- Malformed input encountered.
 
- 
parseTextParses the current element as text.- Parameters:
- r- The input reader.
- Returns:
- The parsed text.
- Throws:
- XMLStreamException- Thrown by underlying reader.
- IOException- Thrown by underlying stream.
- ParseException- Malformed input encountered.
 
- 
isWhitespaceElementReturnstrue if the current element is a whitespace element.For the XML parser, this always returns false . However, the HTML parser defines various whitespace elements such as"br" and"sp" .- Parameters:
- r- The XML stream reader to read the current event from.
- Returns:
- true if the current element is a whitespace element.
 
- 
parseWhitespaceElementprotected String parseWhitespaceElement(XmlReader r) throws IOException, XMLStreamException, ParseException Parses the current whitespace element.For the XML parser, this always returns null since there is no concept of a whitespace element. However, the HTML parser defines various whitespace elements such as"br" and"sp" .- Parameters:
- r- The XML stream reader to read the current event from.
- Returns:
- The whitespace character or characters.
- Throws:
- XMLStreamException- Thrown by underlying reader.
- IOException- Thrown by underlying stream.
- ParseException- Malformed input encountered.
 
- 
doParseprotected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws IOException, ParseException, ExecutableException Description copied from class:ParserSessionWorkhorse method.Subclasses are expected to implement this method or Parser.doParse(ParserSession,ParserPipe,ClassMeta).The default implementation of this method simply calls Parser.doParse(ParserSession,ParserPipe,ClassMeta).- Overrides:
- doParsein class- ParserSession
- Type Parameters:
- T- The class type of the object to create.
- Parameters:
- pipe- Where to get the input from.
- type- The class type of the object to create. If- null or- Object., object type is based on what's being parsed. For example, when parsing JSON text, it may return a- class - String ,- Number ,- JsonMap , etc...
- Returns:
- The parsed object.
- Throws:
- IOException- Thrown by underlying stream.
- ParseException- Malformed input encountered.
- ExecutableException- Exception occurred on invoked constructor/method/field.
 
- 
doParseIntoMapprotected <K,V> Map<K,V> doParseIntoMap(ParserPipe pipe, Map<K, V> m, Type keyType, Type valueType) throws ExceptionDescription copied from class:ParserSessionImplementation method.Default implementation throws an UnsupportedOperationException.- Overrides:
- doParseIntoMapin class- ParserSession
- Type Parameters:
- K- The key type.
- V- The value type.
- Parameters:
- pipe- The parser input.
- m- The map being loaded.
- keyType- The class type of the keys, or- null to default to- String..- class 
- valueType- The class type of the values, or- null to default to whatever is being parsed.
- Returns:
- The same map that was passed in to allow this method to be chained.
- Throws:
- Exception- If thrown from underlying stream, or if the input contains a syntax error or is malformed.
 
- 
doParseIntoCollectionprotected <E> Collection<E> doParseIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) throws Exception Description copied from class:ParserSessionImplementation method.Default implementation throws an UnsupportedOperationException.- Overrides:
- doParseIntoCollectionin class- ParserSession
- Type Parameters:
- E- The element type.
- Parameters:
- pipe- The parser input.
- c- The collection being loaded.
- elementType- The class type of the elements, or- null to default to whatever is being parsed.
- Returns:
- The same collection that was passed in to allow this method to be chained.
- Throws:
- Exception- If thrown from underlying stream, or if the input contains a syntax error or is malformed.
 
- 
parseAnythingprotected <T> T parseAnything(ClassMeta<T> eType, String currAttr, XmlReader r, Object outer, boolean isRoot, BeanPropertyMeta pMeta) throws IOException, ParseException, ExecutableException, XMLStreamException Workhorse method.- Type Parameters:
- T- The expected type of object.
- Parameters:
- eType- The expected type of object.
- currAttr- The current bean property name.
- r- The reader.
- outer- The outer object.
- isRoot- If- true , then we're serializing a root element in the document.
- pMeta- The bean property metadata.
- Returns:
- The parsed object.
- Throws:
- IOException- Thrown by underlying stream.
- ParseException- Malformed input encountered.
- ExecutableException- Exception occurred on invoked constructor/method/field.
- XMLStreamException- Malformed XML encountered.
 
- 
getEventAllocatorXML event allocator.- Returns:
- The XMLEventAllocatorassociated with this parser, ornull if there isn't one.
- See Also:
 
- 
isPreserveRootElementPreserve root element during generalized parsing.- Returns:
- true if when parsing into a generic- JsonMap, the map will contain a single entry whose key is the root element name.
- See Also:
 
- 
getReporterXML reporter.- Returns:
- The XMLReporterassociated with this parser, ornull if there isn't one.
- See Also:
 
- 
getResolverXML resolver.- Returns:
- The XMLResolverassociated with this parser, ornull if there isn't one.
- See Also:
 
- 
isValidatingEnable validation.- Returns:
- true if XML document will be validated.
- See Also:
 
- 
getXmlClassMetaReturns the language-specific metadata on the specified class.- Parameters:
- cm- The class to return the metadata on.
- Returns:
- The metadata.
 
- 
getXmlBeanMetaReturns the language-specific metadata on the specified bean.- Parameters:
- bm- The bean to return the metadata on.
- Returns:
- The metadata.
 
- 
getXmlBeanPropertyMetaReturns the language-specific metadata on the specified bean property.- Parameters:
- bpm- The bean property to return the metadata on.
- Returns:
- The metadata.
 
 
-