Class XAttributeUtils


  • public class XAttributeUtils
    extends java.lang.Object
    Utilities for working with attributes.
    Author:
    Christian W. Guenther (christian@deckfour.org)
    • Constructor Summary

      Constructors 
      Constructor Description
      XAttributeUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static XAttribute composeAttribute​(XFactory factory, java.lang.String key, java.lang.String value, java.lang.String type, XExtension extension)
      Composes the appropriate attribute type from the string-based information found, e.g., in XML serializations.
      static XAttribute derivePrototype​(XAttribute instance)
      Derives a prototype for the given attribute.
      static java.util.Set<XExtension> extractExtensions​(java.util.Map<java.lang.String,​XAttribute> attributeMap)
      Static helper method for extracting all extensions from an attribute map.
      static java.lang.Class<? extends XAttribute> getType​(XAttribute attribute)
      For the given attribute, returns its type, i.e., the most high-level, typed interface this attribute implements.
      static java.lang.String getTypeString​(XAttribute attribute)
      For the given attribute, derives the standardized string describing the attributes specific type (used, e.g., for serialization).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XAttributeUtils

        public XAttributeUtils()
    • Method Detail

      • getType

        public static java.lang.Class<? extends XAttribute> getType​(XAttribute attribute)
        For the given attribute, returns its type, i.e., the most high-level, typed interface this attribute implements.
        Parameters:
        attribute - Attribute to analyze.
        Returns:
        High-level type interface of this attribute.
      • getTypeString

        public static java.lang.String getTypeString​(XAttribute attribute)
        For the given attribute, derives the standardized string describing the attributes specific type (used, e.g., for serialization).
        Parameters:
        attribute - Attribute to extract type string from.
        Returns:
        String representation of the attribute's specific type.
      • derivePrototype

        public static XAttribute derivePrototype​(XAttribute instance)
        Derives a prototype for the given attribute. This prototype attribute will be equal in all respects, expect for the value of the attribute. This value will be set to a default value, depending on the specific type of the given attribute.
        Parameters:
        instance - Attribute to derive prototype from.
        Returns:
        The derived prototype attribute.
      • composeAttribute

        public static XAttribute composeAttribute​(XFactory factory,
                                                  java.lang.String key,
                                                  java.lang.String value,
                                                  java.lang.String type,
                                                  XExtension extension)
        Composes the appropriate attribute type from the string-based information found, e.g., in XML serializations.
        Parameters:
        factory - Factory to use for creating the attribute.
        key - Key of the attribute.
        value - Value of the attribute.
        type - Type string of the attribute.
        extension - Extension of the attribute (can be null).
        Returns:
        An appropriate attribute.
      • extractExtensions

        public static java.util.Set<XExtension> extractExtensions​(java.util.Map<java.lang.String,​XAttribute> attributeMap)
        Static helper method for extracting all extensions from an attribute map.
        Parameters:
        attributeMap - The attribute map from which to extract extensions.
        Returns:
        The set of extensions in the attribute map.