Class NamedXContentRegistry
- java.lang.Object
-
- org.elasticsearch.common.xcontent.NamedXContentRegistry
-
public class NamedXContentRegistry extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNamedXContentRegistry.EntryAn entry in the NamedXContentRegistry containing the name of the object and the parser that can parse it.
-
Field Summary
Fields Modifier and Type Field Description static NamedXContentRegistryEMPTYThe emptyNamedXContentRegistryfor use when you are sure that you aren't going to callXContentParser.namedObject(Class, String, Object).
-
Constructor Summary
Constructors Constructor Description NamedXContentRegistry(java.util.List<NamedXContentRegistry.Entry> entries)
-
Method Summary
Modifier and Type Method Description <T,C>
TparseNamedObject(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.
-
-
-
Field Detail
-
EMPTY
public static final NamedXContentRegistry 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 Detail
-
NamedXContentRegistry
public NamedXContentRegistry(java.util.List<NamedXContentRegistry.Entry> entries)
-
-
Method Detail
-
parseNamedObject
public <T,C> T parseNamedObject(java.lang.Class<T> categoryClass, java.lang.String name, XContentParser parser, C context) throws java.io.IOExceptionParse 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 registeredjava.io.IOException
-
-