public abstract class AttributeableEntity extends Object
Constructor and Description |
---|
AttributeableEntity() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the object and reset to defaults
|
protected javax.json.JsonObjectBuilder |
createJson()
Convert this object into JSON
|
void |
fromJSONObject(javax.json.JsonObject jsonObj)
Extract the metadata from the JSON object.
|
Map<String,javax.json.JsonValue> |
getAttributes()
Get the attributes
|
protected boolean |
getBoolean(String attributeName,
boolean defaultValue)
Helper method to get a boolean value from an attribute
|
protected int |
getInteger(String attributeName,
int defaultValue)
Helper method to get a integer value from an attribute
|
protected Number |
getNumber(String attributeName)
Helper method to get a number value from an attribute
|
protected String |
getString(javax.json.JsonValue jsonValue)
Helper method to get a string value from a JsonValue
|
protected String |
getString(String attributeName)
Helper method to get a string value from an attribute
|
protected String[] |
getStringArray(String attributeName)
Helper method to get a string array from an attribute
|
protected void |
setDefaults()
Apply the non-null default values.
|
protected void |
setString(javax.json.JsonObjectBuilder builder,
String attributeName,
String value)
Helper method to set a string value
|
protected void |
setStringArray(javax.json.JsonObjectBuilder builder,
String attributeName,
String[] value)
Helper method to set a string array
|
javax.json.JsonObject |
toJSONObject()
Convert this object into JSON
|
protected void setDefaults()
public void clear()
public javax.json.JsonObject toJSONObject() throws IOException
IOException
- If generating the JSON failspublic void fromJSONObject(javax.json.JsonObject jsonObj) throws IOException
clear()
jsonObj
- The JSON ObjectIOException
- If JSON parsing failspublic Map<String,javax.json.JsonValue> getAttributes()
protected javax.json.JsonObjectBuilder createJson() throws IOException
IOException
- If generating the JSON failsprotected String getString(javax.json.JsonValue jsonValue)
jsonValue
- The json valuenull
.protected String getString(String attributeName)
attributeName
- The attribute namenull
.protected String[] getStringArray(String attributeName) throws IOException
attributeName
- The attribute namenull
.IOException
protected Number getNumber(String attributeName) throws IOException
attributeName
- The attribute namenull
.IOException
- If the attribute value is not of type booleanprotected void setString(javax.json.JsonObjectBuilder builder, String attributeName, String value)
builder
- The json object builderattributeName
- The name of the attributevalue
- The string valueprotected void setStringArray(javax.json.JsonObjectBuilder builder, String attributeName, String[] value)
builder
- The json object builderattributeName
- The name of the attributevalue
- The string arrayprotected int getInteger(String attributeName, int defaultValue)
attributeName
- The attribute namedefaultValue
- default valueprotected boolean getBoolean(String attributeName, boolean defaultValue) throws IOException
attributeName
- The attribute namedefaultValue
- default valueIOException
- If the attribute value is not of type booleanCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.