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()
EntityFormatGet the type of entities returned by this format.
getEntityType in interface EntityFormatpublic int getHeaderLines()
EntityFormatGet the number of header lines this format uses.
getHeaderLines in interface EntityFormatpublic LineEntityParser makeParser(java.util.List<java.lang.String> header)
EntityFormatCreate an entity parser for a file.
makeParser in interface EntityFormatheader - 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 EntityFormatpublic EntityBuilder newEntityBuilder()
Instantiate a new entity builder.
public java.util.Map<java.lang.String,TypedName<?>> getDefinedAttributes()
Get the attributes expected.
public AttributeSet getAttributes()
EntityFormatGet the set of attributes entities from format may have, if known.
getAttributes in interface EntityFormatnull 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()
EntityFormatCreate a JSON description of this entity format.
toJSON in interface EntityFormatpublic 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