org.enhydra.zeus.binding
Class BaseBinding

java.lang.Object
  |
  +--org.enhydra.zeus.binding.BaseBinding
Direct Known Subclasses:
BaseContainer, BaseProperty, ContainerProperty

public abstract class BaseBinding
extends java.lang.Object

Binding represents an arbitrary Java construct, and provides a representation-independent means of showing how a constraint (presumably from an XML Schema, DTD, Relax schema, etc.) maps to Java. It provides a layer of representation between the constraint representation and generated Java.

This implementation of Binding deals with the basic functionality of all bindings. It leaves specific binding implementations to deal with only their functionality.

Author:
Brett McLaughlin, Sean Ogle

Field Summary
protected  boolean isJavaSerializable
          Whether this binding is Java-serializable
protected  boolean isXMLRootElement
          Whether this is the XML root element
protected  java.lang.String javaCollectionClass
          The Java Collection class for this binding
protected  java.lang.String javaImplementationPackage
          The Java implementation package of the binding
protected  java.lang.String javaInterfacePackage
          The Java interface package of the binding
protected  java.lang.String javaName
          The Java name of the binding
protected  java.lang.String javaType
          The Java type of the binding
protected  java.lang.String javaVariableName
          The Java name of the binding that is a legal Java identifier.
protected  java.lang.String xmlName
          The XML name of the binding
protected  java.lang.String xmlNamespaceURI
          The XML namespace URI associated with the XML name of the binding
protected  java.lang.String xmlParentType
          The XML parent type for this binding
protected  java.lang.String xmlParentTypeNamespaceURI
          The XML namespace URI for this binding's XML parent type
protected  java.lang.String xmlType
          The XML type of the binding
protected  java.lang.String xmlTypeNamespaceURI
          The XML namespace URI associated with the XML type of the binding
 
Constructor Summary
BaseBinding()
           Default constructor.
 
Method Summary
 java.lang.String getJavaCollectionClass()
           This will return the Java collection class to use for this binding, if it is a collection.
 java.lang.String getJavaImplementationPackage()
           This will return the Java package name for this binding's implementation class.
 java.lang.String getJavaInterfacePackage()
           This will return the Java package name for this binding's interface class.
 java.lang.String getJavaName()
           This will return the Java name of the binding.
 java.lang.String getJavaType()
           This will return the Java type associated with the binding.
 java.lang.String getJavaVariableName()
           This will return the Java name that can be used for a variable name in generated code.
 java.lang.String getXMLName()
           This will return the XML name of the binding.
 java.lang.String getXMLNamespaceURI()
           The will return the XML namespace URI associated with the XML name of this binding.
 java.lang.String getXMLParentType()
           This will return the XML local name associated with the XML type of this binding's XML parent.
 java.lang.String getXMLParentTypeNamespaceURI()
           The will return the XML namespace URI associated with the XML type of this binding's XML parent.
 java.lang.String getXMLType()
           This will return the XML local name associated with the XML type of this binding.
 java.lang.String getXMLTypeNamespaceURI()
           The will return the XML namespace URI associated with the XML type of this binding.
 boolean isJavaSerializable()
           This will indicate whether this binding is Java-serializable (indicated by a boolean value of "true"), or not (indicated by a boolean value of "false").
 boolean isXMLRootElement()
           This indicates if this binding represents an XML element that is the root element of the document.
 void setIsJavaSerializable(boolean isJavaSerializable)
           This will set whether this binding should be a Java-serializable class.
 void setIsXMLRootElement(boolean isXMLRootElement)
           This sets whether this binding represents an XML element that is the root element of the document.
 void setJavaCollectionClass(java.lang.String javaCollectionClass)
           This will set the Java collection class to use for this binding, if it is a collection.
 void setJavaImplementationPackage(java.lang.String javaImplementationPackage)
           This will set the Java package for this class's implementation.
 void setJavaInterfacePackage(java.lang.String javaInterfacePackage)
           This will set the Java package for this class's interface.
 void setJavaName(java.lang.String javaName)
           The will set the name of the Java variable associated with this binding.
 void setJavaType(java.lang.String javaType)
           This will set the Java type for this binding.
 void setJavaVariableName(java.lang.String javaVariableName)
           This will set the Java name that can be used for a variable name in generated code.
 void setXMLName(java.lang.String xmlName)
           This will set the XML name of the binding.
 void setXMLNamespaceURI(java.lang.String xmlNamespaceURI)
           The will set the XML namespace URI associated with the XML name of this binding.
 void setXMLParentType(java.lang.String xmlParentType)
           This will set the XML local name associated with the XML type of this binding's XML parent.
 void setXMLParentTypeNamespaceURI(java.lang.String xmlParentTypeNamespaceURI)
           This will set the XML namespace URI associated with the XML type of this binding's XML parent.
 void setXMLType(java.lang.String xmlType)
           This will set the XML local name associated with the XML type of this binding.
 void setXMLTypeNamespaceURI(java.lang.String xmlTypeNamespaceURI)
           This will set the XML namespace URI associated with the XML type of this binding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlName

protected java.lang.String xmlName
The XML name of the binding

xmlNamespaceURI

protected java.lang.String xmlNamespaceURI
The XML namespace URI associated with the XML name of the binding

xmlType

protected java.lang.String xmlType
The XML type of the binding

xmlTypeNamespaceURI

protected java.lang.String xmlTypeNamespaceURI
The XML namespace URI associated with the XML type of the binding

xmlParentType

protected java.lang.String xmlParentType
The XML parent type for this binding

xmlParentTypeNamespaceURI

protected java.lang.String xmlParentTypeNamespaceURI
The XML namespace URI for this binding's XML parent type

isXMLRootElement

protected boolean isXMLRootElement
Whether this is the XML root element

javaName

protected java.lang.String javaName
The Java name of the binding

javaType

protected java.lang.String javaType
The Java type of the binding

javaVariableName

protected java.lang.String javaVariableName
The Java name of the binding that is a legal Java identifier.

javaInterfacePackage

protected java.lang.String javaInterfacePackage
The Java interface package of the binding

javaImplementationPackage

protected java.lang.String javaImplementationPackage
The Java implementation package of the binding

javaCollectionClass

protected java.lang.String javaCollectionClass
The Java Collection class for this binding

isJavaSerializable

protected boolean isJavaSerializable
Whether this binding is Java-serializable
Constructor Detail

BaseBinding

public BaseBinding()

Default constructor.

Method Detail

getXMLName

public java.lang.String getXMLName()

This will return the XML name of the binding. This should be the actual XML name of the binding as would be seen in an XML document.

Returns:
String - the XML name of the binding.

setXMLName

public void setXMLName(java.lang.String xmlName)

This will set the XML name of the binding.

Parameters:
xmlName - the XML name of the binding.

getXMLNamespaceURI

public java.lang.String getXMLNamespaceURI()

The will return the XML namespace URI associated with the XML name of this binding. A value of the empty string indicates that there is no URI associated with the XML name of this binding.

Returns:
String - the XML namespace URI associated with the XML name of this binding, or an empty string if no namespace URI.

setXMLNamespaceURI

public void setXMLNamespaceURI(java.lang.String xmlNamespaceURI)

The will set the XML namespace URI associated with the XML name of this binding. A value of the empty string indicates that there is no URI associated with the XML name of this binding.

Parameters:
xmlNamespaceURI - the XML namespace URI

getXMLType

public java.lang.String getXMLType()

This will return the XML local name associated with the XML type of this binding. When using a DTD, the XML type is the same as the XML name. However, when using an XML Schema, the type may be different from the name.

Returns:
String - the XML local name of the XML type of this binding.

setXMLType

public void setXMLType(java.lang.String xmlType)

This will set the XML local name associated with the XML type of this binding.

Parameters:
xmlType - the XML type.

getXMLTypeNamespaceURI

public java.lang.String getXMLTypeNamespaceURI()

The will return the XML namespace URI associated with the XML type of this binding. A value of the empty string indicates that there is no URI associated with the XML type of this binding.

While this is not useful in DTD binding, it allows types like xsd:string to be distinguished from something like myPrefix:string, which a user might define.

Returns:
String - the XML namespace URI associated with the XML type of this binding.

setXMLTypeNamespaceURI

public void setXMLTypeNamespaceURI(java.lang.String xmlTypeNamespaceURI)

This will set the XML namespace URI associated with the XML type of this binding. A value of the empty string indicates that there is no URI associated with the XML type of this binding.

Parameters:
xmlTypeNamespaceURI - the XML type's namespace URI.

getXMLParentType

public java.lang.String getXMLParentType()

This will return the XML local name associated with the XML type of this binding's XML parent. When using a DTD, the XML type is the same as the XML name. However, when using an XML Schema, the type may be different from the name.

If there is no parent XML type, such as for the root element of a document, this value is null.

Returns:
String - the XML local name of the XML type of this binding's parent.

setXMLParentType

public void setXMLParentType(java.lang.String xmlParentType)

This will set the XML local name associated with the XML type of this binding's XML parent.

Parameters:
xmlParentType - the XML type for this binding's parent.

getXMLParentTypeNamespaceURI

public java.lang.String getXMLParentTypeNamespaceURI()

The will return the XML namespace URI associated with the XML type of this binding's XML parent. A value of the empty string indicates that there is no URI associated with the XML type of this binding's parent.

While this is not useful in DTD binding, it allows types like xsd:string to be distinguished from something like myPrefix:string, which a user might define.

Returns:
String - the XML namespace URI associated with the XML type of this binding's parent.

setXMLParentTypeNamespaceURI

public void setXMLParentTypeNamespaceURI(java.lang.String xmlParentTypeNamespaceURI)

This will set the XML namespace URI associated with the XML type of this binding's XML parent. A value of the empty string indicates that there is no URI associated with the XML type of this binding's parent.

Parameters:
xmlParentTypeNamespaceURI - the XML namespace URI of the parent type.

setIsXMLRootElement

public void setIsXMLRootElement(boolean isXMLRootElement)

This sets whether this binding represents an XML element that is the root element of the document.

Parameters:
isXMLRootElement - whether this is the root element.

isXMLRootElement

public boolean isXMLRootElement()

This indicates if this binding represents an XML element that is the root element of the document.

Returns:
boolean - whether this is the root element.

getJavaName

public java.lang.String getJavaName()

This will return the Java name of the binding. This should be the valid Java name of the binding, which is most often a variable name. This is the string used to build the methods setXXX() and getXXX(). Note that this is not necessarily the variable name used by the generators, but they will provide the setXXX() and getXXX() based on this name.

Returns:
String - the Java name of the binding.

setJavaName

public void setJavaName(java.lang.String javaName)

The will set the name of the Java variable associated with this binding.

Parameters:
javaName - the new variable name.

getJavaType

public java.lang.String getJavaType()

This will return the Java type associated with the binding. This is not a fully qualified name for the type. To get the fully qualified name for the type prepend the value returned from getJavaPackage() to the value returned by this method (with a "." inserted in between if the package is not the empty string).

Returns:
String - the Java type of the binding.

setJavaType

public void setJavaType(java.lang.String javaType)

This will set the Java type for this binding.

Parameters:
javaType - the Java type for this binding.

getJavaVariableName

public java.lang.String getJavaVariableName()

This will return the Java name that can be used for a variable name in generated code. It is guaranteed to be a legal Java identifier.

To illustrate the difference between the Java name and its variable name, consider this simple example:


   
 
With the above DTD the XML name is "default". However, "default" is a Java keyword, but setDefault() and getDefault() are not illegal. So for a typical name binding, the Java name would be "default" and the variable name would (could) be "safeDefault". The generated interface would still contain setDefault() and getDefault().

Note that it is not necessary for the variable name to always (or even often) be different from the normal Java name.

Returns:
String - the Java variable name.

setJavaVariableName

public void setJavaVariableName(java.lang.String javaVariableName)

This will set the Java name that can be used for a variable name in generated code. This must be a legal Java identifier, and the first character must not be an upper case letter.

Parameters:
javaVariableName - the name to use for the Java member variable.

getJavaInterfacePackage

public java.lang.String getJavaInterfacePackage()

This will return the Java package name for this binding's interface class.

Returns:
String - the Java interface package associated with the binding's Java type.

setJavaInterfacePackage

public void setJavaInterfacePackage(java.lang.String javaInterfacePackage)

This will set the Java package for this class's interface.

Parameters:
javaInterfacePackage - the name of the interface package for this binding.

getJavaImplementationPackage

public java.lang.String getJavaImplementationPackage()

This will return the Java package name for this binding's implementation class.

Returns:
String - the Java implementation package associated with the binding's Java type.

setJavaImplementationPackage

public void setJavaImplementationPackage(java.lang.String javaImplementationPackage)

This will set the Java package for this class's implementation.

Parameters:
javaImplementationPackage - the name of the implementation package for this binding.

setJavaCollectionClass

public void setJavaCollectionClass(java.lang.String javaCollectionClass)
                            throws InvalidCollectionTypeException

This will set the Java collection class to use for this binding, if it is a collection. This will be a fully-qualified Java class, such as java.util.List.

Parameters:
javaCollectionClass - the collection class for this binding.
Throws:
InvalidCollectionTypeException - - when the supplied collection class is not a valid collection type.

getJavaCollectionClass

public java.lang.String getJavaCollectionClass()

This will return the Java collection class to use for this binding, if it is a collection. This will be a fully qualified Java class, such as java.util.List.

Returns:
String - the Java collection class for this binding.

setIsJavaSerializable

public void setIsJavaSerializable(boolean isJavaSerializable)

This will set whether this binding should be a Java-serializable class.

Parameters:
isJavaSerializable - whether this binding should be Java serializable (true) or not (false).

isJavaSerializable

public boolean isJavaSerializable()

This will indicate whether this binding is Java-serializable (indicated by a boolean value of "true"), or not (indicated by a boolean value of "false").

Returns:
boolean - whether this binding is Java-serializable.


Copyright © 2001 Enhydra. All Rights Reserved.