public class BindingElement extends NestingElementBase
Modifier and Type | Class and Description |
---|---|
static class |
BindingElement.UnmarshalWrapper
Inner class as wrapper for binding element on unmarshalling.
|
Modifier and Type | Field and Description |
---|---|
static int |
BOTH_BINDING |
static int |
IN_BINDING |
private boolean |
m_addConstructors
Add default constructors where needed flag.
|
private java.net.URL |
m_baseUrl
Base URL for use with relative include paths.
|
private java.util.ArrayList |
m_children
List of child elements.
|
private java.lang.String |
m_direction
Binding direction.
|
private boolean |
m_forceClasses
Generate souce tracking interface flag.
|
private boolean |
m_forwardReferences
Support forward references to IDs flag.
|
private java.util.Set |
m_idClassSet
Set of class names which can be referenced by ID.
|
private java.util.Map |
m_includeBindings
Map from include path to actual binding.
|
private java.util.Set |
m_includePaths
Set of paths for includes.
|
private boolean |
m_inputBinding
Input binding flag.
|
private int |
m_majorVersion
Major version of binding.
|
private int |
m_minorVersion
Minor version of binding.
|
private java.lang.String |
m_name
Binding name.
|
private java.util.ArrayList |
m_namespaceDeclares
List of namespace declarations to be added on output (lazy create,
null if none). |
private boolean |
m_outputBinding
Output binding flag.
|
private boolean |
m_precompiled
Precompiled binding flag.
|
private java.util.Set |
m_precompiledPaths
Set of paths for precompiled includes.
|
private java.lang.String |
m_targetPackage
Package for generated context factory.
|
private boolean |
m_trackSource
Generate souce tracking interface flag.
|
private boolean |
m_trimWhitespace
Trim whitespace for simple values (schema compatibility) flag.
|
static int |
OUT_BINDING |
static StringArray |
s_allowedAttributes
Enumeration of allowed attribute names
|
(package private) static EnumSet |
s_directionEnum |
BINDING_ELEMENT, COLLECTION_ELEMENT, ELEMENT_NAMES, FORMAT_ELEMENT, INCLUDE_ELEMENT, INPUT_ELEMENT, MAPPING_ELEMENT, NAMESPACE_ELEMENT, OUTPUT_ELEMENT, SPLIT_ELEMENT, STRUCTURE_ELEMENT, TEMPLATE_ELEMENT, VALUE_ELEMENT
Constructor and Description |
---|
BindingElement()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addIdClass(IClass clas)
Add a class defined with a ID value.
|
void |
addIncludeBinding(java.lang.String path,
BindingElement bind)
Add binding accessible to includes.
|
boolean |
addIncludePath(java.lang.String path,
boolean precomp)
Add include path to set processed.
|
void |
addNamespaceDecl(java.lang.String prefix,
java.lang.String uri)
Add namespace declaration for output when marshalling.
|
void |
addTopChild(java.lang.Object child)
Add top-level child element.
|
private static FormatElement |
buildFormat(java.lang.String name,
java.lang.String type,
boolean use,
java.lang.String sname,
java.lang.String dname,
java.lang.String dflt) |
private void |
defineBaseFormat(FormatElement format,
DefinitionContext dctx,
ValidationContext vctx)
Define a built-in format.
|
java.net.URL |
getBaseUrl()
Get base URL for relative include paths.
|
int |
getDefaultStyle()
Get default style value for child components.
|
BindingElement |
getExistingIncludeBinding(java.net.URL url)
Get existing included binding.
|
BindingElement |
getIncludeBinding(java.net.URL url,
BindingElement root,
ValidationContext vctx)
Get included binding.
|
int |
getMajorVersion()
Get major version number.
|
int |
getMinorVersion()
Get minor version number.
|
java.lang.String |
getName()
Get binding name.
|
java.lang.String |
getTargetPackage()
Get package for generated context factory class.
|
boolean |
hasAttribute() |
boolean |
hasContent() |
boolean |
isAddConstructors()
Check if default constructor generation is enabled.
|
boolean |
isForceClasses()
Check if marshaller/unmarshaller class creation for top-level non-base
abstract mappings is forced.
|
boolean |
isForward()
Check if forward references to IDs must be supported in XML.
|
boolean |
isIdClass(java.lang.String name)
Check if a class can be referenced by ID.
|
boolean |
isInBinding()
Check if this binding component applies for unmarshalling XML.
|
boolean |
isOptional() |
boolean |
isOutBinding()
Check if this binding component applies for marshalling XML.
|
boolean |
isPrecompiled()
Check if a precompiled binding.
|
boolean |
isTrackSource()
Check if source position tracking enabled for unmarshalling.
|
boolean |
isTrimWhitespace()
Check if whitespace should be trimmed from simple values.
|
static ValidationContext |
newValidationContext()
Create a default validation context.
|
private void |
preGet(IMarshallingContext ictx)
Marshalling hook method to add namespace declarations to <binding>
element.
|
private void |
preSet(IUnmarshallingContext ictx)
Make sure all attributes are defined.
|
void |
prevalidate(ValidationContext vctx)
Prevalidate all attributes of element in isolation.
|
static BindingElement |
readBinding(java.io.InputStream is,
java.lang.String fname,
BindingElement contain,
boolean precomp,
ValidationContext vctx)
Read a binding definition (possibly as an include) to construct binding
model.
|
static BindingElement |
readBinding(java.io.InputStream is,
java.lang.String fname,
ValidationContext vctx)
Read a binding definition to construct binding model.
|
void |
runValidation(boolean full,
ValidationContext vctx)
Run the actual validation of a binding model.
|
void |
runValidation(ValidationContext vctx)
Run the actual validation of a binding model.
|
void |
setAddConstructors(boolean add)
Set default constructor generation.
|
void |
setBaseUrl(java.net.URL base)
Set base URL for relative include paths.
|
private void |
setDirection()
Set the correct direction text.
|
void |
setForceClasses(boolean force)
Set force marshaller/unmarshaller class creation for top-level non-base
abstract mappings.
|
void |
setForward(boolean forward)
Set forward references to IDs be supported in XML.
|
void |
setInBinding(boolean in)
Set binding component applies for unmarshalling XML.
|
void |
setMajorVersion(int ver)
Set major version number.
|
void |
setMinorVersion(int ver)
Set minor version number.
|
void |
setName(java.lang.String name)
Set binding name.
|
void |
setOutBinding(boolean out)
Set binding component applies for marshalling XML.
|
void |
setPrecompiled(boolean precomp)
Set precompiled binding flag.
|
void |
setTargetPackage(java.lang.String pack)
Set package for generated context factory class.
|
void |
setTrackSource(boolean track)
Set source position tracking for unmarshalling.
|
void |
setTrimWhitespace(boolean trim)
Set trim whitespace flag.
|
java.util.Iterator |
topChildIterator()
Get iterator for top-level child elements.
|
java.util.ArrayList |
topChildren()
Get list of top-level child elements.
|
static BindingElement |
validateBinding(java.lang.String name,
java.net.URL path,
java.io.InputStream is,
ValidationContext vctx)
Validate a binding definition.
|
addChild, childIterator, children, getDefinitions, getStyle, getStyleName, setDefinitions, setStyleName, validate
getComment, name, setComment, toString, type, validateAttributes
public static final StringArray s_allowedAttributes
public static final int IN_BINDING
public static final int OUT_BINDING
public static final int BOTH_BINDING
static final EnumSet s_directionEnum
private java.lang.String m_name
private java.lang.String m_direction
private boolean m_inputBinding
private boolean m_outputBinding
private boolean m_forwardReferences
private boolean m_trackSource
private boolean m_forceClasses
private boolean m_addConstructors
private boolean m_trimWhitespace
private int m_majorVersion
private int m_minorVersion
private java.lang.String m_targetPackage
private boolean m_precompiled
private java.net.URL m_baseUrl
private final java.util.Set m_includePaths
private final java.util.Set m_precompiledPaths
private final java.util.Map m_includeBindings
private final java.util.ArrayList m_children
private java.util.Set m_idClassSet
private java.util.ArrayList m_namespaceDeclares
null
if none).public void setName(java.lang.String name)
name
- binding definition namepublic java.lang.String getName()
public void setForward(boolean forward)
forward
- true
if forward references supported,
false
if notpublic boolean isForward()
true
if forward references required,
false
if notpublic void setTrackSource(boolean track)
track
- true
if source position tracking enabled,
false
if notpublic boolean isTrackSource()
true
if source position tracking enabled,
false
if notpublic void setForceClasses(boolean force)
force
- true
if class generation forced,
false
if notpublic boolean isForceClasses()
true
if class generation forced,
false
if notpublic void setAddConstructors(boolean add)
add
- true
if constructors should be added,
false
if notpublic boolean isAddConstructors()
true
if default constructor generation enabled,
false
if notpublic void setTrimWhitespace(boolean trim)
trim
- true
if whitespace should be trimmed from simple
values, false
if notpublic boolean isTrimWhitespace()
public int getMajorVersion()
public void setMajorVersion(int ver)
ver
- major versionpublic int getMinorVersion()
public void setMinorVersion(int ver)
ver
- minor versionpublic void setTargetPackage(java.lang.String pack)
pack
- generated context factory package (null
if
unspecified)public java.lang.String getTargetPackage()
null
if
unspecified)public void setBaseUrl(java.net.URL base)
base
- public java.net.URL getBaseUrl()
private void setDirection()
public void setOutBinding(boolean out)
out
- true
if binding supports output,
false
if notpublic boolean isOutBinding()
true
if binding supports output, false
if notpublic void setInBinding(boolean in)
in
- true
if binding supports input,
false
if notpublic boolean isInBinding()
true
if binding supports input, false
if notpublic boolean isPrecompiled()
true
if precompiled, false
if notpublic void setPrecompiled(boolean precomp)
precomp
- public boolean addIncludePath(java.lang.String path, boolean precomp)
path
- precomp
- precompiled binding flagtrue
if new path, false
if duplicatepublic BindingElement getIncludeBinding(java.net.URL url, BindingElement root, ValidationContext vctx) throws java.io.IOException, JiBXException
addIncludePath(String, boolean)
returns
true
, so that each unique included binding is only processed
once.url
- binding pathroot
- binding containing the includevctx
- validation contextjava.io.IOException
JiBXException
public BindingElement getExistingIncludeBinding(java.net.URL url)
url
- binding pathnull
public void addIncludeBinding(java.lang.String path, BindingElement bind)
path
- URL string identifying the binding (virtual path)bind
- public void addIdClass(IClass clas)
clas
- information for class with ID valuepublic boolean isIdClass(java.lang.String name)
name
- fully qualified name of classtrue
if class is bound with an ID,
false
if notpublic void addTopChild(java.lang.Object child)
child
- element to be added as child of this elementpublic java.util.ArrayList topChildren()
null
if nonepublic java.util.Iterator topChildIterator()
public void addNamespaceDecl(java.lang.String prefix, java.lang.String uri)
prefix
- namespace prefix (null
if none)uri
- namespace URI (non-null
)public boolean hasAttribute()
public boolean hasContent()
public boolean isOptional()
public int getDefaultStyle()
getDefaultStyle
in class NestingElementBase
private void preGet(IMarshallingContext ictx) throws java.io.IOException
ictx
- java.io.IOException
private void preSet(IUnmarshallingContext ictx) throws JiBXException
ictx
- unmarshalling contextJiBXException
- on unmarshalling errorpublic void prevalidate(ValidationContext vctx)
prevalidate
in class NestingElementBase
vctx
- validation contextprivate static FormatElement buildFormat(java.lang.String name, java.lang.String type, boolean use, java.lang.String sname, java.lang.String dname, java.lang.String dflt)
private void defineBaseFormat(FormatElement format, DefinitionContext dctx, ValidationContext vctx)
format
- dctx
- vctx
- public void runValidation(boolean full, ValidationContext vctx)
full
- run full validation flag (requires access to class files)vctx
- context for controlling validationpublic void runValidation(ValidationContext vctx)
vctx
- context for controlling validationpublic static BindingElement readBinding(java.io.InputStream is, java.lang.String fname, BindingElement contain, boolean precomp, ValidationContext vctx) throws JiBXException
is
- input stream for reading bindingfname
- name of input file (null
if unknown)contain
- containing binding (null
if none)precomp
- precompiled binding flagvctx
- validation context used during unmarshallingJiBXException
- on error in reading bindingpublic static BindingElement readBinding(java.io.InputStream is, java.lang.String fname, ValidationContext vctx) throws JiBXException
is
- input stream for reading bindingfname
- name of input file (null
if unknown)vctx
- validation context used during unmarshallingJiBXException
- on error in reading bindingpublic static BindingElement validateBinding(java.lang.String name, java.net.URL path, java.io.InputStream is, ValidationContext vctx) throws JiBXException
name
- binding definition namepath
- binding definition URLis
- input stream for reading bindingvctx
- validation context to record problemsnull
if error
in unmarshallingJiBXException
- on error in binding XML structurepublic static ValidationContext newValidationContext()