java.lang.Object
org.elasticsearch.xcontent.NamedXContentRegistry
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn entry in the NamedXContentRegistry containing the name of the object and the parser that can parse it. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final NamedXContentRegistryThe emptyNamedXContentRegistryfor use when you are sure that you aren't going to callXContentParser.namedObject(Class, String, Object). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasParser(Class<?> categoryClass, String name, RestApiVersion apiVersion) Returnstrueif this registry is able toparsethe referenced object, false otherwise.lookupParser(Class<T> categoryClass, String name, XContentParser parser) <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 emptyNamedXContentRegistryfor 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 anNamedObjectNotFoundExceptionif thecategoryClassisn't registered because this is almost always a bug. Throws anNamedObjectNotFoundExceptionif thecategoryClassis registered but thenameisn't.- Throws:
NamedObjectNotFoundException- if the categoryClass or name is not registeredIOException
-
hasParser
Returnstrueif this registry is able toparsethe referenced object, false otherwise. Note: This method does not throw exceptions, even if theRestApiVersionorcategoryClassare unknown. -
lookupParser
public <T> NamedXContentRegistry.Entry lookupParser(Class<T> categoryClass, String name, XContentParser parser)
-