Class IniParser
- All Implemented Interfaces:
IniMetaProvider,RecordReadable
Parses INI files (section/key-value format) into Java beans and maps.
Media types
Consumes:
Value parsing
- Unquoted
null → Javanull - Unquoted
true /false → Boolean - Unquoted numbers → Number (int, long, float, double as appropriate)
- Single-quoted strings (
'...' ) → String (with'' unescaped to single quote) - Values starting with
[ or{ → Delegated to JSON parser - ISO 8601 strings → Date, Calendar, or
java.time.* when target requires it - ISO 8601 duration strings →
Duration - Other unquoted tokens → String
Sections
Sections (e.g.
Example:
Example input:
Limitations
Parsing into top-level collections, arrays, or scalar types is not supported.
The target type must be a bean class or
Notes:
- This class is thread safe and reusable.
- Values starting with
[ or{ are delegated to the JSON parser.
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 IniParserDefault parser instance.protected final charKey-value separator.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 IniParser.Buildercreate()Creates a new builder.Create a session builder based on the properties defined on this context.Returns the INI-specific metadata on the specified bean property.getIniClassMeta(ClassMeta<?> cm) Returns the INI-specific metadata on the specified class.booleanStreaming-quality signal queryable before opening a cursor.Returns the properties on this bean as a map for debugging.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, isReaderParserMethods 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 instance. -
kvSeparator
Key-value separator.
-
-
Constructor Details
-
IniParser
Constructor.- Parameters:
builder- The builder.
-
-
Method Details
-
create
Creates a new builder.- Returns:
- A new builder.
-
getIniBeanPropertyMeta
Description copied from interface:IniMetaProviderReturns the INI-specific metadata on the specified bean property.- Specified by:
getIniBeanPropertyMetain interfaceIniMetaProvider- Parameters:
bpm- The bean property to return the metadata on.- Returns:
- The metadata.
-
getIniClassMeta
Description copied from interface:IniMetaProviderReturns the INI-specific metadata on the specified class.- Specified by:
getIniClassMetain interfaceIniMetaProvider- Parameters:
cm- The class to return the metadata on.- Returns:
- The metadata.
-
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.
-
properties
Description copied from class:ContextReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classReaderParser- Returns:
- The properties on this bean as a map for debugging.
-
readRecords
Convenience delegator that opens aRecordReaderover the input using default session arguments (mirrorsParser.read(Object, Class)).The real implementation lives on
IniParserSession.readRecords(Object). Callers that need request-derived configuration (locale, timezone, schema, swaps) should callcreateSession()and invokeIniParserSession.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.
-