public class JSONEntityFormat extends java.lang.Object implements EntityFormat
Entity format that decodes JSON objects.
Constructor and Description |
---|
JSONEntityFormat() |
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(java.lang.String name,
TypedName<?> attr)
Add an attribute to the list of expected attributes, with a JSON field name.
|
void |
addAttribute(TypedName<?> attr)
Add an attribute to the list of expected attributes.
|
static JSONEntityFormat |
fromJSON(java.lang.String name,
java.lang.ClassLoader loader,
com.fasterxml.jackson.databind.JsonNode json) |
AttributeSet |
getAttributes()
Get the set of attributes entities from format may have, if known.
|
java.util.Map<java.lang.String,TypedName<?>> |
getDefinedAttributes()
Get the attributes expected.
|
java.lang.Class<? extends EntityBuilder> |
getEntityBuilder()
Get the entity builder class.
|
EntityType |
getEntityType()
Get the type of entities returned by this format.
|
int |
getHeaderLines()
Get the number of header lines this format uses.
|
LineEntityParser |
makeParser(java.util.List<java.lang.String> header)
Create an entity parser for a file.
|
EntityBuilder |
newEntityBuilder()
Instantiate a new entity builder.
|
void |
setEntityBuilder(java.lang.Class<? extends EntityBuilder> builder)
Set the entity builder class.
|
void |
setEntityType(EntityType type)
Set the entity type.
|
com.fasterxml.jackson.databind.node.ObjectNode |
toJSON()
Create a JSON description of this entity format.
|
java.lang.String |
toString() |
public void setEntityType(EntityType type)
Set the entity type.
type
- The entity type.public EntityType getEntityType()
EntityFormat
Get the type of entities returned by this format.
getEntityType
in interface EntityFormat
public int getHeaderLines()
EntityFormat
Get the number of header lines this format uses.
getHeaderLines
in interface EntityFormat
public LineEntityParser makeParser(java.util.List<java.lang.String> header)
EntityFormat
Create an entity parser for a file.
makeParser
in interface EntityFormat
header
- The header lines.public void setEntityBuilder(java.lang.Class<? extends EntityBuilder> builder)
Set the entity builder class.
builder
- The entity builder class.public java.lang.Class<? extends EntityBuilder> getEntityBuilder()
Get the entity builder class.
getEntityBuilder
in interface EntityFormat
public EntityBuilder newEntityBuilder()
Instantiate a new entity builder.
public java.util.Map<java.lang.String,TypedName<?>> getDefinedAttributes()
Get the attributes expected.
public AttributeSet getAttributes()
EntityFormat
Get the set of attributes entities from format may have, if known.
getAttributes
in interface EntityFormat
null
if that information is not known.public void addAttribute(TypedName<?> attr)
Add an attribute to the list of expected attributes. It will be parsed from the JSON object field of the same name.
attr
- The attribute to add.public void addAttribute(java.lang.String name, TypedName<?> attr)
Add an attribute to the list of expected attributes, with a JSON field name.
name
- The name of the field as it will appear in JSON.attr
- The attribute to add.public com.fasterxml.jackson.databind.node.ObjectNode toJSON()
EntityFormat
Create a JSON description of this entity format.
toJSON
in interface EntityFormat
public static JSONEntityFormat fromJSON(java.lang.String name, java.lang.ClassLoader loader, com.fasterxml.jackson.databind.JsonNode json)
public java.lang.String toString()
toString
in class java.lang.Object