Java Sample : Derived By Extension
Schema Summary This sample shows how a complex type 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 implement 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> |
Read Sample | |
SampleRead(Usage1.SamplePath + "DerivedByExtension\\Samples\\Sample3.xml"); // Create Name object DerivedByExtensionLib.Person per = new DerivedByExtensionLib.Person(); // Load data into the object from a file per.fromXmlFile(FilePath); // Now we can look at the data 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"); }
|
Write Sample | |
// Create Name object DerivedByExtensionLib.Person per = new DerivedByExtensionLib.Person(); // populate the person object per.setAge((short)32); // Create the right kind of address object 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"); // Now we can look at the XML from this object System.out.println(per.toXml(true, Formatting.INDENTED, Encoding.UTF8, EOLType.CRLF));
|
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 |
|
Address.java |
package DerivedByExtensionLib; /********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ // <summary> // This class represents the ComplexType Address // </summary> public class Address extends com.liquid_technologies.ltxmllib20.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 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 DerivedByExtension.xsd. // </remarks> @Override protected void init() { try { DerivedByExtensionLib.Registration.iRegistrationIndicator = 0; // causes registration to take place _name = ""; _street = ""; _city = ""; // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional initialization code here... // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS getClassAttributeInfo(); getClassElementInfo(); } catch (Exception ex) { // should never happen 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(); // clone, creates a bitwise copy of the class, so all the collections are the // same as the parents. Init will re-create our own collections, and classes, // preventing objects being shared between the new an original objects newObject.init(); newObject._name = _name; newObject._street = _street; newObject._city = _city; // ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional clone code here... // ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS return newObject; } catch (CloneNotSupportedException e) { // should never happen 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.ltxmllib20.exceptions.LtException { return _name; } public void setName(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _street; } public void setStreet(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _city; } public void setCity(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.WhitespaceUtils.preserve(value); _city = value; } protected java.lang.String _city; @Override public String getNamespace() { return ""; } @Override public com.liquid_technologies.ltxmllib20.XmlObjectBase getBase() { return this; } protected void onEvent(com.liquid_technologies.ltxmllib20.XmlObjectBase msgSource, int msgType, Object data) { if (msgType == CollectionChangeEvent) { } } private static com.liquid_technologies.ltxmllib20.ParentElementInfo __parentElementInfo = null; private static com.liquid_technologies.ltxmllib20.ElementInfo[] __elementInfo = null; private static com.liquid_technologies.ltxmllib20.AttributeInfo[] __attributeInfo = null; protected com.liquid_technologies.ltxmllib20.ParentElementInfo getClassInfo() throws Exception { if (__parentElementInfo == null) { __parentElementInfo = new com.liquid_technologies.ltxmllib20.ParentElementInfo( com.liquid_technologies.ltxmllib20.XmlObjectBase.XmlElementGroupType.SEQUENCE, com.liquid_technologies.ltxmllib20.XmlObjectBase.XmlElementType.ELEMENT, "Address", "", true, true, null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_NONE, com.liquid_technologies.ltxmllib20.WhitespaceRule.NONE, null, false); } return __parentElementInfo; } protected com.liquid_technologies.ltxmllib20.ElementInfo[] getClassElementInfo() throws Exception { if (__elementInfo == null) { __elementInfo = new com.liquid_technologies.ltxmllib20.ElementInfo[] { new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("Name", "", findGetterMethod("DerivedByExtensionLib.Address", "getName"), findSetterMethod("DerivedByExtensionLib.Address", "setName", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("Street", "", findGetterMethod("DerivedByExtensionLib.Address", "getStreet"), findSetterMethod("DerivedByExtensionLib.Address", "setStreet", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("City", "", findGetterMethod("DerivedByExtensionLib.Address", "getCity"), findSetterMethod("DerivedByExtensionLib.Address", "setCity", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) }; } return __elementInfo; } protected com.liquid_technologies.ltxmllib20.AttributeInfo[] getClassAttributeInfo() throws Exception { if (__attributeInfo==null) { __attributeInfo = new com.liquid_technologies.ltxmllib20.AttributeInfo[] { }; } return __attributeInfo; } // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } |
CAN_Address.java |
package DerivedByExtensionLib; /********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ // <summary> // This class represents the ComplexType CAN_Address // </summary> public class CAN_Address extends com.liquid_technologies.ltxmllib20.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 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 DerivedByExtension.xsd. // </remarks> @Override protected void init() { try { DerivedByExtensionLib.Registration.iRegistrationIndicator = 0; // causes registration to take place _name = ""; _street = ""; _city = ""; _province = ""; _postalCode = ""; // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional initialization code here... // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS getClassAttributeInfo(); getClassElementInfo(); } catch (Exception ex) { // should never happen 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(); // clone, creates a bitwise copy of the class, so all the collections are the // same as the parents. Init will re-create our own collections, and classes, // preventing objects being shared between the new an original objects newObject.init(); newObject._name = _name; newObject._street = _street; newObject._city = _city; newObject._province = _province; newObject._postalCode = _postalCode; // ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional clone code here... // ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS return newObject; } catch (CloneNotSupportedException e) { // should never happen 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.ltxmllib20.exceptions.LtException { return _name; } public void setName(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _street; } public void setStreet(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _city; } public void setCity(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _province; } public void setProvince(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _postalCode; } public void setPostalCode(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.WhitespaceUtils.preserve(value); _postalCode = value; } protected java.lang.String _postalCode; @Override public String getNamespace() { return ""; } @Override public com.liquid_technologies.ltxmllib20.XmlObjectBase getBase() { return this; } protected void onEvent(com.liquid_technologies.ltxmllib20.XmlObjectBase msgSource, int msgType, Object data) { if (msgType == CollectionChangeEvent) { } } private static com.liquid_technologies.ltxmllib20.ParentElementInfo __parentElementInfo = null; private static com.liquid_technologies.ltxmllib20.ElementInfo[] __elementInfo = null; private static com.liquid_technologies.ltxmllib20.AttributeInfo[] __attributeInfo = null; protected com.liquid_technologies.ltxmllib20.ParentElementInfo getClassInfo() throws Exception { if (__parentElementInfo == null) { __parentElementInfo = new com.liquid_technologies.ltxmllib20.ParentElementInfo( com.liquid_technologies.ltxmllib20.XmlObjectBase.XmlElementGroupType.SEQUENCE, com.liquid_technologies.ltxmllib20.XmlObjectBase.XmlElementType.ELEMENT, "CAN_Address", "", true, true, null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_NONE, com.liquid_technologies.ltxmllib20.WhitespaceRule.NONE, null, false); } return __parentElementInfo; } protected com.liquid_technologies.ltxmllib20.ElementInfo[] getClassElementInfo() throws Exception { if (__elementInfo == null) { __elementInfo = new com.liquid_technologies.ltxmllib20.ElementInfo[] { new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("Name", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getName"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setName", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("Street", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getStreet"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setStreet", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("City", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getCity"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setCity", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("Province", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getProvince"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setProvince", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("PostalCode", "", findGetterMethod("DerivedByExtensionLib.CAN_Address", "getPostalCode"), findSetterMethod("DerivedByExtensionLib.CAN_Address", "setPostalCode", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) }; } return __elementInfo; } protected com.liquid_technologies.ltxmllib20.AttributeInfo[] getClassAttributeInfo() throws Exception { if (__attributeInfo==null) { __attributeInfo = new com.liquid_technologies.ltxmllib20.AttributeInfo[] { }; } return __attributeInfo; } // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } |
GBR_Address.java |
package DerivedByExtensionLib; /********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ // <summary> // This class represents the ComplexType GBR_Address // </summary> public class GBR_Address extends com.liquid_technologies.ltxmllib20.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 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 DerivedByExtension.xsd. // </remarks> @Override protected void init() { try { DerivedByExtensionLib.Registration.iRegistrationIndicator = 0; // causes registration to take place _name = ""; _street = ""; _city = ""; _county = ""; _postCode = ""; // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional initialization code here... // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS getClassAttributeInfo(); getClassElementInfo(); } catch (Exception ex) { // should never happen 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(); // clone, creates a bitwise copy of the class, so all the collections are the // same as the parents. Init will re-create our own collections, and classes, // preventing objects being shared between the new an original objects newObject.init(); newObject._name = _name; newObject._street = _street; newObject._city = _city; newObject._county = _county; newObject._postCode = _postCode; // ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional clone code here... // ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS return newObject; } catch (CloneNotSupportedException e) { // should never happen 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.ltxmllib20.exceptions.LtException { return _name; } public void setName(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _street; } public void setStreet(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _city; } public void setCity(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _county; } public void setCounty(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { return _postCode; } public void setPostCode(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException { // Apply whitespace rules appropriately value = com.liquid_technologies.ltxmllib20.WhitespaceUtils.preserve(value); _postCode = value; } protected java.lang.String _postCode; @Override public String getNamespace() { return ""; } @Override public com.liquid_technologies.ltxmllib20.XmlObjectBase getBase() { return this; } protected void onEvent(com.liquid_technologies.ltxmllib20.XmlObjectBase msgSource, int msgType, Object data) { if (msgType == CollectionChangeEvent) { } } private static com.liquid_technologies.ltxmllib20.ParentElementInfo __parentElementInfo = null; private static com.liquid_technologies.ltxmllib20.ElementInfo[] __elementInfo = null; private static com.liquid_technologies.ltxmllib20.AttributeInfo[] __attributeInfo = null; protected com.liquid_technologies.ltxmllib20.ParentElementInfo getClassInfo() throws Exception { if (__parentElementInfo == null) { __parentElementInfo = new com.liquid_technologies.ltxmllib20.ParentElementInfo( com.liquid_technologies.ltxmllib20.XmlObjectBase.XmlElementGroupType.SEQUENCE, com.liquid_technologies.ltxmllib20.XmlObjectBase.XmlElementType.ELEMENT, "GBR_Address", "", true, true, null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_NONE, com.liquid_technologies.ltxmllib20.WhitespaceRule.NONE, null, false); } return __parentElementInfo; } protected com.liquid_technologies.ltxmllib20.ElementInfo[] getClassElementInfo() throws Exception { if (__elementInfo == null) { __elementInfo = new com.liquid_technologies.ltxmllib20.ElementInfo[] { new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("Name", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getName"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setName", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("Street", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getStreet"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setStreet", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("City", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getCity"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setCity", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("County", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getCounty"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setCounty", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("PostCode", "", findGetterMethod("DerivedByExtensionLib.GBR_Address", "getPostCode"), findSetterMethod("DerivedByExtensionLib.GBR_Address", "setPostCode", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) }; } return __elementInfo; } protected com.liquid_technologies.ltxmllib20.AttributeInfo[] getClassAttributeInfo() throws Exception { if (__attributeInfo==null) { __attributeInfo = new com.liquid_technologies.ltxmllib20.AttributeInfo[] { }; } return __attributeInfo; } // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } |
IAddress.java |
/********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ package DerivedByExtensionLib; // <summary> // </summary> public interface IAddress extends com.liquid_technologies.ltxmllib20.XmlObjectInterface { // Member variables // Attribute - Name // <summary> // Represents a mandatory Element in the XML document // </summary> java.lang.String getName() throws com.liquid_technologies.ltxmllib20.exceptions.LtException; void setName(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException; // Attribute - Street // <summary> // Represents a mandatory Element in the XML document // </summary> java.lang.String getStreet() throws com.liquid_technologies.ltxmllib20.exceptions.LtException; void setStreet(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException; // Attribute - City // <summary> // Represents a mandatory Element in the XML document // </summary> java.lang.String getCity() throws com.liquid_technologies.ltxmllib20.exceptions.LtException; void setCity(java.lang.String value) throws com.liquid_technologies.ltxmllib20.exceptions.LtException; // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } |
Person.java |
package DerivedByExtensionLib; /********************************************************************************************** * Copyright (c) 2001-2023 Liquid Technologies Limited. All rights reserved. * See www.liquid-technologies.com for product details. * * Please see products End User License Agreement for distribution permissions. * * WARNING: THIS FILE IS GENERATED * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten * * Generation : by Liquid XML Data Binder 19.0.14.11049 * Using Schema: DerivedByExtension.xsd **********************************************************************************************/ // <summary> // This class represents the Element Person // </summary> public class Person extends com.liquid_technologies.ltxmllib20.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 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 DerivedByExtension.xsd. // </remarks> @Override protected void init() { try { DerivedByExtensionLib.Registration.iRegistrationIndicator = 0; // causes registration to take place _age = (short)0; _homeAddress = null; // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional initialization code here... // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS getClassAttributeInfo(); getClassElementInfo(); } catch (Exception ex) { // should never happen 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(); // clone, creates a bitwise copy of the class, so all the collections are the // same as the parents. Init will re-create our own collections, and classes, // preventing objects being shared between the new an original objects newObject.init(); newObject._age = _age; newObject._homeAddress = null; if (_homeAddress != null) newObject._homeAddress = (DerivedByExtensionLib.IAddress)_homeAddress.clone(); // ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional clone code here... // ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS return newObject; } catch (CloneNotSupportedException e) { // should never happen 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.ltxmllib20.exceptions.LtException { return _age; } public void setAge(short value) throws com.liquid_technologies.ltxmllib20.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.ltxmllib20.exceptions.LtException { throw_IfPropertyIsNull(value, "HomeAddress"); // The object being set needs to take the element name from the class (the type="" attribute will then be set in the XML) if (value != null) setElementName(value.getBase(), "HomeAddress"); _homeAddress = value; } protected DerivedByExtensionLib.IAddress _homeAddress; @Override public String getNamespace() { return ""; } @Override public com.liquid_technologies.ltxmllib20.XmlObjectBase getBase() { return this; } protected void onEvent(com.liquid_technologies.ltxmllib20.XmlObjectBase msgSource, int msgType, Object data) { if (msgType == CollectionChangeEvent) { } } private static com.liquid_technologies.ltxmllib20.ParentElementInfo __parentElementInfo = null; private static com.liquid_technologies.ltxmllib20.ElementInfo[] __elementInfo = null; private static com.liquid_technologies.ltxmllib20.AttributeInfo[] __attributeInfo = null; protected com.liquid_technologies.ltxmllib20.ParentElementInfo getClassInfo() throws Exception { if (__parentElementInfo == null) { __parentElementInfo = new com.liquid_technologies.ltxmllib20.ParentElementInfo( com.liquid_technologies.ltxmllib20.XmlObjectBase.XmlElementGroupType.SEQUENCE, com.liquid_technologies.ltxmllib20.XmlObjectBase.XmlElementType.ELEMENT, "Person", "", true, false, null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_NONE, com.liquid_technologies.ltxmllib20.WhitespaceRule.NONE, null, false); } return __parentElementInfo; } protected com.liquid_technologies.ltxmllib20.ElementInfo[] getClassElementInfo() throws Exception { if (__elementInfo == null) { __elementInfo = new com.liquid_technologies.ltxmllib20.ElementInfo[] { new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqPrimMnd("Age", "", findGetterMethod("DerivedByExtensionLib.Person", "getAge"), findSetterMethod("DerivedByExtensionLib.Person", "setAge", "short"), null, null, com.liquid_technologies.ltxmllib20.Conversions.ConversionType.TYPE_UI1, null, com.liquid_technologies.ltxmllib20.WhitespaceRule.COLLAPSE, new com.liquid_technologies.ltxmllib20.PrimitiveRestrictions("", -1, -1, "", "", "", "", -1, -1, -1), null) ,new com.liquid_technologies.ltxmllib20.data.ElementInfoSeqAbsClsMnd("HomeAddress", "", findGetterMethod("DerivedByExtensionLib.Person", "getHomeAddress"), findSetterMethod("DerivedByExtensionLib.Person", "setHomeAddress", "DerivedByExtensionLib.IAddress"), com.liquid_technologies.ltxmllib20.XmlObjectBase.XmlElementType.ELEMENT, getClassFactoryCreateMethod("DerivedByExtensionLib.ClassFactory", "IAddressCreateObject")) }; } return __elementInfo; } protected com.liquid_technologies.ltxmllib20.AttributeInfo[] getClassAttributeInfo() throws Exception { if (__attributeInfo==null) { __attributeInfo = new com.liquid_technologies.ltxmllib20.AttributeInfo[] { }; } return __attributeInfo; } // ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS // Add Additional Methods and members here... // ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS } |
Main Menu | Samples List |