|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sonyericsson.hudson.plugins.metadata.model.JsonUtils
public abstract class JsonUtils
Constants regarding JSON conversions.
Nested Class Summary | |
---|---|
static class |
JsonUtils.ParseException
Exception thrown during the conversion from JSON to internal POJO representations if something went wrong. |
Field Summary | |
---|---|
static String |
CHILDREN
The TreeNodeMetadataValue.getChildren() attribute
of a node JSON object. |
static String |
DESCRIPTION
The Metadata.getDescription() attribute of a
JSON object. |
static String |
EXPOSED
The AbstractMetadataValue.isExposedToEnvironment()
attribute of a node JSON object. |
static String |
GENERATED
The MetadataValue.isGenerated() attribute of a JSON
object. |
static String |
METADATA_TYPE
The type of the metadata object mapped via AbstractMetadataValue.AbstractMetaDataValueDescriptor.findForJsonType(String)
to create the correct POJO implementation. |
static String |
NAME
The Metadata.getName() attribute of a JSON
object. |
static String |
VALUE
The Metadata.getValue() attribute of a JSON
object. |
Method Summary | |
---|---|
static void |
checkRequiredJsonAttribute(net.sf.json.JSONObject json,
String attribute)
Utility method for checking if a required attribute is present in the JSON object. |
static net.sf.json.JSON |
toJson(Collection<MetadataValue> values)
Converts the given values into a JSON array. |
static MetadataValue |
toValue(net.sf.json.JSONObject json,
MetadataContainer<MetadataValue> container)
Converts the given JSON object to MetadataValue . |
static List<MetadataValue> |
toValues(net.sf.json.JSONArray json,
MetadataContainer<MetadataValue> container)
Converts the given JSON array to MetadataValue s. |
static List<MetadataValue> |
toValues(net.sf.json.JSON json,
MetadataContainer<MetadataValue> container)
Converts the given JSON object to MetadataValue s. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String NAME
Metadata.getName()
attribute of a JSON
object. Usually required.
public static final String DESCRIPTION
Metadata.getDescription()
attribute of a
JSON object. Usually not required.
public static final String METADATA_TYPE
AbstractMetadataValue.AbstractMetaDataValueDescriptor.findForJsonType(String)
to create the correct POJO implementation.
public static final String VALUE
Metadata.getValue()
attribute of a JSON
object. Usually required.
public static final String CHILDREN
TreeNodeMetadataValue.getChildren()
attribute
of a node JSON object. Used instead of VALUE
for nodes.
public static final String EXPOSED
AbstractMetadataValue.isExposedToEnvironment()
attribute of a node JSON object. Used to decide if this value should be exposed as an environment variable..
public static final String GENERATED
MetadataValue.isGenerated()
attribute of a JSON
object. Usually not required.
Method Detail |
---|
public static List<MetadataValue> toValues(net.sf.json.JSON json, MetadataContainer<MetadataValue> container) throws JsonUtils.ParseException
MetadataValue
s. If the object is an array the method will return a list
of them all else it will be a list of one items.
json
- the JSON data to convert.container
- the container that the value is later supposed to go into.
Can be used to check for validity of attributes.
JsonUtils.ParseException
- if for example mandatory fields are missing in the data. The exception will contain the
JSONObject that was the offending one.toValues(net.sf.json.JSONArray, MetadataContainer)
public static List<MetadataValue> toValues(net.sf.json.JSONArray json, MetadataContainer<MetadataValue> container) throws JsonUtils.ParseException
MetadataValue
s.
json
- the JSON array to convert.container
- the container that the value is later supposed to go into.
Can be used to check for validity of attributes.
JsonUtils.ParseException
- if for example mandatory fields are missing in the data. The exception will contain the
JSONObject that was the offending one.toValue(net.sf.json.JSONObject, MetadataContainer)
public static MetadataValue toValue(net.sf.json.JSONObject json, MetadataContainer<MetadataValue> container) throws JsonUtils.ParseException
MetadataValue
.
json
- the JSON data to convert.container
- the container that the value is later supposed to go into.
Can be used to check for validity of attributes.
JsonUtils.ParseException
- if for example mandatory fields are missing in the data. The exception will contain the
JSONObject that was the offending one, it could be something further down the hierarchy
than the object provided..toValues(net.sf.json.JSONArray, MetadataContainer)
public static net.sf.json.JSON toJson(Collection<MetadataValue> values)
values
- the values to convert.
public static void checkRequiredJsonAttribute(net.sf.json.JSONObject json, String attribute) throws JsonUtils.ParseException
json
- the object to check.attribute
- the attribute to check for.
JsonUtils.ParseException
- if the attribute is missing.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |