public class ReferencePathManager
extends java.lang.Object
Title: Framework Support Library
Description: A utility for extracting values of structured data elements.
The Reference Path Manager
utility allows users to extract specific fields from a
data object (SDO) using it's data reference path. This provides a mechanism for working with data
elements for the purpose of mapping between object instances or exposing certain object elements
without allowing access to the underlying object, resulting in a reference by copy and leaving
the source object safe from modifications.
Structured Data Reference
A structured data reference (SDR) acts as a pointer to a specific object element (field). The
reference uses a short-hand notation to point to a specific element or collection instance. It may be used
in the same way as a pointer. However because an SDR is a text reference it may be serialized
or used by meta-data facilities to represent an object reference. A collection of references may
represent a structured data subset. Although such as subset is inherently flat it may be combined with
other subsets to create mappings between hierarchical structures. This allows for very easy extraction
of values and for mapping between object instances. SDR paths are also used by the Application Dataspace
facilities to reference object values stored in dataspace collection. This allows users to index
objects by value, query and join such objects using the Dataspace Query Language (DSQL). See
the spath()
function for additional details.
Data Reference Path
The structured data reference path (SPATH) expression allows users to specify a data reference. The path expression uses the following node and instance identifiers to point to specific data elements:
someKey
SemanticType
.Examples:
Consider the following set of objects: class AssetTag { private String assetName = ""; private int assetId = 0; private String assetDesc = ""; .. .. // Get and Set methods omitted.. } class Employee { private String firstName = "Bob"; private String lastName = "Smith"; private VectorCasting failures will result inassets = new Vector(); .. .. // Get and Set methods omitted.. } Here are some valid paths that may be used to extract data elements from Employee object: //firstName //firstName/assets //firstName/assets[2] //firstName/assets[TOP] To force a type check using a semantic type reference: //firstName/assets[2]:{AssetTag} //firstName/assets[2]:{AssetTag}/assetId
ReferencePathException
being thrown.
Semantic Types and Object Casting
Semantic type hints are an optional but recommended mechanism for enforcing the usage of correct object
instances to represent reference paths. The utility class allows users to pass AliasManager
into the constructor and use it to resolve semantic types to their associate classes.
Copyright: Copyright (c) 2011
Company: StreamScape Technologies
Modifier and Type | Class and Description |
---|---|
static class |
ReferencePathManager.SdrInfo |
Modifier and Type | Method and Description |
---|---|
java.util.Map |
getReferenceValueMap(java.util.List sdrPaths,
java.lang.Object object)
Returns a table containing the reference paths to object elements and their associated values.
|
java.lang.Class |
getTypeAtPath(java.lang.String sdrPath,
java.lang.Class clazz) |
java.lang.Object |
getValueAtMap(java.lang.String sdrPath,
java.lang.Object map)
Extracts a value from the object specified by the
Structured Data Reference Path . |
java.lang.Object |
getValueAtPath(java.lang.String sdrPath,
java.lang.Object object)
Extracts a value from the object specified by the
Structured Data Reference Path . |
static java.lang.Object |
getValueByIndex(java.lang.Object result,
java.lang.String index,
boolean isMapKey,
boolean isMapValue) |
java.lang.Object |
instantiateClass(java.lang.Class clazz) |
static ReferencePathManager.SdrInfo |
parseSdr(java.lang.String sdr) |
void |
setValueAtMap(java.lang.String sdrPath,
java.lang.Object object,
java.lang.Object fieldValue)
Sets a value of an object field specified by the
Structured Data Reference Path . |
void |
setValueAtMap(java.lang.String sdrPath,
java.lang.Object object,
java.lang.Object fieldValue,
boolean convertPrimitives) |
void |
setValueAtPath(java.lang.String sdrPath,
java.lang.Object object,
java.lang.Object fieldValue)
Sets a value of an object field specified by the
Structured Data Reference Path . |
void |
setValueAtPath(java.lang.String sdrPath,
java.lang.Object object,
java.lang.Object fieldValue,
boolean convertPrimitives) |
public java.lang.Object getValueAtPath(java.lang.String sdrPath, java.lang.Object object) throws ReferencePathException
Structured Data Reference Path
.
To specify map keys syntax [key=name] should be used.sdrPath
- the SDR path.object
- the object to be analyzed.ReferencePathException
- if some error occurs during this operation execution.public java.lang.Object getValueAtMap(java.lang.String sdrPath, java.lang.Object map) throws ReferencePathException
Structured Data Reference Path
.
If object is a Map field name from the path will be considered as a Map key.sdrPath
- map
- ReferencePathException
public void setValueAtPath(java.lang.String sdrPath, java.lang.Object object, java.lang.Object fieldValue) throws ReferencePathException
Structured Data Reference Path
.
To specify map keys syntax [key=name] should be used.sdrPath
- the SDR path.object
- the object to be analyzed.fieldValue
- new value of the fieldReferencePathException
- if some error occurs during this operation execution.public void setValueAtMap(java.lang.String sdrPath, java.lang.Object object, java.lang.Object fieldValue) throws ReferencePathException
Structured Data Reference Path
.
If object is a Map field name from the path will be considered as a Map key.sdrPath
- object
- fieldValue
- ReferencePathException
public void setValueAtPath(java.lang.String sdrPath, java.lang.Object object, java.lang.Object fieldValue, boolean convertPrimitives) throws ReferencePathException
ReferencePathException
public void setValueAtMap(java.lang.String sdrPath, java.lang.Object object, java.lang.Object fieldValue, boolean convertPrimitives) throws ReferencePathException
ReferencePathException
public java.lang.Class getTypeAtPath(java.lang.String sdrPath, java.lang.Class clazz) throws ReferencePathException
ReferencePathException
public java.util.Map getReferenceValueMap(java.util.List sdrPaths, java.lang.Object object) throws ReferencePathException
sdrPaths
- the list of SDR paths.object
- the object to be analyzed.ReferencePathException
- if some error occurs during this operation execution.public static ReferencePathManager.SdrInfo parseSdr(java.lang.String sdr)
public java.lang.Object instantiateClass(java.lang.Class clazz) throws java.lang.Exception
java.lang.Exception
public static java.lang.Object getValueByIndex(java.lang.Object result, java.lang.String index, boolean isMapKey, boolean isMapValue)
Copyright © 2015-2024 StreamScape Technologies. All rights reserved.