Class EntityJson
- java.lang.Object
-
- org.symphonyoss.symphony.entityjson.EntityJson
-
- All Implemented Interfaces:
Iterable<StructuredObject>
public class EntityJson extends Object implements Iterable<StructuredObject>
Represents an EntityJSON document which is an object containing one or more StructuredObjects.- Author:
- Bruce Skingle
-
-
Constructor Summary
Constructors Constructor Description EntityJson(IEntityJsonInstanceContext context)Construct an EntityJson from the given context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(StructuredObject o)As per the method of the same name in java.util.ListStructuredObjectget(int index)As per the method of the same name in java.util.ListStructuredObjectget(String name)Return the StructuredObject for the given name, or null.List<StructuredObject>getChildren()Return the StructuredObjects contained within this object as a list.IEntityJsonInstanceContextgetContext()Return the parse context from which this object was created, which includes error reports if the input was invalid in some way.booleanisEmpty()As per the method of the same name in java.util.ListIterator<StructuredObject>iterator()intsize()As per the method of the same name in java.util.ListStringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
EntityJson
public EntityJson(IEntityJsonInstanceContext context) throws InvalidInstanceException
Construct an EntityJson from the given context. Each object within the EntityJSON structure is parsed and validated against the general StructuredObject schema. Callers who wish to validate individual objects against their specific schema need to call validate() on each object in turn, using this object as an Iterableif desired. Although this class and its constructor are public, it is not envisaged that clients will call it directly, rather one would expect instances to be obtained via EntityJsonParser.parseStructuredObject(...)- Parameters:
context- A parser context.- Throws:
InvalidInstanceException- If the EntityJSON structure contains elements whch are not valid STructuredObjects.
-
-
Method Detail
-
getContext
public IEntityJsonInstanceContext getContext()
Return the parse context from which this object was created, which includes error reports if the input was invalid in some way.- Returns:
- The parse context from which this object was created.
-
getChildren
public List<StructuredObject> getChildren()
Return the StructuredObjects contained within this object as a list.- Returns:
- The StructuredObjects contained within this object.
-
iterator
public Iterator<StructuredObject> iterator()
- Specified by:
iteratorin interfaceIterable<StructuredObject>
-
get
@Nullable public StructuredObject get(String name)
Return the StructuredObject for the given name, or null.- Parameters:
name- The name of the required object.- Returns:
- The required child object, or null if the given name does not exist.
-
size
public int size()
As per the method of the same name in java.util.List
-
isEmpty
public boolean isEmpty()
As per the method of the same name in java.util.List
-
contains
public boolean contains(StructuredObject o)
As per the method of the same name in java.util.List
-
get
public StructuredObject get(int index)
As per the method of the same name in java.util.List
-
-