Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.common.instance.helper
Class PropertyResolver

java.lang.Object
  extended by eu.esdihumboldt.hale.common.instance.helper.PropertyResolver

public class PropertyResolver
extends Object

This class provides plubic static methods for resolving propertys from instances. A cache provides that former accessed propertys are found faster and the programm does not need to search over the whole definitiontree of the instances again. Note: stringquery or querypath in comments references to a path of indicies reassambling a path of definitions inside the instance-definition-tree

Author:
Sebastian Reinhardt

Constructor Summary
PropertyResolver()
           
 
Method Summary
static void clearCache()
          Clear the definition cache, e.g.
static LinkedList<String> getKnownQueryPath(Instance instance, String query)
          Gets a certain definitionpath from the Cache by generating the cacheindex object from a given Instance (its Definitions) and the pathquery
static List<QName> getQNamesFromPath(String propertyPath)
          Split a property path into a list of QNames.
static Collection<Object> getValues(Instance instance, String propertyPath)
          Method for retrieving values from instances using a certain path query for searching through the instance definitions.
static Collection<Object> getValues(Instance instance, String propertyPath, boolean forceValue)
          Method for retrieving values from instances using a certain path query for searching through the instance definitions.
static boolean hasProperty(Instance instance, String query)
          Determines of the given Instance contains certain definitions questioned by a given stringquery.
static boolean isLastQueryPathUnique()
          Determines if the last query path was unique.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyResolver

public PropertyResolver()
Method Detail

getValues

public static Collection<Object> getValues(Instance instance,
                                           String propertyPath)
Method for retrieving values from instances using a certain path query for searching through the instance definitions. Calls methods for traversing the definition tree.

If at the end of the path there is an instance, its value will be returned.

Parameters:
instance - the instance
propertyPath - the property path
Returns:
the values contained in the instance matching the path

getValues

public static Collection<Object> getValues(Instance instance,
                                           String propertyPath,
                                           boolean forceValue)
Method for retrieving values from instances using a certain path query for searching through the instance definitions. Calls methods for traversing the definition tree.

Parameters:
instance - the instance
propertyPath - the property path
forceValue - if this is true, when the object at the end of a path is an instance, its value will be returned
Returns:
the values or instances contained in the instance matching the given path, may be null

getQNamesFromPath

public static List<QName> getQNamesFromPath(String propertyPath)
Split a property path into a list of QNames.

Parameters:
propertyPath - the property path
Returns:
the list of represented qualified names

hasProperty

public static boolean hasProperty(Instance instance,
                                  String query)
Determines of the given Instance contains certain definitions questioned by a given stringquery. If the cache allready contains this special path of the instance-definition-tree, true will be returned, else the method calls the analysismethods for searching of the definition-tree

Parameters:
instance - the given instance we are searching in
query - the given pathquery we are searching inside the definition-tree
Returns:
true if the path was found, else false

getKnownQueryPath

public static LinkedList<String> getKnownQueryPath(Instance instance,
                                                   String query)
Gets a certain definitionpath from the Cache by generating the cacheindex object from a given Instance (its Definitions) and the pathquery

Parameters:
instance - the given instance wich should contain the definitions mentioned in the paths
query - the pathstring from the filterquery
Returns:
a list of Strings with possible paths inside the definitions of the instance

isLastQueryPathUnique

public static boolean isLastQueryPathUnique()
Determines if the last query path was unique. This will only yield a reliable result if the last call to hasProperty(Instance, String) was done from the current thread. The information on the last hasProperty(Instance, String) call will be reset on calling this method.

Returns:
true if the last query path was unique or if there is no information on the last query path, false otherwise

clearCache

public static void clearCache()
Clear the definition cache, e.g. when the type definitions may no longer be valid. FIXME cache in service instead?


Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d