|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsugar4j.Sugar4j<InstanceBuilder>
sugar4xml.InstanceBuilder
public class InstanceBuilder
Given an existing xml, creates a Sugar4Xml
subclass that writes that very xml
again.
A super class may be set using setSuperClass(Class)
, this has the effect that the
created class extends from that class instead of Sugar4Xml
and element-creation
calls are handled differently.
Given this sample xml data:
<schema xmlns="http://www.w3.org/2001/XMLSchema"> <complexType name="Car"> <attribute type="string" required="true" name="brand"/> </complexType> </schema>Without a super class assigned, the output is:
element("schema", xmlns, "http://www.w3.org/2001/XMLSchema"); { element("complexType", "name", "Car"); { element("attribute", "type", "string", "required", true, "name", "brand").end(); } end(); } end();
With the Xsd super class set (generated using Schema2Package
, like XHtml
):
schema(xmlns, "http://www.w3.org/2001/XMLSchema"); { complexType(name, "Car"); { attribute(type, "string", required, true, name, "brand").end(); } end(); } end();With a super class set, all element and attribute names are left unquoted, thus they will referr to methods/constants of the super class, giving some static type checking. less string literals and less code to write.
The super class is expected to be previously created from Schema2Package
.
Schema2Package
Constructor Summary | |
---|---|
InstanceBuilder(String classss,
Reader xml,
String description)
Constructs a new instance builder. |
Method Summary | |
---|---|
void |
doCreate()
Creates the 'sugar'. |
Class<?> |
getSuperClass()
Returns the class of which this class will extend. |
void |
setSuperClass(Class<?> superClass)
Sets the class of which this class will extend. |
Constructor Detail |
---|
public InstanceBuilder(String classss, Reader xml, String description)
classss
- The full qualified class of the generated java class.xml
- The existing 'template' xmldescription
- A brief description for the generated javadoc commentsMethod Detail |
---|
public void doCreate()
Creator
public Class<?> getSuperClass()
public void setSuperClass(Class<?> superClass)
superClass
-
ClassCastException
- if the superClass is not a subclass of Sugar4Xml
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |