Class HoconParser
- All Implemented Interfaces:
HoconMetaProvider,RecordReadable
Media types
Handles
Description
Multi-pass parsing strategy: tokenize → build intermediate tree → resolve substitutions → convert to bean.
Accepts all three key-value separators:
Supports unquoted string keys and values, path expressions (
Example input (bean):
name = myapp port = 8080 debug = true database { host = localhost port = 5432 } tags = [web, api, rest]
Limitations:
include directives are not supported — they are ignored with a warning during parsing.- Duration/size unit suffixes (
10s ,5m ,512K ,2G ) are treated as unquoted strings. - Substitutions are resolved before bean conversion; the resolved (concrete) values are what Juneau sees.
See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.juneau.marshall.parser.ReaderParser
ReaderParser.DefaultBuilderNested classes/interfaces inherited from class org.apache.juneau.marshall.parser.Parser
Parser.Null -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HoconParserDefault parser.protected final booleanWhether to resolve ${var} substitutions.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 HoconParser.Buildercreate()Creates a new builder.Create a session builder based on the properties defined on this context.Returns the HOCON-specific metadata on the specified bean property.getHoconClassMeta(ClassMeta<?> cm) Returns the HOCON-specific metadata on the specified class.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
getSession, 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
-
resolveSubstitutions
Whether to resolve ${var} substitutions. -
DEFAULT
Default parser.
-
-
Constructor Details
-
HoconParser
Constructor.- Parameters:
builder- The builder.
-
-
Method Details
-
create
Creates a new builder.- Returns:
- A new builder.
-
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.
-
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.
-
getHoconBeanPropertyMeta
Description copied from interface:HoconMetaProviderReturns the HOCON-specific metadata on the specified bean property.- Specified by:
getHoconBeanPropertyMetain interfaceHoconMetaProvider- Parameters:
bpm- The bean property to return the metadata on.- Returns:
- The metadata.
-
getHoconClassMeta
Description copied from interface:HoconMetaProviderReturns the HOCON-specific metadata on the specified class.- Specified by:
getHoconClassMetain interfaceHoconMetaProvider- Parameters:
cm- The class to return the metadata on.- Returns:
- The metadata.
-
readRecords
Convenience delegator that opens aRecordReaderover the input using default session arguments (mirrorsParser.read(Object, Class)).The real implementation lives on
HoconParserSession.readRecords(Object). Callers that need request-derived configuration (locale, timezone, schema, swaps) should callcreateSession()and invokeHoconParserSession.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.
-