Package org.jibx.binding.model
Class BindingHolder
- java.lang.Object
-
- org.jibx.binding.model.BindingHolder
-
public class BindingHolder extends java.lang.ObjectExternal data for a binding definition. Along with the actual mapping definitions, this tracks namespace references and usages.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description private BindingElementm_bindingActual binding definition.private booleanm_elementDefaultNamespace used by default for elements flag.private java.lang.Stringm_fileNameName for file to be written from binding.private booleanm_finishedBinding finalized flag.private LazyListm_mappingsList of mapping definitions in binding.private java.lang.Stringm_namespaceNamespace URI associated with this binding (nullif no-namespace binding).private booleanm_namespaceUsedBinding namespace used for element or attribute flag.private BindingOrganizerm_organizerOrganizer managing this holder.private java.lang.Stringm_prefixPrefix to be used for this namespace (nullif unspecified).private booleanm_pullUpNamespacesPull namespaces used in element or attribute names up to root binding flag (set when a type reference to this binding is seen).private InsertionOrderedSetm_referencedNamespacesSet of namespaces referenced in qualified names in this bindings.private InsertionOrderedSetm_usedNamespacesSet of namespaces used in element or attribute names in binding.
-
Constructor Summary
Constructors Constructor Description BindingHolder(java.lang.String uri, boolean dflt, BindingOrganizer dir)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFormat(FormatElement format)Add a format definition to the binding.voidaddMapping(MappingElementBase mapping)Add a mapping definition to the binding.voidaddNamespaceUsage(java.lang.String uri)Add usage of namespace for an element or attribute name in binding.voidaddTypeNameReference(java.lang.String uri, java.lang.Object obj)Add reference from this binding to a type name defined in the same or another binding.private voidcheckModifiable()Internal check method to verify that the binding is still modifiable.(package private) voidfinish(java.util.Collection formats, java.util.Collection includes, java.util.Set outernss, java.util.Map nsdfltpref, java.util.Map nsfrcdpref)Finishes building the binding.(package private) voidforcePullUpNamespaces()Force namespaces to be pulled up to the root binding.BindingElementgetBinding()Get the binding element.java.lang.StringgetElementDefaultNamespace()Get default namespace URI for elements defined in this binding.java.lang.StringgetFileName()Get the file name to be used for this file.intgetMappingCount()Get the number of mapping definitions present in this binding.java.lang.StringgetNamespace()Get namespace URI associated with this binding.java.lang.StringgetPrefix()Get namespace prefix for this binding.(package private) java.util.SetgetReferencedNamespaces()Get a set of all the namespace URIs referenced by a qualified name in this binding.BindingHoldergetRequiredBinding(java.lang.Object obj)Get the binding associated with a particular control object.(package private) java.util.SetgetUsedNamespaces()Get a set of all the namespace URIs used by element or attributes names in this binding.(package private) booleanisBindingNamespaceUsed()Check if the namespace associated with this binding is actually used by any element or attribute definitions in the binding.(package private) booleanisNamespaceElementDefault()Check if the namespace associated with this binding should be used as the default for definitions in the binding.(package private) booleanisPullUpNamespaces()Check if used namespaces need to be pulled up to the root binding.java.util.IteratoriterateMappings()Get the number of mapping definitions present in this binding.voidsetBinding(BindingElement bind)Set the binding element.voidsetFileName(java.lang.String name)Set the file name to be used for this file.(package private) voidsetPrefix(java.lang.String prefix)Set namespace prefix for this binding.
-
-
-
Field Detail
-
m_organizer
private final BindingOrganizer m_organizer
Organizer managing this holder.
-
m_namespace
private final java.lang.String m_namespace
Namespace URI associated with this binding (nullif no-namespace binding).
-
m_elementDefault
private final boolean m_elementDefault
Namespace used by default for elements flag.
-
m_referencedNamespaces
private final InsertionOrderedSet m_referencedNamespaces
Set of namespaces referenced in qualified names in this bindings.
-
m_usedNamespaces
private final InsertionOrderedSet m_usedNamespaces
Set of namespaces used in element or attribute names in binding.
-
m_prefix
private java.lang.String m_prefix
Prefix to be used for this namespace (nullif unspecified).
-
m_binding
private BindingElement m_binding
Actual binding definition.
-
m_pullUpNamespaces
private boolean m_pullUpNamespaces
Pull namespaces used in element or attribute names up to root binding flag (set when a type reference to this binding is seen).
-
m_namespaceUsed
private boolean m_namespaceUsed
Binding namespace used for element or attribute flag.
-
m_finished
private boolean m_finished
Binding finalized flag.
-
m_fileName
private java.lang.String m_fileName
Name for file to be written from binding.
-
m_mappings
private final LazyList m_mappings
List of mapping definitions in binding.
-
-
Constructor Detail
-
BindingHolder
public BindingHolder(java.lang.String uri, boolean dflt, BindingOrganizer dir)Constructor. TODO: add a way of handling pregenerated bindings, so that namespaces can be properly tracked?- Parameters:
uri- (nullif no-namespace binding)dflt- namespace is default for elements flagdir- directory managing this holder
-
-
Method Detail
-
getNamespace
public java.lang.String getNamespace()
Get namespace URI associated with this binding.- Returns:
- namespace (
nullif no-namespace)
-
getPrefix
public java.lang.String getPrefix()
Get namespace prefix for this binding.- Returns:
- prefix (
nullif not specified)
-
setPrefix
void setPrefix(java.lang.String prefix)
Set namespace prefix for this binding. Method used by the binding organizer code to configure binding.- Parameters:
prefix- (nullif not specified)
-
getElementDefaultNamespace
public java.lang.String getElementDefaultNamespace()
Get default namespace URI for elements defined in this binding.- Returns:
- namespace (
nullif no-namespace)
-
getBinding
public BindingElement getBinding()
Get the binding element.- Returns:
- binding
-
setBinding
public void setBinding(BindingElement bind)
Set the binding element. This method is provided so that the generated binding element can be replaced by one which has been read in from a file after being written.- Parameters:
bind-
-
addFormat
public void addFormat(FormatElement format)
Add a format definition to the binding. In actual generation, formats may be moved to a root binding definition.- Parameters:
format-
-
addNamespaceUsage
public void addNamespaceUsage(java.lang.String uri)
Add usage of namespace for an element or attribute name in binding.- Parameters:
uri- referenced namespace URI (nullif no-namespace)
-
addTypeNameReference
public void addTypeNameReference(java.lang.String uri, java.lang.Object obj)Add reference from this binding to a type name defined in the same or another binding.- Parameters:
uri- namespace URI for type nameobj- object associated with referenced binding
-
checkModifiable
private void checkModifiable()
Internal check method to verify that the binding is still modifiable.
-
getFileName
public java.lang.String getFileName()
Get the file name to be used for this file.- Returns:
- name (
nullif not set)
-
setFileName
public void setFileName(java.lang.String name)
Set the file name to be used for this file.- Parameters:
name-
-
addMapping
public void addMapping(MappingElementBase mapping)
Add a mapping definition to the binding.- Parameters:
mapping-
-
getMappingCount
public int getMappingCount()
Get the number of mapping definitions present in this binding.- Returns:
- count
-
iterateMappings
public java.util.Iterator iterateMappings()
Get the number of mapping definitions present in this binding.- Returns:
- count
-
getRequiredBinding
public BindingHolder getRequiredBinding(java.lang.Object obj)
Get the binding associated with a particular control object.- Parameters:
obj- object associated with binding (can be namespace URI, if only one binding per namespace)- Returns:
- binding holder
-
getReferencedNamespaces
java.util.Set getReferencedNamespaces()
Get a set of all the namespace URIs referenced by a qualified name in this binding. Method used by the binding organizer code to configure binding.- Returns:
- live namespace list
-
getUsedNamespaces
java.util.Set getUsedNamespaces()
Get a set of all the namespace URIs used by element or attributes names in this binding. Method used by the binding organizer code to configure binding.- Returns:
- live namespace list
-
forcePullUpNamespaces
void forcePullUpNamespaces()
Force namespaces to be pulled up to the root binding. Method used by the binding organizer code to configure binding.
-
isPullUpNamespaces
boolean isPullUpNamespaces()
Check if used namespaces need to be pulled up to the root binding. Method used by the binding organizer code to configure binding.- Returns:
- pull up flag
-
isNamespaceElementDefault
boolean isNamespaceElementDefault()
Check if the namespace associated with this binding should be used as the default for definitions in the binding. Method used by the binding organizer code to configure binding.- Returns:
- pull up flag
-
isBindingNamespaceUsed
boolean isBindingNamespaceUsed()
Check if the namespace associated with this binding is actually used by any element or attribute definitions in the binding. Method used by the binding organizer code to configure binding.- Returns:
- pull up flag
-
finish
void finish(java.util.Collection formats, java.util.Collection includes, java.util.Set outernss, java.util.Map nsdfltpref, java.util.Map nsfrcdpref)Finishes building the binding. Method used by the binding organizer code to configure binding.- Parameters:
formats- format elements to be used in bindingincludes- include elements to be used in bindingouternss- namespaces inherited by this bindingnsdfltpref- map from namespace URI to default prefix when used in a namespace declaration within the binding (nullvalues for namespace used as the default)nsfrcdpref- map from namespace URI to prefix when used in a binding namespace definition (prefix must be non-nulland non-empty)
-
-