Schema Summary
This sample shows how a complextype may be extended, and how the base and extended types can be manipulated in code.
Schema Details
The Schema
A global base type Address is defined (all base types must be global). The elements CAN_Address and GBR_Address then extended Address in order to add additional elements.
The Person element contains a child element HomeAddress of type Address. In place of Address any type that is based on Address (including Address itself) can be used (CAN_Address and GBR_Address).
If an element is added to Person:HomeAddress of a type other than the Address, then we need to identify the type of the element used (for validation purposes), this means placing a xs:type="" attribute against the element. This is automatically done for you by the generated classes.
Generated Code
The element Address is a base element to CAN_Address and GBR_Address, and Address can be created as an element in its own right. This means that where ever Address can be used CAN_Address and GBR_Address can be used in its place. In order to implemenent this in the generated code, an abstract base class IAddress is introduced. All of the classes generated from Address, CAN_Address and GBR_Address implement this IAddress interface.
Sample Description
The sample demonstrates the use of the derived type Can_Address. Note the type specified in Person is 'Address' however any element deriving from it may used in its place.
|
Sample XML File
Sample3.xml
|
<?xml version="1.0" encoding="UTF-8"?>
<Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="..\Schema\DerivedByExtension.xsd" >
<Age>32</Age>
<HomeAddress xsi:type="CAN_Address">
<Name>Trevelyn</Name>
<Street>8185 Great White North Bay</Street>
<City>Thunder Bay</City>
<Province>Ontario</Province>
<PostalCode>M1A 3X9</PostalCode>
</HomeAddress>
</Person>
|
Sample Code
Read Sample
|
SampleRead(Usage1.SamplePath + "DerivedByExtension\\Samples\\Sample3.xml");
...
DerivedByExtensionLib.Person per = new DerivedByExtensionLib.Person();
per.fromXmlFile(FilePath);
System.out.println("Age = " + per.getAge());
System.out.println("Address");
System.out.println(" Name = " + per.getHomeAddress().getName() );
System.out.println(" Street = " + per.getHomeAddress().getStreet() );
System.out.println(" City = " + per.getHomeAddress().getCity() );
if (per.getHomeAddress().getClass().isInstance(new DerivedByExtensionLib.Address()))
{
// The HomeAddress is an Address object, there is no more data to display
}
else if (per.getHomeAddress().getClass().isInstance(new DerivedByExtensionLib.CAN_Address()))
{
// The HomeAddress is an CAN_Address object
DerivedByExtensionLib.CAN_Address CAdd = (DerivedByExtensionLib.CAN_Address)per.getHomeAddress();
System.out.println(" City = " + CAdd.getProvince() );
System.out.println(" PostalCode = " + CAdd.getPostalCode() );
}
else if (per.getHomeAddress().getClass().isInstance(new DerivedByExtensionLib.GBR_Address()))
{
// The HomeAddress is an GBR_Address object.
DerivedByExtensionLib.GBR_Address GAdd = (DerivedByExtensionLib.GBR_Address)per.getHomeAddress();
System.out.println(" County = " + GAdd.getCounty() );
System.out.println(" PostCode = " + GAdd.getPostCode() );
}
else
{
// The HomeAddress is an unknown type
System.out.println("The Home address is an unknown type");
}
Output
Age = 32
Address
Name = Trevelyn
Street = 8185 Great White North Bay
City = Thunder Bay
City = Ontario
PostalCode = M1A 3X9
|
|
Write Sample
|
DerivedByExtensionLib.Person per = new DerivedByExtensionLib.Person();
per.setAge((short)32);
DerivedByExtensionLib.CAN_Address CanAddress = new DerivedByExtensionLib.CAN_Address();
per.setHomeAddress(CanAddress);
CanAddress.setName("Trevelyn");
CanAddress.setStreet("8185 Great White North Bay");
CanAddress.setCity("Thunder Bay");
CanAddress.setProvince("Ontario");
CanAddress.setPostalCode("M1A 3X9");
System.out.println(per.toXml(true, Formatting.INDENTED, Encoding.UTF8, EOLType.CRLF));
Output
<?xml version="1.0" encoding="UTF-8"?>
<!--Created by Liquid XML Data Binding Libraries (www.liquid-technologies.com) for Liquid Technologies Ltd -->
<Person xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
<Age>32</Age>
<HomeAddress xs:type="CAN_Address">
<Name>Trevelyn</Name>
<Street>8185 Great White North Bay</Street>
<City>Thunder Bay</City>
<Province>Ontario</Province>
<PostalCode>M1A 3X9</PostalCode>
</HomeAddress>
</Person>
|
|
XSD Source Files
DerivedByExtension.xsd
|
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="Address">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Street" type="xs:string"/>
<xs:element name="City" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="CAN_Address">
<xs:complexContent>
<xs:extension base="Address">
<xs:sequence>
<xs:element name="Province" type="xs:string"/>
<xs:element name="PostalCode" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="GBR_Address">
<xs:complexContent>
<xs:extension base="Address">
<xs:sequence>
<xs:element name="County" type="xs:string"/>
<xs:element name="PostCode" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="Person">
<xs:complexType>
<xs:sequence>
<xs:element name="Age" type="xs:unsignedByte"/>
<xs:element name="HomeAddress" type="Address"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
|
Schema Diagrams
|
|
Generated Files
Address.java
|
Address.java
package DerivedByExtensionLib;
public class Address extends com.liquid_technologies.ltxmllib16.XmlGeneratedClass
implements DerivedByExtensionLib.IAddress
{
private static final long serialVersionUID = 13L;
// <summary>
// Constructor for Address
// </summary>
// <remarks>
// The class is created with all the mandatory fields populated with the
// default data.
// All Collection object are created.
// However any 1-n relationships (these are represented as collections) are
// empty. To comply with the schema these must be populated before the xml
// obtained from ToXml is valid against the schema D:/Development2018/Liquid/Tools/DataBindingSamples/Samples/DerivedByExtension/Schema/DerivedByExtension.xsd
// </remarks>
public Address() {
setElementName("Address");
init();
}
public Address(String elementName) {
setElementName(elementName);
init();
}
// <summary>
// Initializes the class
// </summary>
// <remarks>
// This creates all the mandatory fields (populated with the default data)
// All Collection object are created.
// However any 1-n relationships (these are represented as collections) are
// empty. To comply with the schema these must be populated before the xml
// obtained from ToXml is valid against the schema D:/Development2018/Liquid/Tools/DataBindingSamples/Samples/DerivedByExtension/Schema/DerivedByExtension.xsd.
// </remarks>
@Override
protected void init() {
try {
DerivedByExtensionLib.Registration.iRegistrationIndicator = 0;
_name = "";
_street = "";
_city = "";
getClassAttributeInfo();
getClassElementInfo();
} catch (Exception ex) {
ex.printStackTrace();
throw new InternalError();
}
}
// <summary>
// Allows the class to be copied
// </summary>
// <remarks>
// Performs a 'deep copy' of all the data in the class (and its children)
// </remarks>
@Override
public Object clone() throws CloneNotSupportedException {
try {
DerivedByExtensionLib.Address newObject = (DerivedByExtensionLib.Address)super.clone();
newObject.init();
newObject._name = _name;
newObject._street = _street;
newObject._city = _city;
return newObject;
} catch (CloneNotSupportedException e) {
e.printStackTrace();
throw new InternalError();
}
}
@Override
public String getTargetNamespace() {
return "";
}
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getName() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _name;
}
public void setName(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_name = value;
}
protected java.lang.String _name;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getStreet() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _street;
}
public void setStreet(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_street = value;
}
protected java.lang.String _street;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getCity() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _city;
}
public void setCity(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_city = value;
}
protected java.lang.String _city;
@Override
public String getNamespace() {
return "";
}
@Override
public com.liquid_technologies.ltxmllib16.XmlObjectBase getBase() {
return this;
}
protected void onEvent(com.liquid_technologies.ltxmllib16.XmlObjectBase msgSource, int msgType, Object data) {
if (msgType == CollectionChangeEvent) {
}
}
private static com.liquid_technologies.ltxmllib16.ParentElementInfo __parentElementInfo = null;
private static com.liquid_technologies.ltxmllib16.ElementInfo[] __elementInfo = null;
private static com.liquid_technologies.ltxmllib16.AttributeInfo[] __attributeInfo = null;
protected com.liquid_technologies.ltxmllib16.ParentElementInfo getClassInfo() throws Exception {
if (__parentElementInfo == null) {
__parentElementInfo = new com.liquid_technologies.ltxmllib16.ParentElementInfo(
com.liquid_technologies.ltxmllib16.XmlObjectBase.XmlElementGroupType.SEQUENCE,
com.liquid_technologies.ltxmllib16.XmlObjectBase.XmlElementType.ELEMENT, "Address", "", true, true,
null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_NONE, null, false);
}
return __parentElementInfo;
}
protected com.liquid_technologies.ltxmllib16.ElementInfo[] getClassElementInfo() throws Exception {
if (__elementInfo == null) {
__elementInfo = new com.liquid_technologies.ltxmllib16.ElementInfo[] {
new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("Name", "", findGetterMethod("DerivedByExtensionLib.Address", "getName"), findSetterMethod("DerivedByExtensionLib.Address", "setName", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("Street", "", findGetterMethod("DerivedByExtensionLib.Address", "getStreet"), findSetterMethod("DerivedByExtensionLib.Address", "setStreet", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("City", "", findGetterMethod("DerivedByExtensionLib.Address", "getCity"), findSetterMethod("DerivedByExtensionLib.Address", "setCity", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
};
}
return __elementInfo;
}
protected com.liquid_technologies.ltxmllib16.AttributeInfo[] getClassAttributeInfo() throws Exception {
if (__attributeInfo==null) {
__attributeInfo = new com.liquid_technologies.ltxmllib16.AttributeInfo[] {
};
}
return __attributeInfo;
}
}
|
CAN_Address.java
|
CAN_Address.java
package DerivedByExtensionLib;
public class CAN_Address extends com.liquid_technologies.ltxmllib16.XmlGeneratedClass
implements DerivedByExtensionLib.IAddress
{
private static final long serialVersionUID = 13L;
// <summary>
// Constructor for CAN_Address
// </summary>
// <remarks>
// The class is created with all the mandatory fields populated with the
// default data.
// All Collection object are created.
// However any 1-n relationships (these are represented as collections) are
// empty. To comply with the schema these must be populated before the xml
// obtained from ToXml is valid against the schema D:/Development2018/Liquid/Tools/DataBindingSamples/Samples/DerivedByExtension/Schema/DerivedByExtension.xsd
// </remarks>
public CAN_Address() {
setElementName("CAN_Address");
init();
}
public CAN_Address(String elementName) {
setElementName(elementName);
init();
}
// <summary>
// Initializes the class
// </summary>
// <remarks>
// This creates all the mandatory fields (populated with the default data)
// All Collection object are created.
// However any 1-n relationships (these are represented as collections) are
// empty. To comply with the schema these must be populated before the xml
// obtained from ToXml is valid against the schema D:/Development2018/Liquid/Tools/DataBindingSamples/Samples/DerivedByExtension/Schema/DerivedByExtension.xsd.
// </remarks>
@Override
protected void init() {
try {
DerivedByExtensionLib.Registration.iRegistrationIndicator = 0;
_name = "";
_street = "";
_city = "";
_province = "";
_postalCode = "";
getClassAttributeInfo();
getClassElementInfo();
} catch (Exception ex) {
ex.printStackTrace();
throw new InternalError();
}
}
// <summary>
// Allows the class to be copied
// </summary>
// <remarks>
// Performs a 'deep copy' of all the data in the class (and its children)
// </remarks>
@Override
public Object clone() throws CloneNotSupportedException {
try {
DerivedByExtensionLib.CAN_Address newObject = (DerivedByExtensionLib.CAN_Address)super.clone();
newObject.init();
newObject._name = _name;
newObject._street = _street;
newObject._city = _city;
newObject._province = _province;
newObject._postalCode = _postalCode;
return newObject;
} catch (CloneNotSupportedException e) {
e.printStackTrace();
throw new InternalError();
}
}
@Override
public String getTargetNamespace() {
return "";
}
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getName() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _name;
}
public void setName(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_name = value;
}
protected java.lang.String _name;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getStreet() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _street;
}
public void setStreet(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_street = value;
}
protected java.lang.String _street;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getCity() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _city;
}
public void setCity(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_city = value;
}
protected java.lang.String _city;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getProvince() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _province;
}
public void setProvince(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_province = value;
}
protected java.lang.String _province;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getPostalCode() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _postalCode;
}
public void setPostalCode(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_postalCode = value;
}
protected java.lang.String _postalCode;
@Override
public String getNamespace() {
return "";
}
@Override
public com.liquid_technologies.ltxmllib16.XmlObjectBase getBase() {
return this;
}
protected void onEvent(com.liquid_technologies.ltxmllib16.XmlObjectBase msgSource, int msgType, Object data) {
if (msgType == CollectionChangeEvent) {
}
}
private static com.liquid_technologies.ltxmllib16.ParentElementInfo __parentElementInfo = null;
private static com.liquid_technologies.ltxmllib16.ElementInfo[] __elementInfo = null;
private static com.liquid_technologies.ltxmllib16.AttributeInfo[] __attributeInfo = null;
protected com.liquid_technologies.ltxmllib16.ParentElementInfo getClassInfo() throws Exception {
if (__parentElementInfo == null) {
__parentElementInfo = new com.liquid_technologies.ltxmllib16.ParentElementInfo(
com.liquid_technologies.ltxmllib16.XmlObjectBase.XmlElementGroupType.SEQUENCE,
com.liquid_technologies.ltxmllib16.XmlObjectBase.XmlElementType.ELEMENT, "CAN_Address", "", true, true,
null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_NONE, null, false);
}
return __parentElementInfo;
}
protected com.liquid_technologies.ltxmllib16.ElementInfo[] getClassElementInfo() throws Exception {
if (__elementInfo == null) {
__elementInfo = new com.liquid_technologies.ltxmllib16.ElementInfo[] {
new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("Name", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getName"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setName", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("Street", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getStreet"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setStreet", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("City", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getCity"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setCity", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("Province", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getProvince"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setProvince", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("PostalCode", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getPostalCode"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setPostalCode", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
};
}
return __elementInfo;
}
protected com.liquid_technologies.ltxmllib16.AttributeInfo[] getClassAttributeInfo() throws Exception {
if (__attributeInfo==null) {
__attributeInfo = new com.liquid_technologies.ltxmllib16.AttributeInfo[] {
};
}
return __attributeInfo;
}
}
|
GBR_Address.java
|
GBR_Address.java
package DerivedByExtensionLib;
public class GBR_Address extends com.liquid_technologies.ltxmllib16.XmlGeneratedClass
implements DerivedByExtensionLib.IAddress
{
private static final long serialVersionUID = 13L;
// <summary>
// Constructor for GBR_Address
// </summary>
// <remarks>
// The class is created with all the mandatory fields populated with the
// default data.
// All Collection object are created.
// However any 1-n relationships (these are represented as collections) are
// empty. To comply with the schema these must be populated before the xml
// obtained from ToXml is valid against the schema D:/Development2018/Liquid/Tools/DataBindingSamples/Samples/DerivedByExtension/Schema/DerivedByExtension.xsd
// </remarks>
public GBR_Address() {
setElementName("GBR_Address");
init();
}
public GBR_Address(String elementName) {
setElementName(elementName);
init();
}
// <summary>
// Initializes the class
// </summary>
// <remarks>
// This creates all the mandatory fields (populated with the default data)
// All Collection object are created.
// However any 1-n relationships (these are represented as collections) are
// empty. To comply with the schema these must be populated before the xml
// obtained from ToXml is valid against the schema D:/Development2018/Liquid/Tools/DataBindingSamples/Samples/DerivedByExtension/Schema/DerivedByExtension.xsd.
// </remarks>
@Override
protected void init() {
try {
DerivedByExtensionLib.Registration.iRegistrationIndicator = 0;
_name = "";
_street = "";
_city = "";
_county = "";
_postCode = "";
getClassAttributeInfo();
getClassElementInfo();
} catch (Exception ex) {
ex.printStackTrace();
throw new InternalError();
}
}
// <summary>
// Allows the class to be copied
// </summary>
// <remarks>
// Performs a 'deep copy' of all the data in the class (and its children)
// </remarks>
@Override
public Object clone() throws CloneNotSupportedException {
try {
DerivedByExtensionLib.GBR_Address newObject = (DerivedByExtensionLib.GBR_Address)super.clone();
newObject.init();
newObject._name = _name;
newObject._street = _street;
newObject._city = _city;
newObject._county = _county;
newObject._postCode = _postCode;
return newObject;
} catch (CloneNotSupportedException e) {
e.printStackTrace();
throw new InternalError();
}
}
@Override
public String getTargetNamespace() {
return "";
}
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getName() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _name;
}
public void setName(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_name = value;
}
protected java.lang.String _name;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getStreet() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _street;
}
public void setStreet(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_street = value;
}
protected java.lang.String _street;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getCity() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _city;
}
public void setCity(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_city = value;
}
protected java.lang.String _city;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getCounty() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _county;
}
public void setCounty(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_county = value;
}
protected java.lang.String _county;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to "".
// </remarks>
public java.lang.String getPostCode() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _postCode;
}
public void setPostCode(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
value = com.liquid_technologies.ltxmllib16.WhitespaceUtils.preserve(value);
_postCode = value;
}
protected java.lang.String _postCode;
@Override
public String getNamespace() {
return "";
}
@Override
public com.liquid_technologies.ltxmllib16.XmlObjectBase getBase() {
return this;
}
protected void onEvent(com.liquid_technologies.ltxmllib16.XmlObjectBase msgSource, int msgType, Object data) {
if (msgType == CollectionChangeEvent) {
}
}
private static com.liquid_technologies.ltxmllib16.ParentElementInfo __parentElementInfo = null;
private static com.liquid_technologies.ltxmllib16.ElementInfo[] __elementInfo = null;
private static com.liquid_technologies.ltxmllib16.AttributeInfo[] __attributeInfo = null;
protected com.liquid_technologies.ltxmllib16.ParentElementInfo getClassInfo() throws Exception {
if (__parentElementInfo == null) {
__parentElementInfo = new com.liquid_technologies.ltxmllib16.ParentElementInfo(
com.liquid_technologies.ltxmllib16.XmlObjectBase.XmlElementGroupType.SEQUENCE,
com.liquid_technologies.ltxmllib16.XmlObjectBase.XmlElementType.ELEMENT, "GBR_Address", "", true, true,
null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_NONE, null, false);
}
return __parentElementInfo;
}
protected com.liquid_technologies.ltxmllib16.ElementInfo[] getClassElementInfo() throws Exception {
if (__elementInfo == null) {
__elementInfo = new com.liquid_technologies.ltxmllib16.ElementInfo[] {
new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("Name", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getName"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setName", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("Street", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getStreet"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setStreet", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("City", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getCity"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setCity", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("County", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getCounty"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setCounty", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("PostCode", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getPostCode"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setPostCode", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
};
}
return __elementInfo;
}
protected com.liquid_technologies.ltxmllib16.AttributeInfo[] getClassAttributeInfo() throws Exception {
if (__attributeInfo==null) {
__attributeInfo = new com.liquid_technologies.ltxmllib16.AttributeInfo[] {
};
}
return __attributeInfo;
}
}
|
IAddress.java
|
IAddress.java
package DerivedByExtensionLib;
public interface IAddress extends com.liquid_technologies.ltxmllib16.XmlObjectInterface
{
// Member variables
// Attribute - Name
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
java.lang.String getName() throws com.liquid_technologies.ltxmllib16.exceptions.LtException;
void setName(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException;
// Attribute - Street
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
java.lang.String getStreet() throws com.liquid_technologies.ltxmllib16.exceptions.LtException;
void setStreet(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException;
// Attribute - City
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
java.lang.String getCity() throws com.liquid_technologies.ltxmllib16.exceptions.LtException;
void setCity(java.lang.String value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException;
}
|
Person.java
|
Person.java
package DerivedByExtensionLib;
public class Person extends com.liquid_technologies.ltxmllib16.XmlGeneratedClass {
private static final long serialVersionUID = 13L;
// <summary>
// Constructor for Person
// </summary>
// <remarks>
// The class is created with all the mandatory fields populated with the
// default data.
// All Collection object are created.
// However any 1-n relationships (these are represented as collections) are
// empty. To comply with the schema these must be populated before the xml
// obtained from ToXml is valid against the schema D:/Development2018/Liquid/Tools/DataBindingSamples/Samples/DerivedByExtension/Schema/DerivedByExtension.xsd
// </remarks>
public Person() {
setElementName("Person");
init();
}
public Person(String elementName) {
setElementName(elementName);
init();
}
// <summary>
// Initializes the class
// </summary>
// <remarks>
// This creates all the mandatory fields (populated with the default data)
// All Collection object are created.
// However any 1-n relationships (these are represented as collections) are
// empty. To comply with the schema these must be populated before the xml
// obtained from ToXml is valid against the schema D:/Development2018/Liquid/Tools/DataBindingSamples/Samples/DerivedByExtension/Schema/DerivedByExtension.xsd.
// </remarks>
@Override
protected void init() {
try {
DerivedByExtensionLib.Registration.iRegistrationIndicator = 0;
_age = (short)0;
_homeAddress = null;
getClassAttributeInfo();
getClassElementInfo();
} catch (Exception ex) {
ex.printStackTrace();
throw new InternalError();
}
}
// <summary>
// Allows the class to be copied
// </summary>
// <remarks>
// Performs a 'deep copy' of all the data in the class (and its children)
// </remarks>
@Override
public Object clone() throws CloneNotSupportedException {
try {
DerivedByExtensionLib.Person newObject = (DerivedByExtensionLib.Person)super.clone();
newObject.init();
newObject._age = _age;
newObject._homeAddress = null;
if (_homeAddress != null)
newObject._homeAddress = (DerivedByExtensionLib.IAddress)_homeAddress.clone();
return newObject;
} catch (CloneNotSupportedException e) {
e.printStackTrace();
throw new InternalError();
}
}
@Override
public String getTargetNamespace() {
return "";
}
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// It is defaulted to (short)0.
// </remarks>
public short getAge() throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
return _age;
}
public void setAge(short value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
_age = value;
}
protected short _age;
// <summary>
// Represents a mandatory Element in the XML document
// </summary>
// <remarks>
// This property is represented as an Element in the XML.
// It is mandatory and therefore must be populated within the XML.
// If this property is set, then the object will be COPIED. If the property is set to null an exception is raised.
// </remarks>
public DerivedByExtensionLib.IAddress getHomeAddress() {
return _homeAddress;
}
public void setHomeAddress(DerivedByExtensionLib.IAddress value) throws com.liquid_technologies.ltxmllib16.exceptions.LtException {
throw_IfPropertyIsNull(value, "HomeAddress");
if (value != null)
setElementName(value.getBase(), "HomeAddress");
_homeAddress = value;
}
protected DerivedByExtensionLib.IAddress _homeAddress;
@Override
public String getNamespace() {
return "";
}
@Override
public com.liquid_technologies.ltxmllib16.XmlObjectBase getBase() {
return this;
}
protected void onEvent(com.liquid_technologies.ltxmllib16.XmlObjectBase msgSource, int msgType, Object data) {
if (msgType == CollectionChangeEvent) {
}
}
private static com.liquid_technologies.ltxmllib16.ParentElementInfo __parentElementInfo = null;
private static com.liquid_technologies.ltxmllib16.ElementInfo[] __elementInfo = null;
private static com.liquid_technologies.ltxmllib16.AttributeInfo[] __attributeInfo = null;
protected com.liquid_technologies.ltxmllib16.ParentElementInfo getClassInfo() throws Exception {
if (__parentElementInfo == null) {
__parentElementInfo = new com.liquid_technologies.ltxmllib16.ParentElementInfo(
com.liquid_technologies.ltxmllib16.XmlObjectBase.XmlElementGroupType.SEQUENCE,
com.liquid_technologies.ltxmllib16.XmlObjectBase.XmlElementType.ELEMENT, "Person", "", true, false,
null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_NONE, null, false);
}
return __parentElementInfo;
}
protected com.liquid_technologies.ltxmllib16.ElementInfo[] getClassElementInfo() throws Exception {
if (__elementInfo == null) {
__elementInfo = new com.liquid_technologies.ltxmllib16.ElementInfo[] {
new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqPrimMnd("Age", "", findGetterMethod("DerivedByExtensionLib.Person", "getAge"), findSetterMethod("DerivedByExtensionLib.Person", "setAge", "short"), null, null, com.liquid_technologies.ltxmllib16.Conversions.ConversionType.TYPE_UI1, null, com.liquid_technologies.ltxmllib16.WhitespaceRule.COLLAPSE, new com.liquid_technologies.ltxmllib16.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1))
,new com.liquid_technologies.ltxmllib16.data.ElementInfoSeqAbsClsMnd("HomeAddress", "", findGetterMethod("DerivedByExtensionLib.Person", "getHomeAddress"), findSetterMethod("DerivedByExtensionLib.Person", "setHomeAddress", "DerivedByExtensionLib.IAddress"), com.liquid_technologies.ltxmllib16.XmlObjectBase.XmlElementType.ELEMENT, getClassFactoryCreateMethod("DerivedByExtensionLib.ClassFactory", "IAddressCreateObject"))
};
}
return __elementInfo;
}
protected com.liquid_technologies.ltxmllib16.AttributeInfo[] getClassAttributeInfo() throws Exception {
if (__attributeInfo==null) {
__attributeInfo = new com.liquid_technologies.ltxmllib16.AttributeInfo[] {
};
}
return __attributeInfo;
}
}
|