org.deckfour.xes.extension.std
Class XAbstractNestedAttributeSupport<Type>

java.lang.Object
  extended by org.deckfour.xes.extension.std.XAbstractNestedAttributeSupport<Type>
Direct Known Subclasses:
XCostAmount, XCostDriver, XCostType

public abstract class XAbstractNestedAttributeSupport<Type>
extends Object

This class offers generic support for extracting and assigning values to and from nested attributes.

Author:
Eric Verbeek (h.m.w.verbeek@tue.nl)

Constructor Summary
XAbstractNestedAttributeSupport()
           
 
Method Summary
 void assignNestedValues(XAttributable element, Map<List<String>,Type> amounts)
          Assigns (to the given event) multiple values given their key lists.
abstract  void assignValue(XAttribute element, Type value)
          Abstract method to assign a value to an element.
 void assignValues(XAttributable element, Map<String,Type> values)
          Assigns (to the given element) multiple values given their keys.
 Map<List<String>,Type> extractNestedValues(XAttributable element)
          Retrieves a map containing all values for all descending attributes of an element.
abstract  Type extractValue(XAttribute element)
          Abstract method to extract a value from an element.
 Map<String,Type> extractValues(XAttributable element)
          Retrieves a map containing all values for all child attributes of an element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XAbstractNestedAttributeSupport

public XAbstractNestedAttributeSupport()
Method Detail

extractValue

public abstract Type extractValue(XAttribute element)
Abstract method to extract a value from an element.

Parameters:
element - The element to extract the value from.
Returns:
The extracted value.

assignValue

public abstract void assignValue(XAttribute element,
                                 Type value)
Abstract method to assign a value to an element.

Parameters:
element - The element to assign the value to.
value - The value to be assigned.

extractValues

public Map<String,Type> extractValues(XAttributable element)
Retrieves a map containing all values for all child attributes of an element. For example, the XES fragment:
 <trace>
     <string key="key.1" value="">
         <float key="ext:attr" value="val.1"/>
         <string key="key.1.1" value="">
         	  <float key="ext:attr" value="val.1.1"/>
         </string>
         <string key="key.1.2" value="">
         	  <float key="ext:attr" value="val.1.2"/>
         </string>
     </string>
     <string key="key.2" value="">
        <float key="ext:attr" value="val.2"/>
     </string>
     <string key="key.3" value="">
        <float key="ext:attr" value="val.3"/>
     </string>
 </trace>
 
 
should result into the following:
 [[key.1 val.1] [key.2 val.2] [key.3 val.3]]
 

Parameters:
element - Element to retrieve all values for.
Returns:
Map from all child keys to values.

extractNestedValues

public Map<List<String>,Type> extractNestedValues(XAttributable element)
Retrieves a map containing all values for all descending attributes of an element. For example, the XES fragment:
 <trace>
     <string key="key.1" value="">
         <float key="ext:attr" value="val.1"/>
         <string key="key.1.1" value="">
         	  <float key="ext:attr" value="val.1.1"/>
         </string>
         <string key="key.1.2" value="">
         	  <float key="ext:attr" value="val.1.2"/>
         </string>
     </string>
     <string key="key.2" value="">
        <float key="ext:attr" value="val.2"/>
     </string>
     <string key="key.3" value="">
        <float key="ext:attr" value="val.3"/>
     </string>
 </trace>
 
 
should result into the following:
 [[[key.1] val.1] [[key.1 key.1.1] val.1.1] [[key.1 key.1.2] val.1.2] [[key.2] val.2] [[key.3] val.3]]
 

Parameters:
element - Element to retrieve all values for.
Returns:
Map from all descending keys to values.

assignValues

public void assignValues(XAttributable element,
                         Map<String,Type> values)
Assigns (to the given element) multiple values given their keys. Note that as a side effect this method creates attributes when it does not find an attribute with the proper key. For example, the call:
 assignValues(event, [[key.1 val.1] [key.2 val.2] [key.3 val.3]])
 
should result into the following XES fragment:
 <event>
     <string key="key.1" value="">
         <float key="ext:attr" value="val.1"/>
     </string>
     <string key="key.2" value="">
        <float key="ext:attr" value="val.2"/>
     </string>
     <string key="key.3" value="">
        <float key="ext:attr" value="val.3"/>
     </string>
 </event>
 
 

Parameters:
event - Event to assign the values to.
amounts - Mapping from keys to values which are to be assigned.

assignNestedValues

public void assignNestedValues(XAttributable element,
                               Map<List<String>,Type> amounts)
Assigns (to the given event) multiple values given their key lists. The i-th element in the key list should correspond to an i-level attribute with the prescribed key. Note that as a side effect this method creates attributes when it does not find an attribute with the proper key. For example, the call:
 assignNestedValues(event, [[[key.1] val.1] [[key.1 key.1.1] val.1.1] [[key.1 key.1.2] val.1.2] [[key.2] val.2] [[key.3] val.3]])
 
should result into the following XES fragment:
 <event>
     <string key="key.1" value="">
         <float key="ext:attr" value="val.1"/>
         <string key="key.1.1" value="">
         	  <float key="ext:attr" value="val.1.1"/>
         </string>
         <string key="key.1.2" value="">
         	  <float key="ext:attr" value="val.1.2"/>
         </string>
     </string>
     <string key="key.2" value="">
        <float key="ext:attr" value="val.2"/>
     </string>
     <string key="key.3" value="">
        <float key="ext:attr" value="val.3"/>
     </string>
 </event>
 
 

Parameters:
element - Element to assign the values to.
amounts - Mapping from key lists to values which are to be assigned.