Package com.ibm.fhir.config
Class PropertyGroup
- java.lang.Object
- 
- com.ibm.fhir.config.PropertyGroup
 
- 
 public class PropertyGroup extends Object This class represents a collection of properties - a property group. This could be the entire set of properties resulting from loading the configuration, or it could be just a sub-structure within the overall config hierarchy, as a property group can contain other property groups. Internally, there is a JsonObject which holds the actual group of properties and this class provides a high-level API for accessing properties in a hierarchical manner.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classPropertyGroup.PropertyEntryThis class represents a single property contained within a PropertyGroup.
 - 
Field SummaryFields Modifier and Type Field Description protected javax.json.JsonObjectjsonObjstatic StringPATH_ELEMENT_SEPARATORThis constant represents the separator character used within a hierarchical property name.
 - 
Constructor SummaryConstructors Constructor Description PropertyGroup(javax.json.JsonObject jsonObj)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ObjectconvertJsonValue(javax.json.JsonValue jsonValue)Converts the specified JsonValue into the appropriate java.lang.* type.Object[]getArrayProperty(String propertyName)Returns the value (as an array of Object) of the specified array property.BooleangetBooleanProperty(String propertyName)Returns the value of the specified boolean property or null if it wasn't found.BooleangetBooleanProperty(String propertyName, Boolean defaultValue)Returns the value of the specified boolean property.DoublegetDoubleProperty(String propertyName)Returns the value of the specified double property or null if it wasn't found.DoublegetDoubleProperty(String propertyName, Double defaultValue)Returns the value of the specified double property.IntegergetIntProperty(String propertyName)Returns the value of the specified int property or null if it wasn't found.IntegergetIntProperty(String propertyName, Integer defaultValue)Returns the value of the specified int property.javax.json.JsonObjectgetJsonObj()javax.json.JsonValuegetJsonValue(String propertyName)Finds the specified property and returns it as a generic JsonValue.protected String[]getPathElements(String propertyName)Splits a potentially hierarchical property name into the individual path elementsList<PropertyGroup.PropertyEntry>getProperties()Returns the properties contained in the PropertyGroup in the form of a list of PropertyEntry instances.PropertyGroupgetPropertyGroup(String propertyName)Returns a PropertyGroup associated with the specified property.protected javax.json.JsonObjectgetPropertySubGroup(String[] pathElements)This function will find the JSON "sub object" rooted at "this.jsonObj" that is associated with the specified hierarchical property name.List<String>getStringListProperty(String propertyName)This is a convenience function that will retrieve an array property, then convert it to a list of Strings by calling toString() on each array element.StringgetStringProperty(String propertyName)Returns the value of the specified String property or null if it wasn't found.StringgetStringProperty(String propertyName, String defaultValue)Returns the value of the specified String property.protected voidsetJsonObj(javax.json.JsonObject jsonObj)StringtoString()Returns the String representation of the PropertyGroup instance.
 
- 
- 
- 
Field Detail- 
PATH_ELEMENT_SEPARATORpublic static final String PATH_ELEMENT_SEPARATOR This constant represents the separator character used within a hierarchical property name. Example:fhir-server/server-core/truststoreLocation- See Also:
- Constant Field Values
 
 - 
jsonObjprotected javax.json.JsonObject jsonObj 
 
- 
 - 
Method Detail- 
getJsonObjpublic javax.json.JsonObject getJsonObj() 
 - 
setJsonObjprotected void setJsonObj(javax.json.JsonObject jsonObj) 
 - 
getPropertyGrouppublic PropertyGroup getPropertyGroup(String propertyName) Returns a PropertyGroup associated with the specified property.- Parameters:
- propertyName- a hierarchical property name (e.g. "level1/level2/level3") that refers to a property group.
- Returns:
- a PropertyGroup that holds the sub-structure associated with the specified property.
 
 - 
getStringPropertypublic String getStringProperty(String propertyName) throws Exception Returns the value of the specified String property or null if it wasn't found. If the value is encoded, then it will be decoded.- Parameters:
- propertyName- the name of the property to retrieved
- Throws:
- Exception
 
 - 
getStringPropertypublic String getStringProperty(String propertyName, String defaultValue) throws Exception Returns the value of the specified String property. If not found, then 'defaultValue' is returned instead. If the value is encoded, then it will be decoded.- Parameters:
- propertyName- the name of the property to retrieve
- Throws:
- Exception
 
 - 
getStringListPropertypublic List<String> getStringListProperty(String propertyName) throws Exception This is a convenience function that will retrieve an array property, then convert it to a list of Strings by calling toString() on each array element.- Parameters:
- propertyName- the name of the property to retrieve
- Returns:
- a Listcontaining the elements from the JSON array property; possibly null 
- Throws:
- Exception
 
 - 
getIntPropertypublic Integer getIntProperty(String propertyName) Returns the value of the specified int property or null if it wasn't found.- Parameters:
- propertyName- the name of the property to retrieve
 
 - 
getIntPropertypublic Integer getIntProperty(String propertyName, Integer defaultValue) Returns the value of the specified int property. If not found, then 'defaultValue' is returned instead.- Parameters:
- propertyName- the name of the property to retrieve
 
 - 
getDoublePropertypublic Double getDoubleProperty(String propertyName) Returns the value of the specified double property or null if it wasn't found.- Parameters:
- propertyName- the name of the property to retrieve
 
 - 
getDoublePropertypublic Double getDoubleProperty(String propertyName, Double defaultValue) Returns the value of the specified double property. If not found, then 'defaultValue' is returned instead.- Parameters:
- propertyName- the name of the property to retrieve
 
 - 
getBooleanPropertypublic Boolean getBooleanProperty(String propertyName) Returns the value of the specified boolean property or null if it wasn't found.- Parameters:
- propertyName- the name of the property to retrieve
 
 - 
getBooleanPropertypublic Boolean getBooleanProperty(String propertyName, Boolean defaultValue) Returns the value of the specified boolean property. If not found, then 'defaultValue' is returned instead.- Parameters:
- propertyName- the name of the property to retrieve
 
 - 
getArrayPropertypublic Object[] getArrayProperty(String propertyName) throws Exception Returns the value (as an array of Object) of the specified array property. Each element of the returned array will be an instance of Boolean, Integer, Double, String or PropertyGroup, depending on the value type associated with the property within the underlying JsonObject.- Parameters:
- propertyName- the name of the property to retrieve
- Returns:
- an array of values from the specified array property or null if the property doesn't exist
- Throws:
- Exception
 
 - 
getPropertiespublic List<PropertyGroup.PropertyEntry> getProperties() throws Exception Returns the properties contained in the PropertyGroup in the form of a list of PropertyEntry instances. If no properties exist, then an empty list will be returned.- Throws:
- Exception
 
 - 
toStringpublic String toString() Returns the String representation of the PropertyGroup instance.
 - 
convertJsonValuepublic static Object convertJsonValue(javax.json.JsonValue jsonValue) throws Exception Converts the specified JsonValue into the appropriate java.lang.* type.- Parameters:
- jsonValue- the JsonValue instance to be converted
- Returns:
- an instance of Boolean, Integer, String, PropertyGroup, or List
- Throws:
- Exception
 
 - 
getJsonValuepublic javax.json.JsonValue getJsonValue(String propertyName) Finds the specified property and returns it as a generic JsonValue.- Parameters:
- propertyName- the possibly hierarchical property name.
 
 - 
getPathElementsprotected String[] getPathElements(String propertyName) Splits a potentially hierarchical property name into the individual path elements- Parameters:
- propertyName- a hierarchical property name (e.g. "level1/level2/myProperty"
- Returns:
 
 - 
getPropertySubGroupprotected javax.json.JsonObject getPropertySubGroup(String[] pathElements) This function will find the JSON "sub object" rooted at "this.jsonObj" that is associated with the specified hierarchical property name.For example, consider the following JSON structure: { "level1":{ "level2":{ "myProperty":"myValue" } } }If this function was invoked with a property name of "level1/level2/myProperty", then the result will be the JsonObject associated with the "level2" field within the JSON structure above.- Parameters:
- pathElements- an array of path elements that make up the hierarchical property name (e.g. {"level1", "level2", "myProperty"})
- Returns:
- the JsonObject sub-structure that contains the specified property.
 
 
- 
 
-