Class HtmlParserSession
- All Implemented Interfaces:
BeanSession,ConverterSession,ArrayRecordReadable,RecordReadable
HtmlParser.
Notes:
- This class is not thread safe and is typically discarded after one use.
See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.juneau.marshall.xml.XmlParserSession
XmlParserSession.DefaultBuilder -
Field Summary
Fields inherited from class org.apache.juneau.marshall.parser.ParserSession
DEFAULT_MAX_PARSE_DEPTHFields inherited from class org.apache.juneau.marshall.MarshallingSession
NAME_PROPERTY_NAME -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic HtmlParserSession.Buildercreate(HtmlParser ctx) Creates a new builder for this object.protected <T> TdoRead(ParserPipe pipe, ClassMeta<T> type) Workhorse method.protected <E> Collection<E>doReadIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) Implementation method.protected <K,V> Map<K, V> doReadIntoMap(ParserPipe pipe, Map<K, V> m, Type keyType, Type valueType) Implementation method.protected StringIdentical toreadText(XmlReader)except assumes the current event is the opening tag.protected HtmlBeanPropertyMetaReturns the language-specific metadata on the specified bean property.protected HtmlClassMetagetHtmlClassMeta(ClassMeta<?> cm) Returns the language-specific metadata on the specified class.protected booleanReturnstrue if the current element is a whitespace element.protected StringParses CHARACTERS data.protected StringParses the current whitespace element.Methods inherited from class org.apache.juneau.marshall.xml.XmlParserSession
create, decodeString, getEventAllocator, getReporter, getResolver, getXmlBeanMeta, getXmlBeanPropertyMeta, getXmlClassMeta, getXmlReader, isArrayRecordStreaming, isPreserveRootElement, isRecordStreaming, isValidating, readAnything, readArrayRecords, readArrayRecords, readRecordsMethods inherited from class org.apache.juneau.marshall.parser.ReaderParserSession
create, createPipe, getStreamCharset, isReaderParser, propertiesMethods inherited from class org.apache.juneau.marshall.parser.ParserSession
allocateLocal, cast, checkRequired, convertAttrToType, create, doReadToBeanConsumer, enterParseDepth, exitParseDepth, getCalendarFormat, getClassMeta, getDateFormat, getDebugOutputLines, getDurationFormat, getInputAsString, getJavaMethod, getLastLocation, getListener, getListener, getListenerClass, getLocaleFormat, getNulls, getOuter, getPeriodFormat, getPosition, getSchema, getStringBuilder, getTemporalFormat, getTimeZoneFormat, isAutoCloseStreams, isTrimStrings, isUnbuffered, mark, onBeanSetterException, onUnknownProperty, parentBean, read, read, read, read, read, read, readArgs, readCalendar, readDate, readDuration, readIntoCollection, readIntoMap, readPeriod, readTemporal, readToBeanConsumer, returnStringBuilder, setCurrentClass, setCurrentProperty, setName, setParent, setPipe, swapParentBean, trim, trim, unmark, unswapMethods inherited from class org.apache.juneau.marshall.MarshallingSession
addWarning, convertToMemberType, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, convertToType, create, get, getActiveView, getAnnotationProvider, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionary, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassLoader, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getLocale, getMarshallingContext, getMediaType, getNotBeanClasses, getNotBeanPackagesNames, getPropertyNamer, getSwaps, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFindFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnoreMissingSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isPropertyInActiveView, isRecordComponentOrder, isUnsortedProperties, isUseInterfaceProxies, isUseJavaBeanIntrospector, isValidateSchema, newBean, newBean, newBeanMap, newBeanMap, newGenericList, newGenericMap, newGenericMap, object, parseToList, parseToMap, string, toArray, toBeanMap, toBeanMap, toBeanMapMethods inherited from class org.apache.juneau.marshall.ContextSession
checkForWarnings, getContext, getSessionProperties, getWarnings, isDebug, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.juneau.commons.conversion.ConverterSession
get
-
Constructor Details
-
HtmlParserSession
Constructor.- Parameters:
builder- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Parameters:
ctx- The context creating this session.
Cannot benull .- Returns:
- A new builder.
-
doRead
protected <T> T doRead(ParserPipe pipe, ClassMeta<T> type) throws IOException, ParseException, ExecutableException Description copied from class:ParserSessionWorkhorse method.Subclasses are expected to implement this method or
Parser.doRead(ParserSession,ParserPipe,ClassMeta).The default implementation of this method simply calls
Parser.doRead(ParserSession,ParserPipe,ClassMeta).- Overrides:
doReadin classXmlParserSession- 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. Ifnull orObject., object type is based on what's being parsed. For example, when parsing JSON text, it may return aclass 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.
-
doReadIntoCollection
protected <E> Collection<E> doReadIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) throws Exception Description copied from class:ParserSessionImplementation method.Default implementation throws an
UnsupportedOperationException.- Overrides:
doReadIntoCollectionin classXmlParserSession- Type Parameters:
E- The element type.- Parameters:
pipe- The parser input.c- The collection being loaded.elementType- The class type of the elements, ornull 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.
-
doReadIntoMap
protected <K,V> Map<K,V> doReadIntoMap(ParserPipe pipe, Map<K, V> m, Type keyType, Type valueType) throws ExceptionDescription copied from class:ParserSessionImplementation method.Default implementation throws an
UnsupportedOperationException.- Overrides:
doReadIntoMapin classXmlParserSession- 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, ornull to default toString..class valueType- The class type of the values, ornull 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.
-
getElementText
Identical toreadText(XmlReader)except assumes the current event is the opening tag.Precondition: Pointing to opening tag. Postcondition: Pointing to closing tag.
- Overrides:
getElementTextin classXmlParserSession- Parameters:
r- The stream being read from.- Returns:
- The parsed string.
- Throws:
XMLStreamException- Thrown by underlying XML stream.ParseException- Malformed input encountered.IOException- Thrown by underlying stream.
-
getHtmlBeanPropertyMeta
Returns the language-specific metadata on the specified bean property.- Parameters:
bpm- The bean property to return the metadata on.- Returns:
- The metadata.
-
getHtmlClassMeta
Returns the language-specific metadata on the specified class.- Parameters:
cm- The class to return the metadata on.- Returns:
- The metadata.
-
isWhitespaceElement
Description copied from class:XmlParserSessionReturnstrue 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" .- Overrides:
isWhitespaceElementin classXmlParserSession- Parameters:
r- The XML stream reader to read the current event from.- Returns:
true if the current element is a whitespace element.
-
readText
Parses CHARACTERS data.Precondition: Pointing to event immediately following opening tag. Postcondition: Pointing to closing tag.
- Overrides:
readTextin classXmlParserSession- Parameters:
r- The stream being read from.- Returns:
- The parsed string.
- Throws:
XMLStreamException- Thrown by underlying XML stream.IOException- Thrown by underlying stream.ParseException- Malformed input encountered.
-
readWhitespaceElement
protected String readWhitespaceElement(XmlReader r) throws IOException, ParseException, XMLStreamException Description copied from class:XmlParserSessionParses 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" .- Overrides:
readWhitespaceElementin classXmlParserSession- Parameters:
r- The XML stream reader to read the current event from.- Returns:
- The whitespace character or characters.
- Throws:
IOException- Thrown by underlying stream.ParseException- Malformed input encountered.XMLStreamException- Thrown by underlying reader.
-