Class ClassCustom

All Implemented Interfaces:
IApply

public class ClassCustom extends NestingBase implements IApply
Class customization information. This supports direct class customizations (such as the corresponding element name, when building a concrete mapping) and also acts as a container for individual fields and/or properties.
Author:
Dennis M. Sosnoski
  • Field Details

    • s_allowedAttributes

      public static final StringArray s_allowedAttributes
      Enumeration of allowed attribute names
    • ELEMENT_NAME

      public static final String ELEMENT_NAME
      Element name in XML customization file.
      See Also:
    • FORM_DEFAULT

      public static final int FORM_DEFAULT
      See Also:
    • FORM_CONCRETE_MAPPING

      public static final int FORM_CONCRETE_MAPPING
      See Also:
    • FORM_ABSTRACT_MAPPING

      public static final int FORM_ABSTRACT_MAPPING
      See Also:
    • FORM_STRING

      public static final int FORM_STRING
      See Also:
    • s_representationEnum

      public static final EnumSet s_representationEnum
    • m_name

      private String m_name
    • m_elementName

      private String m_elementName
    • m_typeName

      private String m_typeName
    • m_createType

      private String m_createType
    • m_factoryMethod

      private String m_factoryMethod
    • m_enumValueMethod

      private String m_enumValueMethod
    • m_form

      private int m_form
    • m_includes

      private String[] m_includes
    • m_excludes

      private String[] m_excludes
    • m_useSuper

      private boolean m_useSuper
    • m_requireds

      private String[] m_requireds
    • m_optionals

      private String[] m_optionals
    • m_serializer

      private String m_serializer
    • m_deserializer

      private String m_deserializer
    • m_children

      private final ArrayList m_children
    • m_isApplied

      private boolean m_isApplied
    • m_typeQName

      private QName m_typeQName
    • m_elementQName

      private QName m_elementQName
    • m_classInformation

      private IClass m_classInformation
    • m_memberMap

      private InsertionOrderedMap m_memberMap
  • Constructor Details

    • ClassCustom

      ClassCustom(NestingBase parent, String name)
      Constructor.
      Parameters:
      parent -
      name - class simple name (without package)
  • Method Details

    • preSet

      private void preSet(IUnmarshallingContext uctx)
      Make sure all attributes are defined.
      Parameters:
      uctx - unmarshalling context
    • getName

      public String getName()
      Get fully-qualified class name.
      Returns:
      class name
    • getSimpleName

      public String getSimpleName()
      Get simple class name.
      Returns:
      class name
    • getElementName

      public String getElementName()
      Get the element name to be used for this class in a concrete mapping.
      Returns:
      element name
    • getElementQName

      public QName getElementQName()
      Get the qualified element name to be used for this class in a concrete mapping.
      Returns:
      element name
    • getTypeName

      public String getTypeName()
      Get the type name to be used for this class in an abstract mapping.
      Returns:
      type name
    • getCreateType

      public String getCreateType()
      Get the type name to be used when creating an instance of this class.
      Returns:
      type name
    • setCreateType

      public void setCreateType(String type)
      Set the type name to be used when creating an instance of this class.
      Parameters:
      type -
    • getSerializer

      public String getSerializer()
      Get serializer method.
      Returns:
      serializer
    • getDeserializer

      public String getDeserializer()
      Get deserializer method.
      Returns:
      deserializer
    • getEnumValueMethod

      public String getEnumValueMethod()
      Get the method used to retrieve the text value for an enum class.
      Returns:
      method name
    • getFactoryMethod

      public String getFactoryMethod()
      Get the factory method to be used when creating an instance of this class.
      Returns:
      method name
    • getTypeQName

      public QName getTypeQName()
      Get the qualified type name to be used for this class in an abstract mapping.
      Returns:
      type qname
    • getForm

      public int getForm()
      Get the representation code.
      Returns:
      value from s_representationEnum enumeration
    • getExcludes

      public String[] getExcludes()
      Get list of names to be excluded from class representation.
      Returns:
      excludes (null if none)
    • getIncludes

      public String[] getIncludes()
      Get list of names to be included in class representation.
      Returns:
      includes (null if none)
    • isUseSuper

      public boolean isUseSuper()
      Check for superclass to be included in binding.
      Returns:
      true if superclass included, false if not
    • isConcreteClass

      public boolean isConcreteClass()
      Check if this is a directly instantiable class (not an interface, and not abstract)
      Returns:
      true if instantiable, false if not
    • isSimpleValue

      public boolean isSimpleValue()
      Check if class represents a simple text value.
      Returns:
      text value flag
    • isAbstractMappingForced

      public boolean isAbstractMappingForced()
      Check if abstract mapping required for class.
      Returns:
      abstract mapping flag
    • isConcreteMappingForced

      public boolean isConcreteMappingForced()
      Check if concrete mapping required for class. If a 'form' setting is defined for the class it returns the flag based on that setting, and otherwise returns based on the nesting abstract mapping flag.
      Returns:
      abstract mapping flag
    • getChildren

      public List getChildren()
      Get list of children.
      Returns:
      list
    • addChild

      protected void addChild(CustomBase child)
      Add child.
      Parameters:
      child -
    • setFormText

      private void setFormText(String text, IUnmarshallingContext ictx)
      Form set text method. This is intended for use during unmarshalling. TODO: add validation
      Parameters:
      text -
      ictx -
    • getFormText

      private String getFormText()
      Form get text method. This is intended for use during marshalling.
      Returns:
      text
    • mapPropertyReadMethods

      private Map mapPropertyReadMethods(IClassItem[] methods, Set inclset, Set exclset)
      Build map from member names to read access methods. This assumes that each public, non-static, no-argument method which returns a value and has a name beginning with "get" or "is" is a property read access method. It maps the corresponding property name to the method, and returns the map.
      Parameters:
      methods -
      inclset - set of member names to be included (null if not specified)
      exclset - set of member names to be excluded (null if not specified, ignored if inclset is non-null)
      Returns:
      map
    • mapPropertyWriteMethods

      private Map mapPropertyWriteMethods(IClassItem[] methods, Set inclset, Set exclset)
      Build map from member names to write access methods. This assumes that each public, non-static, single-argument method which returns void and has a name beginning with "set" is a property write access method. It maps the corresponding property name to the method, and returns the map.
      Parameters:
      methods -
      inclset - set of member names to be included (null if not specified)
      exclset - set of member names to be excluded (null if not specified, ignored if inclset is non-null)
      Returns:
      map
    • mapFields

      private Map mapFields(IClassItem[] fields, String[] prefs, String[] suffs, Set inclset, Set exclset)
      Build map from member names to fields. This includes all non-static and non-transient fields of the class.
      Parameters:
      fields -
      prefs - prefixes to be stripped in deriving names
      suffs - suffixes to be stripped in deriving names
      inclset - set of member names to be included (null if not specified)
      exclset - set of member names to be excluded (null if not specified, ignored if inclset is non-null)
      Returns:
      map
    • findPropertyType

      private String findPropertyType(IClassItem gmeth, IClassItem smeth, IClassLocator icl)
      Find the most specific type for a property based on the access methods.
      Parameters:
      gmeth - read access method (null if not defined)
      smeth - write access method (null if not defined)
      icl -
      Returns:
      most specific type name
    • stripNames

      private static String[] stripNames(String[] names)
      Utility method to strip any leading non-alphanumeric characters from an array of name strings.
      Parameters:
      names - (null if none)
      Returns:
      array of stripped names (null if none)
    • classifyNames

      private static void classifyNames(String[] names, Set elems, Set attrs)
      Classify an array of names as elements or attributes, based on leading flag characters ('@' for an attribute, 'invalid input: '<'' for an element).
      Parameters:
      names - (null if none)
      elems - set of element names
      attrs - set of attribute names
    • apply

      public void apply(IClassLocator icl)
      Apply customizations to class to fill out members. The name handling gets tricky, because of the variety of options provided. The user can specify value names to be included and/or excluded for the class, and also value names to be treated as optional or required. If an 'includes' list is given, only the values on that list are processed from the class, along with any values with their own child elements. If an 'excludes' list is given, only the names not on that list are processed. If neither an 'includes' nor an 'excludes' list is present, all values defined by the class will be processed. It is an error if the same name occurs on both an 'excludes' list and any other list, or if a name on the 'excludes' list has a child element present. It is also an error if the same name occurs on both the 'optionals' and 'requireds' list. Each list name can also be flagged with a leading indicator character to say whether the value should be represented as an attribute ('@') or element ('invalid input: '<''). The order of child elements is also partially determined by the lists, with the 'includes' list processed first, then the 'requireds' list, then the 'optionals' list, then the child elements, then any values not yet processed.
      Specified by:
      apply in interface IApply
      Parameters:
      icl - class locator
    • getMember

      public ValueCustom getMember(String name)
      Get customization information for a member by name. This method may only be called after apply(IClassLocator).
      Parameters:
      name -
      Returns:
      customization, or null if none
    • getClassInformation

      public IClass getClassInformation()
      Get actual class information. This method may only be called after apply(IClassLocator).
      Returns:
      class information
    • getMembers

      public Collection getMembers()
      Get collection of members in class.
      Returns:
      members