public class PropertyIndex extends Object implements Iterable<PropertyBase>
| Constructor and Description | 
|---|
PropertyIndex(PropertyBusinessObject parent,
             String name,
             PropertyBase... properties)
The constructor is essential for a proper property business object 
 | 
| Modifier and Type | Method and Description | 
|---|---|
Element | 
asElement()
Returns an element object mapping to the current object hierarchy similar
 to the map object 
 | 
Externalizable | 
asExternalizable()
Returns an externalizable object for serialization of this business object, unlike regular
 externalizables this implementation is robust to changes, additions and removals of 
 properties 
 | 
boolean | 
equals(Object o)
Returns true if the given object equals the property index 
 | 
void | 
fromJSON(String jsonString)
Populates the object from a JSON string 
 | 
void | 
fromXml(Element e)
Converts the XML element to this object hierarchy 
 | 
PropertyBase | 
get(int i)
Allows us to get an individual property within the object instance 
 | 
PropertyBase | 
get(String name)
Returns a property by its name 
 | 
PropertyBase | 
getIgnoreCase(String name)
Returns a property by its name regardless of case sensitivity for the name 
 | 
Object | 
getMetaDataOfClass(String meta)
Allows us to fetch class meta data not to be confused with standard properties 
 | 
String | 
getName()
The name of the parent business object 
 | 
int | 
getSize()
The number of properties in the class 
 | 
PropertyBase | 
getXmlTextElement()
Returns the property that contains the XML text e.g. 
 | 
int | 
hashCode()
The hashcode of the object 
 | 
void | 
init(Object... values)
This method works similarly to a constructor, it accepts the values for the properties in the order
 they appear within the index 
 | 
boolean | 
isExcludeFromJSON(PropertyBase pb)
Indicates whether the given property is excluded from the  
toJSON() method output | 
boolean | 
isExcludeFromMap(PropertyBase pb)
Indicates whether the given property is excluded from the  
toMapRepresentation() 
 method output | 
boolean | 
isXmlTextElement(PropertyBase p)
Toggles whether a given property should act as a text element for this 
 object 
 | 
Iterator<PropertyBase> | 
iterator()
Allows us to traverse the properties with a for-each statement 
 | 
void | 
loadJSON(InputStream stream)
Loads JSON for the object from the given input stream 
 | 
void | 
loadJSON(String name)
Loads JSON for the object from storage with the given name if it exists. 
 | 
<X extends PropertyBusinessObject> | 
loadJSONList(InputStream stream)
Loads JSON containing a list of property objects of this type 
 | 
<X extends PropertyBusinessObject> | 
loadJSONList(String name)
Loads JSON containing a list of property objects of this type 
 | 
PropertyBusinessObject | 
newInstance()
Creates a new instance of the parent class 
 | 
void | 
populateFromMap(Map<String,Object> m)
This is useful for JSON parsing, it allows converting JSON map data to objects 
 | 
void | 
populateFromMap(Map<String,Object> m,
               Class<? extends PropertyBusinessObject> recursiveType)
This is useful for JSON parsing, it allows converting JSON map data to objects 
 | 
void | 
putMetaDataOfClass(String meta,
                  Object o)
Sets class specific metadata 
 | 
void | 
registerExternalizable()
Invoking this method will allow a property object to be serialized seamlessly 
 | 
void | 
setExcludeFromJSON(PropertyBase pb,
                  boolean exclude)
Allows us to exclude a specific property from the toJSON process 
 | 
void | 
setExcludeFromMap(PropertyBase pb,
                 boolean exclude)
Allows us to exclude a specific property from the  
toMapRepresentation() process | 
boolean | 
setSimpleObject(PropertyBase p,
               Object val)
Sets one of the builtin simple objects into a property 
 | 
void | 
setXmlTextElement(PropertyBase p,
                 boolean t)
Toggles whether a given property should act as a text element for this 
 object 
 | 
void | 
storeJSON(String name)
Writes the JSON string to storage, it's a shortcut for writing/generating the JSON 
 | 
static void | 
storeJSONList(String name,
             List<? extends PropertyBusinessObject> objs)
Writes the JSON string to storage, it's a shortcut for writing/generating the JSON 
 | 
String | 
toJSON()
Converts the object to a JSON representation 
 | 
static String | 
toJSONList(List<? extends PropertyBusinessObject> objs)
Creates a JSON string, containing the list of property business objects 
 | 
Map<String,Object> | 
toMapRepresentation()
This is useful in converting a property object to JSON 
 | 
String | 
toString()
Returns a user readable printout of the property values which is useful for debugging 
 | 
String | 
toString(boolean includeNewline)
Returns a user readable printout of the property values which is useful for debugging 
 | 
String | 
toXML()
Converts the object to an XML representation 
 | 
public PropertyIndex(PropertyBusinessObject parent, String name, PropertyBase... properties)
parent - the parent object instancename - the name of the parent classproperties - the list of properties in the objectpublic String getName()
public PropertyBase get(String name)
name - the name of the property (case sensitive)public PropertyBase getIgnoreCase(String name)
name - the name of the property (case insensitive)public PropertyBase get(int i)
i - the index of the propertypublic int getSize()
public Iterator<PropertyBase> iterator()
iterator in interface Iterable<PropertyBase>public Object getMetaDataOfClass(String meta)
meta - the meta data unique namepublic void putMetaDataOfClass(String meta, Object o)
meta - the name of the meta datao - object value for the meta datapublic String toString()
public String toString(boolean includeNewline)
includeNewline - true to indicate that newline characters should be includedpublic void populateFromMap(Map<String,Object> m)
m - the mappublic boolean setSimpleObject(PropertyBase p, Object val)
p - the property baseval - the object valuepublic void populateFromMap(Map<String,Object> m, Class<? extends PropertyBusinessObject> recursiveType)
m - the maprecursiveType - when running into map types we create this object typepublic Map<String,Object> toMapRepresentation()
public String toJSON()
public Element asElement()
public String toXML()
public void setXmlTextElement(PropertyBase p, boolean t)
p - the property that should act as a text elementt - true to activate the text element false to remove itpublic boolean isXmlTextElement(PropertyBase p)
p - the propertypublic PropertyBase getXmlTextElement()
<xmltag>property value</xmltag>public void fromXml(Element e)
e - the elementpublic void init(Object... values)
values - values of properties in the order they appear in the indexpublic void storeJSON(String name)
name - the name of the storage filepublic static void storeJSONList(String name, List<? extends PropertyBusinessObject> objs)
name - the name of the storage fileobjs - a list of business objectspublic static String toJSONList(List<? extends PropertyBusinessObject> objs)
objs - a list of business objectspublic <X extends PropertyBusinessObject> List<X> loadJSONList(String name)
name - the name of the storagepublic <X extends PropertyBusinessObject> List<X> loadJSONList(InputStream stream) throws IOException
stream - the input streamIOExceptionpublic PropertyBusinessObject newInstance()
public void fromJSON(String jsonString)
jsonString - the JSON Stringpublic void loadJSON(String name)
name - the name of the storagepublic void loadJSON(InputStream stream) throws IOException
stream - the input stream containing the JSON fileIOExceptionpublic boolean equals(Object o)
public int hashCode()
public void setExcludeFromJSON(PropertyBase pb, boolean exclude)
pb - the propertyexclude - true to exclude and false to reincludepublic boolean isExcludeFromMap(PropertyBase pb)
toMapRepresentation() 
 method outputpb - the propertypublic void setExcludeFromMap(PropertyBase pb, boolean exclude)
toMapRepresentation() processpb - the propertyexclude - true to exclude and false to reincludepublic boolean isExcludeFromJSON(PropertyBase pb)
toJSON() method outputpb - the propertypublic void registerExternalizable()
public Externalizable asExternalizable()