-
- All Known Implementing Classes:
HoconConfigParser
,PropertiesConfigParser
,YamlConfigParser
public interface ConfigParser
Transforms configConfigParser.Content
into aConfigNode.ObjectNode
that represents the original structure and values from the content.The application can register parsers on a
Builder
using theConfig.Builder.addParser(ConfigParser)
method. The config system also locates parsers using the JavaServiceLoader
mechanism and automatically adds them to everyBuilder
unless the application disables this feature for a givenBuilder
by invokingConfig.Builder.disableParserServices()
.A parser can specify a
Priority
. If no priority is explicitly assigned, the value of 100 is assumed.Parser is used by the config system and a config source provides data as an input stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ConfigParser.Content
Config content to be parsed by aConfigParser
.
-
Field Summary
Fields Modifier and Type Field Description static int
PRIORITY
Default priority of the parser if registered byConfig.Builder
automatically.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description ConfigNode.ObjectNode
parse(ConfigParser.Content content)
Deprecated.default ConfigNode.ObjectNode
parse(ConfigParser.Content content, Function<String,Optional<InputStream>> relativeResolver)
Parses a specifiedConfigContent
into ahierarchical configuration representation
.Set<String>
supportedMediaTypes()
Returns set of supported media types by the parser.default List<String>
supportedSuffixes()
Config parser can define supported file suffixes.
-
-
-
Field Detail
-
PRIORITY
static final int PRIORITY
Default priority of the parser if registered byConfig.Builder
automatically.- See Also:
- Constant Field Values
-
-
Method Detail
-
supportedMediaTypes
Set<String> supportedMediaTypes()
Returns set of supported media types by the parser.Set of supported media types is used when config system looks for appropriate parser based on media type of content.
ParsableSource
implementations can useMediaTypes
to probe for media type of content to provide it to config system throughConfigParser.Content.Builder.mediaType(String)
.- Returns:
- supported media types by the parser
-
parse
@Deprecated ConfigNode.ObjectNode parse(ConfigParser.Content content) throws ConfigParserException
Deprecated.Parses a specifiedConfigContent
into ahierarchical configuration representation
.Never returns
null
.- Parameters:
content
- a content to be parsed- Returns:
- parsed hierarchical configuration representation
- Throws:
ConfigParserException
- in case of problem to parse configuration from the source
-
parse
default ConfigNode.ObjectNode parse(ConfigParser.Content content, Function<String,Optional<InputStream>> relativeResolver)
Parses a specifiedConfigContent
into ahierarchical configuration representation
.Never returns
null
.- Parameters:
content
- a content to be parsedrelativeResolver
- function to resolve relative resources to this resource (if supported by the source)- Returns:
- parsed hierarchical configuration representation
- Throws:
ConfigParserException
- in case of problem to parse configuration from the source
-
supportedSuffixes
default List<String> supportedSuffixes()
Config parser can define supported file suffixes. If such are defined, Helidon will use these to discover default configuration sources. For example if there is aConfigParser
that returnsxml
, config would look formeta-config.xml
to discover meta configuration, and forapplication.xml
on file system and on classpath to discover configuration files.Note that the suffixes must resolve into a media type supported by a config parser (see
MediaTypes.detectExtensionType(String)
).- Returns:
- a set of file suffixes supported by this config parser.
-
-