Package org.elasticsearch.xcontent
Class NamedXContentRegistry
java.lang.Object
org.elasticsearch.xcontent.NamedXContentRegistry
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An entry in the NamedXContentRegistry containing the name of the object and the parser that can parse it. -
Field Summary
Modifier and TypeFieldDescriptionstatic final NamedXContentRegistry
The emptyNamedXContentRegistry
for use when you are sure that you aren't going to callXContentParser.namedObject(Class, String, Object)
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T,
C> T parseNamedObject
(Class<T> categoryClass, String name, XContentParser parser, C context) Parse a named object, throwing an exception if the parser isn't found.
-
Field Details
-
EMPTY
The emptyNamedXContentRegistry
for use when you are sure that you aren't going to callXContentParser.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 thoroughly 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.
-
-
Constructor Details
-
NamedXContentRegistry
-
-
Method Details
-
parseNamedObject
public <T,C> T parseNamedObject(Class<T> categoryClass, String name, XContentParser parser, C context) throws IOException Parse a named object, throwing an exception if the parser isn't found. Throws anNamedObjectNotFoundException
if thecategoryClass
isn't registered because this is almost always a bug. Throws anNamedObjectNotFoundException
if thecategoryClass
is registered but thename
isn't.- Throws:
NamedObjectNotFoundException
- if the categoryClass or name is not registeredIOException
-