public class NamedXContentRegistry
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
NamedXContentRegistry.Entry
An entry in the NamedXContentRegistry containing the name of the object and the parser that can parse it.
|
static class |
NamedXContentRegistry.UnknownNamedObjectException
Thrown when
parseNamedObject(Class, String, XContentParser, Object) is called with an unregistered
name. |
Modifier and Type | Field and Description |
---|---|
static NamedXContentRegistry |
EMPTY
The empty
NamedXContentRegistry for use when you are sure that you aren't going to call
XContentParser.namedObject(Class, String, Object) . |
Constructor and Description |
---|
NamedXContentRegistry(java.util.List<NamedXContentRegistry.Entry> entries) |
Modifier and Type | Method and Description |
---|---|
<T,C> T |
parseNamedObject(java.lang.Class<T> categoryClass,
java.lang.String name,
XContentParser parser,
C context)
Parse a named object, throwing an exception if the parser isn't found.
|
public static final NamedXContentRegistry EMPTY
NamedXContentRegistry
for use when you are sure that you aren't going to call
XContentParser.namedObject(Class, String, Object)
. Be *very* careful with this singleton because a parser using it will fail
every call to XContentParser.namedObject(Class, String, Object). Every non-test usage really should be checked thorowly
and marked with a comment about how it was checked. That way anyone that sees code that uses it knows that it is potentially
dangerous.public NamedXContentRegistry(java.util.List<NamedXContentRegistry.Entry> entries)
public <T,C> T parseNamedObject(java.lang.Class<T> categoryClass, java.lang.String name, XContentParser parser, C context) throws java.io.IOException
ElasticsearchException
if the
categoryClass
isn't registered because this is almost always a bug. Throws a NamedXContentRegistry.UnknownNamedObjectException
if the
categoryClass
is registered but the name
isn't.java.io.IOException