Class MarkdownParser
- All Implemented Interfaces:
MarkdownMetaProvider,RecordReadable
- Direct Known Subclasses:
MarkdownDocParser
Media types
Handles
Description
Parses Markdown tables and bulleted lists produced by MarkdownSerializer back into Java objects.
The following mappings apply:
- 2-column key/value tables are parsed as beans or
Maps. - Multi-column tables are parsed as
Lists of beans orMaps. - Bulleted lists are parsed as
Lists. - Table cells containing backtick-wrapped JSON5 values are parsed via
Json5Parser.
Example:
Limitations:
- Multi-line string values cannot round-trip; newlines in cells are literal
<br>text. - The configured null value string (default:
*null*) is interpreted asnull, not as the literal string. - Without a target type, table cell values are auto-detected as Integer, Long, Double, Boolean, or String.
- Type ambiguity: without a target type, tables return
Map<String,Object>(key/value) orList<Map>(multi-column). - This class is thread safe and reusable.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMarkdownParser.Builder<SELF extends MarkdownParser.Builder<SELF>>Builder class.static final classNested classes/interfaces inherited from class org.apache.juneau.marshall.parser.Parser
Parser.Null -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MarkdownParserDefault parser, all default settings.Fields inherited from class org.apache.juneau.marshall.parser.Parser
autoCloseStreams, consumes, debugOutputLines, listener, nulls, trimStrings, unbufferedFields inherited from class org.apache.juneau.marshall.MarshallingContextable
marshallingContextFields inherited from class org.apache.juneau.marshall.Context
CONTEXT_APPLY_FILTER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a builder from this context object.static MarkdownParser.Builder<?>create()Creates a new builder for this object.Create a session builder based on the properties defined on this context.Returns the language-specific metadata on the specified bean property.getMarkdownClassMeta(ClassMeta<?> cm) Returns the language-specific metadata on the specified class.Returns the string that is interpreted as null when parsing.Returns a session to use for this context.booleanStreaming-quality signal queryable before opening a cursor.readRecords(Object input) Convenience delegator that opens aRecordReaderover the input using default session arguments (mirrorsParser.read(Object, Class)).Methods inherited from class org.apache.juneau.marshall.parser.ReaderParser
getStreamCharset, isReaderParser, propertiesMethods inherited from class org.apache.juneau.marshall.parser.Parser
canHandle, createParserBuilder, doRead, getDebugOutputLines, getListener, getMediaTypes, getNulls, getPrimaryMediaType, isAutoCloseStreams, isTrimStrings, isUnbuffered, read, read, read, read, read, read, readArgs, readIntoCollection, readIntoMap, readWithOuterMethods inherited from class org.apache.juneau.marshall.MarshallingContextable
getDurationFormat, getMarshallingContext, getPeriodFormatMethods inherited from class org.apache.juneau.marshall.Context
createBuilder, getAnnotationProvider, init, isDebug, toString
-
Field Details
-
DEFAULT
Default parser, all default settings.
-
-
Constructor Details
-
MarkdownParser
Constructor.- Parameters:
builder- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Returns:
- A new builder.
-
getNullValue
Returns the string that is interpreted as null when parsing.- Returns:
- The null marker.
-
copy
Description copied from class:ContextCreates a builder from this context object.Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
-
createSession
Description copied from class:ContextCreate a session builder based on the properties defined on this context.Use this method for creating sessions where you want to override basic settings. Otherwise, use
Context.getSession()directly.- Overrides:
createSessionin classReaderParser- Returns:
- A new session builder.
-
getMarkdownBeanPropertyMeta
Description copied from interface:MarkdownMetaProviderReturns the language-specific metadata on the specified bean property.- Specified by:
getMarkdownBeanPropertyMetain interfaceMarkdownMetaProvider- Parameters:
bpm- The bean property to return the metadata on.- Returns:
- The metadata.
-
getMarkdownClassMeta
Description copied from interface:MarkdownMetaProviderReturns the language-specific metadata on the specified class.- Specified by:
getMarkdownClassMetain interfaceMarkdownMetaProvider- Parameters:
cm- The class to return the metadata on.- Returns:
- The metadata.
-
getSession
Description copied from class:ContextReturns a session to use for this context.Note that subclasses may opt to return a reusable non-modifiable session.
- Overrides:
getSessionin classReaderParser- Returns:
- A new session object.
-
readRecords
Convenience delegator that opens aRecordReaderover the input using default session arguments (mirrorsParser.read(Object, Class)).The real implementation lives on
MarkdownParserSession.readRecords(Object). Callers that need request-derived configuration (locale, timezone, schema, swaps) should callcreateSession()and invokeMarkdownParserSession.readRecords(Object)on the built session instead.- Specified by:
readRecordsin interfaceRecordReadable- Parameters:
input- The input.- Returns:
- A new
RecordReadercursor. - Throws:
IOException- If a problem occurred opening the underlying input.
-
isRecordStreaming
Description copied from interface:RecordReadableStreaming-quality signal queryable before opening a cursor.- Specified by:
isRecordStreamingin interfaceRecordReadable- Returns:
true ifRecordReadable.readRecords(Object)returns an O(1)-memory streaming cursor;false for buffered (whole-value) formats backed byRecordAdapter.
-