org.deckfour.xes.info
Class XGlobalAttributeNameMap

java.lang.Object
  extended by org.deckfour.xes.info.XGlobalAttributeNameMap
All Implemented Interfaces:
XAttributeNameMap

public class XGlobalAttributeNameMap
extends Object
implements XAttributeNameMap

This singleton class implements a global attribute name mapping facility and can manage a number of attribute name mappings. Further, this class also acts as a proxy to the standard mapping, i.e. it can be used directly as a attribute name mapping instance.

Author:
Christian W. Guenther (christian@deckfour.org)

Field Summary
static String MAPPING_DUTCH
          The attribute name mapping to the Dutch language.
static String MAPPING_ENGLISH
          The attribute name mapping to the English language.
static String MAPPING_FRENCH
          The attribute name mapping to the French language.
static String MAPPING_GERMAN
          The attribute name mapping to the German language.
static String MAPPING_ITALIAN
          The attribute name mapping to the Italian language.
static String MAPPING_PORTUGUESE
          The attribute name mapping to the Portuguese language.
static String MAPPING_SPANISH
          The attribute name mapping to the Spanish language.
static String MAPPING_STANDARD
          The standard attribute name mapping, to the English language (EN).
 
Method Summary
 Collection<String> getAvailableMappingNames()
          Returns the names of all available mappings.
 Collection<XAttributeNameMap> getAvailableMappings()
          Returns all available mappings.
 XAttributeNameMap getMapping(String name)
          Provides access to a specific attribute name mapping by its name.
 String getMappingName()
          Returns the name of this mapping.
 XAttributeNameMap getStandardMapping()
          Retrieves the standard attribute name mapping, i.e.
static XGlobalAttributeNameMap instance()
          Accesses the singleton instance.
 String map(String attributeKey)
          Returns the name mapped onto the provided attribute key by this mapping.
 String map(XAttribute attribute)
          Returns the name mapped onto the provided attribute by this mapping.
 String mapSafely(String attributeKey, String mappingName)
          Maps an attribute safely, using the given attribute mapping.
 String mapSafely(String attributeKey, XAttributeNameMap mapping)
          Maps an attribute safely, using the given attribute mapping.
 String mapSafely(XAttribute attribute, String mappingName)
          Maps an attribute safely, using the given attribute mapping.
 String mapSafely(XAttribute attribute, XAttributeNameMap mapping)
          Maps an attribute safely, using the given attribute mapping.
 void registerMapping(String mappingName, String attributeKey, String alias)
          Registers a known attribute for mapping in a given attribute name map.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAPPING_STANDARD

public static final String MAPPING_STANDARD
The standard attribute name mapping, to the English language (EN).

See Also:
Constant Field Values

MAPPING_ENGLISH

public static final String MAPPING_ENGLISH
The attribute name mapping to the English language.

See Also:
Constant Field Values

MAPPING_GERMAN

public static final String MAPPING_GERMAN
The attribute name mapping to the German language.

See Also:
Constant Field Values

MAPPING_DUTCH

public static final String MAPPING_DUTCH
The attribute name mapping to the Dutch language.

See Also:
Constant Field Values

MAPPING_FRENCH

public static final String MAPPING_FRENCH
The attribute name mapping to the French language.

See Also:
Constant Field Values

MAPPING_ITALIAN

public static final String MAPPING_ITALIAN
The attribute name mapping to the Italian language.

See Also:
Constant Field Values

MAPPING_SPANISH

public static final String MAPPING_SPANISH
The attribute name mapping to the Spanish language.

See Also:
Constant Field Values

MAPPING_PORTUGUESE

public static final String MAPPING_PORTUGUESE
The attribute name mapping to the Portuguese language.

See Also:
Constant Field Values
Method Detail

instance

public static XGlobalAttributeNameMap instance()
Accesses the singleton instance.

Returns:
The global attribute name mapping instance.

getAvailableMappingNames

public Collection<String> getAvailableMappingNames()
Returns the names of all available mappings. Note that referenced mappings may be empty.

Returns:
A collection of names of all available mappings.

getAvailableMappings

public Collection<XAttributeNameMap> getAvailableMappings()
Returns all available mappings. Note that returned mappings may be empty.

Returns:
A collection of all available mappings.

getMapping

public XAttributeNameMap getMapping(String name)
Provides access to a specific attribute name mapping by its name. If the requested mapping does not exist yet, a new mapping will be created, added to the set of managed mappings, and returned. This means, this method will always return a mapping, but this could be empty.

Parameters:
name - Name of the requested mapping.
Returns:
The requested mapping, as stored in this facility (or newly created).

getStandardMapping

public XAttributeNameMap getStandardMapping()
Retrieves the standard attribute name mapping, i.e. the EN english language mapping.

Returns:
The standard mapping.

mapSafely

public String mapSafely(XAttribute attribute,
                        XAttributeNameMap mapping)
Maps an attribute safely, using the given attribute mapping. Safe mapping attempts to map the attribute using the given mapping first. If this does not succeed, the standard mapping (EN) will be used for mapping. If no mapping is available in the standard mapping, the original attribute key is returned unchanged. This way, it is always ensured that this method returns a valid string for naming attributes.

Parameters:
attribute - Attribute to map.
mapping - Mapping to be used preferably.
Returns:
The safe mapping for the given attribute.

mapSafely

public String mapSafely(String attributeKey,
                        XAttributeNameMap mapping)
Maps an attribute safely, using the given attribute mapping. Safe mapping attempts to map the attribute using the given mapping first. If this does not succeed, the standard mapping (EN) will be used for mapping. If no mapping is available in the standard mapping, the original attribute key is returned unchanged. This way, it is always ensured that this method returns a valid string for naming attributes.

Parameters:
attributeKey - Key of the attribute to map.
mapping - Mapping to be used preferably.
Returns:
The safe mapping for the given attribute key.

mapSafely

public String mapSafely(XAttribute attribute,
                        String mappingName)
Maps an attribute safely, using the given attribute mapping. Safe mapping attempts to map the attribute using the given mapping first. If this does not succeed, the standard mapping (EN) will be used for mapping. If no mapping is available in the standard mapping, the original attribute key is returned unchanged. This way, it is always ensured that this method returns a valid string for naming attributes.

Parameters:
attribute - Attribute to map.
mappingName - Name of the mapping to be used preferably.
Returns:
The safe mapping for the given attribute.

mapSafely

public String mapSafely(String attributeKey,
                        String mappingName)
Maps an attribute safely, using the given attribute mapping. Safe mapping attempts to map the attribute using the given mapping first. If this does not succeed, the standard mapping (EN) will be used for mapping. If no mapping is available in the standard mapping, the original attribute key is returned unchanged. This way, it is always ensured that this method returns a valid string for naming attributes.

Parameters:
attributeKey - Key of the attribute to map.
mappingName - Name of the mapping to be used preferably.
Returns:
The safe mapping for the given attribute.

registerMapping

public void registerMapping(String mappingName,
                            String attributeKey,
                            String alias)
Registers a known attribute for mapping in a given attribute name map. IMPORTANT: This method should only be called when one intends to create, or add to, the global attribute name mapping.

Parameters:
mappingName - Name of the mapping to register with.
attributeKey - Attribute key to be mapped.
alias - Alias to map the given attribute to.

getMappingName

public String getMappingName()
Description copied from interface: XAttributeNameMap
Returns the name of this mapping.

Specified by:
getMappingName in interface XAttributeNameMap
Returns:
The name of this mapping.

map

public String map(XAttribute attribute)
Description copied from interface: XAttributeNameMap
Returns the name mapped onto the provided attribute by this mapping. If no mapping for the given attribute is provided by this map, null is returned.

Specified by:
map in interface XAttributeNameMap
Parameters:
attribute - Attribute to retrieve mapping for.
Returns:
The mapping for the given attribute, or null, if no such mapping exists.

map

public String map(String attributeKey)
Description copied from interface: XAttributeNameMap
Returns the name mapped onto the provided attribute key by this mapping. If no mapping for the given attribute key is provided by this map, null is returned.

Specified by:
map in interface XAttributeNameMap
Parameters:
attributeKey - Attribute key to retrieve mapping for.
Returns:
The mapping for the given attribute key, or null, if no such mapping exists.

toString

public String toString()
Overrides:
toString in class Object