public class BindGen
extends java.lang.Object
public
access, they are
intended for use only by the JiBX developers and may change from one release to the next. To make use of this class
from your own code, call the main(String[])
method with an appropriate argument list.Modifier and Type | Field and Description |
---|---|
private BindingOrganizer |
m_directory
Directory for bindings being built.
|
private java.util.Set |
m_directSet
Set of class names to be handled directly.
|
private java.util.Map |
m_elementNamesMap
Map from namespace URI to
UniqueNameSet for element names. |
private java.util.Set |
m_formatSet
Set of class names possibly requiring format definitions.
|
private GlobalCustom |
m_global
Binding generation customizations.
|
private java.util.Set |
m_ignoreSet
Set of class names to be ignored.
|
private java.util.Set |
m_includeSet
Set of class names to be included.
|
private java.util.Map |
m_mappingDetailsMap
Map from fully-qualified class name to mapping details.
|
private java.util.Set |
m_superSet
Set of class names subclassed by other classes in binding.
|
private java.lang.String |
m_targetPackage
Target package for binding code generation.
|
private java.util.Map |
m_typeNamesMap
Map from namespace URI to
UniqueNameSet for type names. |
Constructor and Description |
---|
BindGen(GlobalCustom glob)
Create a generator based on a particular set of customizations.
|
Modifier and Type | Method and Description |
---|---|
BindingHolder |
addBinding(java.lang.String uri,
boolean dflt)
Get the binding definition for a namespace, creating a new one if not previously defined.
|
private void |
addMapping(java.lang.String type,
BindingMappingDetail detail)
Add the <mapping> definition for a class to a binding.
|
private BindingMappingDetail |
addMappingDetails(java.lang.Boolean abstr,
QName ename,
java.lang.String type)
Add the details for mapping a class.
|
private void |
addMemberBindings(ClassCustom cust,
java.util.Map exmethmap,
java.util.Map inmethmap,
NestingElementBase parent,
BindingHolder hold)
Add binding details for the actual members of a class, excluding any members which have been handled separately.
|
private void |
addReferencedMappings(ReferenceCountMap refmap)
Add mapping details for classes referenced more than once, or classes with mapping forced.
|
void |
addRootUris(java.util.Collection uris)
Adds a collection of namespace URIs to be referenced at root binding level.
|
boolean |
checkInclude(java.lang.String type)
Check if a class needs to be included in the binding.
|
private MappingElement |
createMapping(java.lang.String type,
ClassCustom cust)
Create and initialize a <mapping> element.
|
void |
defineCollection(java.lang.String itype,
java.lang.String iname,
CollectionElement coll,
BindingHolder hold)
Define the details of a collection binding.
|
void |
expandReferences(java.lang.String type,
ReferenceCountMap refmap)
Expand all references from a class.
|
private void |
fillStructure(ClassCustom cust,
ValueCustom memb,
java.util.Map inmethmap,
StructureElement struct,
BindingHolder hold)
Add binding details for the full representation of a class.
|
private void |
findReferences(java.util.List classes,
ReferenceCountMap refmap)
Find closure of references from a supplied list of classes.
|
BindingHolder |
finish(java.lang.String name)
Complete the generated bindings.
|
private void |
fixBaseClasses()
Fix the base classes that are to be used as extension types.
|
private QName |
fixElementName(QName qname)
Fix element local name to be unique within the appropriate namespace.
|
private QName |
fixQName(QName qname,
java.util.Map map)
Fix local name to be unique within the appropriate namespace for a category of names.
|
private QName |
fixTypeName(QName qname)
Fix type local name to be unique within the appropriate namespace.
|
private void |
flagMultipleReferences(ReferenceCountMap refmap)
Flag classes referenced more than once to be handled with <mapping> definitions.
|
void |
generate(java.lang.Boolean abstr,
java.util.List classes)
Generate binding(s) for a list of classes.
|
private void |
generateFormats()
Generate any required format definitions.
|
private void |
generateMappings(java.util.List classes)
Generate mappings for a list of classes.
|
private void |
generateReferencedMappings(ReferenceCountMap refmap)
Generate the mapping definitions for classes referenced more than once.
|
void |
generateSpecified(java.util.ArrayList qnames,
java.util.List concrs,
java.util.List abstrs)
Generate binding(s) for lists of classes.
|
BindingHolder |
getBinding(java.lang.String uri)
Get the binding definition for a namespace, which must already have been created.
|
BindingMappingDetail |
getMappingDetail(java.lang.String type)
Get the mapping details for a class.
|
private boolean |
isQNameUsed(QName qname,
java.util.Map map)
Check if a qualified name is already defined within a category of names.
|
boolean |
isValueClass(java.lang.String type)
Check if a class represents a simple value.
|
static void |
main(java.lang.String[] args)
Run the binding generation using command line parameters.
|
private void |
setTypes(ValueCustom memb,
StructureElementBase struct)
Set creation information for structure binding component.
|
java.util.List |
validateFiles(java.io.File dir,
IClassLocator loc,
BindingHolder root)
Write and validate the generated binding definition files.
|
private final GlobalCustom m_global
private final java.util.Set m_includeSet
private final java.util.Set m_ignoreSet
private final java.util.Set m_directSet
private final java.util.Set m_superSet
private final java.util.Set m_formatSet
private final java.util.Map m_mappingDetailsMap
private final java.util.Map m_typeNamesMap
UniqueNameSet
for type names.private final java.util.Map m_elementNamesMap
UniqueNameSet
for element names.private java.lang.String m_targetPackage
private BindingOrganizer m_directory
public BindGen(GlobalCustom glob)
glob
- public boolean isValueClass(java.lang.String type)
type
- fully qualified class nametrue
if simple value, false
if notpublic boolean checkInclude(java.lang.String type)
true
if any member is ultimately found with a simple value.type
- fully qualified class nametrue
if class to be included in binding, false
if it should be skippedpublic void expandReferences(java.lang.String type, ReferenceCountMap refmap)
type
- fully qualified class namerefmap
- reference count mapprivate void setTypes(ValueCustom memb, StructureElementBase struct)
memb
- struct
- public void defineCollection(java.lang.String itype, java.lang.String iname, CollectionElement coll, BindingHolder hold)
itype
- item typeiname
- item namecoll
- hold
- private void addMemberBindings(ClassCustom cust, java.util.Map exmethmap, java.util.Map inmethmap, NestingElementBase parent, BindingHolder hold)
cust
- class customization informationexmethmap
- map from property method names to be excluded to the corresponding property customizationsinmethmap
- map from property method names included in binding to the corresponding property customizations
(populated by this method, null
if not needed)parent
- containing binding componenthold
- binding holderprivate void fillStructure(ClassCustom cust, ValueCustom memb, java.util.Map inmethmap, StructureElement struct, BindingHolder hold)
cust
- class customization informationmemb
- member customization information (null
if implicit reference, rather than member)inmethmap
- map from property method names included in binding to the corresponding property customizations,
(needed in case of interface or overridden methods; populated by this method, null
if not needed)struct
- structure element referencing the classhold
- binding holderprivate void addMapping(java.lang.String type, BindingMappingDetail detail)
type
- fully qualified class namedetail
- mapping detailsprivate MappingElement createMapping(java.lang.String type, ClassCustom cust)
type
- cust
- private BindingMappingDetail addMappingDetails(java.lang.Boolean abstr, QName ename, java.lang.String type)
abstr
- force abstract mapping flagename
- element name for concrete mapping (null
if unspecified)type
- fully-qualified class nameprivate boolean isQNameUsed(QName qname, java.util.Map map)
qname
- requested qualified name (null
allowed, always returns false
)map
- namespace URI to UniqueNameSet
map for categorytrue
if used, false
if notprivate QName fixQName(QName qname, java.util.Map map)
qname
- requested qualified name (null
allowed, always returns null
)map
- namespace URI to UniqueNameSet
map for categoryprivate QName fixElementName(QName qname)
qname
- requested qualified name (null
allowed, always returns null
)private QName fixTypeName(QName qname)
qname
- requested qualified name (null
allowed, always returns null
)private void findReferences(java.util.List classes, ReferenceCountMap refmap)
classes
- refmap
- private void flagMultipleReferences(ReferenceCountMap refmap)
refmap
- private void addReferencedMappings(ReferenceCountMap refmap)
refmap
- private void generateReferencedMappings(ReferenceCountMap refmap)
refmap
- private void generateMappings(java.util.List classes)
classes
- private void fixBaseClasses()
private void generateFormats()
public void generate(java.lang.Boolean abstr, java.util.List classes)
abstr
- force abstract mapping flag (use both abstract and concrete if null
)classes
- class listpublic void generateSpecified(java.util.ArrayList qnames, java.util.List concrs, java.util.List abstrs)
qnames
- list of names for concrete mappingsconcrs
- list of classes to be given concrete mappingsabstrs
- list of classes to be given abstract mappingspublic BindingMappingDetail getMappingDetail(java.lang.String type)
generate(Boolean, List)
method has been called.type
- fully-qualified class namenull
if nonepublic BindingHolder getBinding(java.lang.String uri)
generate(Boolean, List)
method has been called. It delegates to the
BindingOrganizer
implementation.uri
- public void addRootUris(java.util.Collection uris)
uris
- public BindingHolder addBinding(java.lang.String uri, boolean dflt)
generate(Boolean, List)
method has been called. It delegates to the
BindingOrganizer
implementation.uri
- dflt
- namespace is default for elements in binding flagpublic BindingHolder finish(java.lang.String name)
name
- file name for root or singleton binding definitionpublic java.util.List validateFiles(java.io.File dir, IClassLocator loc, BindingHolder root) throws java.io.IOException, JiBXException
dir
- target directory (bindings not written if null
)loc
- class locator for binding validation (ignored if no target directory supplied)root
- holder for root binding definitionnull
if validation errorjava.io.IOException
JiBXException
public static void main(java.lang.String[] args) throws JiBXException, java.io.IOException
args
- JiBXException
java.io.IOException