Package org.jibx.custom.classes
Class ClassCustom
java.lang.Object
org.jibx.custom.classes.CustomBase
org.jibx.custom.classes.SharedNestingBase
org.jibx.custom.classes.NestingBase
org.jibx.custom.classes.ClassCustom
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringElement name in XML customization file.static final intstatic final intstatic final intstatic final intprivate final ArrayListprivate IClassprivate Stringprivate Stringprivate Stringprivate QNameprivate Stringprivate String[]private Stringprivate intprivate String[]private booleanprivate InsertionOrderedMapprivate Stringprivate String[]private String[]private Stringprivate Stringprivate QNameprivate booleanstatic final StringArrayEnumeration of allowed attribute namesstatic final EnumSetFields inherited from class org.jibx.custom.classes.NestingBase
ATTRIBUTE_STYLE_INTEGER, ATTRIBUTE_VALUE_STYLE, ELEMENT_STYLE_INTEGER, ELEMENT_VALUE_STYLE, s_valueStyleEnumFields inherited from class org.jibx.custom.classes.CustomBase
CAMEL_CASE_NAMES, DERIVE_BY_PACKAGE, DERIVE_FIXED, DERIVE_NONE, DOTTED_NAMES, HYPHENATED_NAMES, REQUIRE_ALL, REQUIRE_NONE, REQUIRE_OBJECTS, REQUIRE_PRIMITIVES, s_namespaceStyleEnum, s_nameStyleEnum, s_requireEnum, UNDERSCORED_NAMES, UPPER_CAMEL_CASE_NAMES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddChild(CustomBase child) Add child.voidapply(IClassLocator icl) Apply customizations to class to fill out members.private static voidclassifyNames(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).private StringfindPropertyType(IClassItem gmeth, IClassItem smeth, IClassLocator icl) Find the most specific type for a property based on the access methods.Get list of children.Get actual class information.Get the type name to be used when creating an instance of this class.Get deserializer method.Get the element name to be used for this class in a concrete mapping.Get the qualified element name to be used for this class in a concrete mapping.Get the method used to retrieve the text value for an enum class.String[]Get list of names to be excluded from class representation.Get the factory method to be used when creating an instance of this class.intgetForm()Get the representation code.private StringForm get text method.String[]Get list of names to be included in class representation.Get customization information for a member by name.Get collection of members in class.getName()Get fully-qualified class name.Get serializer method.Get simple class name.Get the type name to be used for this class in an abstract mapping.Get the qualified type name to be used for this class in an abstract mapping.booleanCheck if abstract mapping required for class.booleanCheck if this is a directly instantiable class (not an interface, and not abstract)booleanCheck if concrete mapping required for class.booleanCheck if class represents a simple text value.booleanCheck for superclass to be included in binding.private MapBuild map from member names to fields.private MapmapPropertyReadMethods(IClassItem[] methods, Set inclset, Set exclset) Build map from member names to read access methods.private MapmapPropertyWriteMethods(IClassItem[] methods, Set inclset, Set exclset) Build map from member names to write access methods.private voidpreSet(IUnmarshallingContext uctx) Make sure all attributes are defined.voidsetCreateType(String type) Set the type name to be used when creating an instance of this class.private voidsetFormText(String text, IUnmarshallingContext ictx) Form set text method.private static String[]stripNames(String[] names) Utility method to strip any leading non-alphanumeric characters from an array of name strings.Methods inherited from class org.jibx.custom.classes.NestingBase
getStripPrefixes, getStripSuffixes, getValueStyle, isForceMapping, isForceStructureNames, isMapAbstract, isPropertyAccess, isWrapCollections, setMapAbstract, setValueStyleMethods inherited from class org.jibx.custom.classes.SharedNestingBase
convertName, getFormatterClass, getNamespace, getNamespaceStyle, getNameStyle, getSpecifiedNamespace, isObjectRequired, isPrimitiveRequired, isUseJavaDocs, setNamespace, setNamespaceStyle, setNameStyleMethods inherited from class org.jibx.custom.classes.CustomBase
convertName, deriveItemName, deriveNamespace, getContainingObject, getGlobal, getParent, packageOfType, packageToNamespace, validateAttributes
-
Field Details
-
s_allowedAttributes
Enumeration of allowed attribute names -
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
-
m_name
-
m_elementName
-
m_typeName
-
m_createType
-
m_factoryMethod
-
m_enumValueMethod
-
m_form
private int m_form -
m_includes
-
m_excludes
-
m_useSuper
private boolean m_useSuper -
m_requireds
-
m_optionals
-
m_serializer
-
m_deserializer
-
m_children
-
m_isApplied
private boolean m_isApplied -
m_typeQName
-
m_elementQName
-
m_classInformation
-
m_memberMap
-
-
Constructor Details
-
ClassCustom
ClassCustom(NestingBase parent, String name) Constructor.- Parameters:
parent-name- class simple name (without package)
-
-
Method Details
-
preSet
Make sure all attributes are defined.- Parameters:
uctx- unmarshalling context
-
getName
Get fully-qualified class name.- Returns:
- class name
-
getSimpleName
Get simple class name.- Returns:
- class name
-
getElementName
Get the element name to be used for this class in a concrete mapping.- Returns:
- element name
-
getElementQName
Get the qualified element name to be used for this class in a concrete mapping.- Returns:
- element name
-
getTypeName
Get the type name to be used for this class in an abstract mapping.- Returns:
- type name
-
getCreateType
Get the type name to be used when creating an instance of this class.- Returns:
- type name
-
setCreateType
Set the type name to be used when creating an instance of this class.- Parameters:
type-
-
getSerializer
Get serializer method.- Returns:
- serializer
-
getDeserializer
Get deserializer method.- Returns:
- deserializer
-
getEnumValueMethod
Get the method used to retrieve the text value for an enum class.- Returns:
- method name
-
getFactoryMethod
Get the factory method to be used when creating an instance of this class.- Returns:
- method name
-
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_representationEnumenumeration
-
getExcludes
Get list of names to be excluded from class representation.- Returns:
- excludes (
nullif none)
-
getIncludes
Get list of names to be included in class representation.- Returns:
- includes (
nullif none)
-
isUseSuper
public boolean isUseSuper()Check for superclass to be included in binding.- Returns:
trueif superclass included,falseif not
-
isConcreteClass
public boolean isConcreteClass()Check if this is a directly instantiable class (not an interface, and not abstract)- Returns:
trueif instantiable,falseif 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
Get list of children.- Returns:
- list
-
addChild
Add child.- Parameters:
child-
-
setFormText
Form set text method. This is intended for use during unmarshalling. TODO: add validation- Parameters:
text-ictx-
-
getFormText
Form get text method. This is intended for use during marshalling.- Returns:
- text
-
mapPropertyReadMethods
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 (nullif not specified)exclset- set of member names to be excluded (nullif not specified, ignored if inclset is non-null)- Returns:
- map
-
mapPropertyWriteMethods
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 (nullif not specified)exclset- set of member names to be excluded (nullif 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 namessuffs- suffixes to be stripped in deriving namesinclset- set of member names to be included (nullif not specified)exclset- set of member names to be excluded (nullif not specified, ignored if inclset is non-null)- Returns:
- map
-
findPropertyType
Find the most specific type for a property based on the access methods.- Parameters:
gmeth- read access method (nullif not defined)smeth- write access method (nullif not defined)icl-- Returns:
- most specific type name
-
stripNames
Utility method to strip any leading non-alphanumeric characters from an array of name strings.- Parameters:
names- (nullif none)- Returns:
- array of stripped names (
nullif none)
-
classifyNames
Classify an array of names as elements or attributes, based on leading flag characters ('@' for an attribute, 'invalid input: '<'' for an element).- Parameters:
names- (nullif none)elems- set of element namesattrs- set of attribute names
-
apply
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. -
getMember
Get customization information for a member by name. This method may only be called afterapply(IClassLocator).- Parameters:
name-- Returns:
- customization, or
nullif none
-
getClassInformation
Get actual class information. This method may only be called afterapply(IClassLocator).- Returns:
- class information
-
getMembers
Get collection of members in class.- Returns:
- members
-