From 9b286c7fbf3b8604b42ec35608f13aa06c316153 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Sun, 18 Nov 2012 06:15:24 +0100 Subject: [PATCH] Changed global element configurator to seperate interface, fixed few javadoc warnings and worked on elddoc html output and added more descriptions in eld. --- build.txt | 2 +- .../java/org/x4o/xml/core/X4ODebugWriter.java | 8 +- .../org/x4o/xml/eld/EldModuleLoaderCore.java | 3 + .../lang/AttributeFromBodyConfigurator.java | 2 +- .../AbstractElementLanguageModule.java | 2 +- .../java/org/x4o/xml/sax/AttributeMap.java | 8 +- .../resources/META-INF/cel/cel-core-1.0.xsd | 15 +- .../resources/META-INF/cel/cel-root-1.0.xsd | 4 +- .../resources/META-INF/eld/eld-conv-1.0.xsd | 2 +- .../resources/META-INF/eld/eld-lang-1.0.xsd | 45 ++++-- .../main/resources/META-INF/eld/eld-lang.eld | 138 +++++++++++++----- .../resources/META-INF/eld/eld-root-1.0.xsd | 4 +- .../java/org/x4o/xml/core/EmptyXmlTest.java | 1 - .../org/x4o/xml/eld/doc/EldDocHtmlWriter.java | 85 +++++------ .../xml/meta/lang/BeanPropertyComparator.java | 4 +- 15 files changed, 203 insertions(+), 120 deletions(-) diff --git a/build.txt b/build.txt index 9a606d0..fd586a3 100644 --- a/build.txt +++ b/build.txt @@ -54,7 +54,7 @@ src/build/gnu-up.sh -- Make site -- cd project-root/; -mvn -Psite-elddoc clean package site site:stage +MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m" mvn -Psite-elddoc clean package site site:stage -- Check for code style -- diff --git a/x4o-core/src/main/java/org/x4o/xml/core/X4ODebugWriter.java b/x4o-core/src/main/java/org/x4o/xml/core/X4ODebugWriter.java index 7ce0819..cf80753 100644 --- a/x4o-core/src/main/java/org/x4o/xml/core/X4ODebugWriter.java +++ b/x4o-core/src/main/java/org/x4o/xml/core/X4ODebugWriter.java @@ -355,10 +355,10 @@ public class X4ODebugWriter { } /** - * Todo move after xpath support - * @param element - * @param buff - * @return + * Todo move after xpath support. + * @param element The element. + * @param buff The buffer. + * @return Returns the buffer of the builf path. */ private StringBuffer getElementPath(Element element,StringBuffer buff) { if (element.getParent()==null) { diff --git a/x4o-core/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java b/x4o-core/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java index c12f709..f5d5895 100644 --- a/x4o-core/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java +++ b/x4o-core/src/main/java/org/x4o/xml/eld/EldModuleLoaderCore.java @@ -150,6 +150,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader { throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e); } + namespace.setId(CEL_CORE); namespace.setUri(CEL_CORE_URI); namespace.setSchemaUri(CEL_CORE_XSD_URI); namespace.setSchemaResource(CEL_CORE_XSD_FILE); @@ -189,6 +190,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader { throw new ElementLanguageModuleLoaderException(this,e.getMessage(),e); } + namespace.setId(CEL_ROOT); namespace.setUri(CEL_ROOT_URI); namespace.setSchemaUri(CEL_ROOT_XSD_URI); namespace.setSchemaResource(CEL_ROOT_XSD_FILE); @@ -285,6 +287,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader { ec.addElementParent("", "configurator"); ec.addElementParent("", "elementInterface"); ec.addElementParent("", "element"); + ec.addElementParent("", "attribute"); elementClassList.add(ec); ec = new DefaultElementClass("elementParent",null,ElementClassAddParentElement.class); diff --git a/x4o-core/src/main/java/org/x4o/xml/eld/lang/AttributeFromBodyConfigurator.java b/x4o-core/src/main/java/org/x4o/xml/eld/lang/AttributeFromBodyConfigurator.java index 2b50c12..106e26e 100644 --- a/x4o-core/src/main/java/org/x4o/xml/eld/lang/AttributeFromBodyConfigurator.java +++ b/x4o-core/src/main/java/org/x4o/xml/eld/lang/AttributeFromBodyConfigurator.java @@ -52,7 +52,7 @@ public class AttributeFromBodyConfigurator extends AbstractElementConfigurator { throw new ElementConfiguratorException(this,"name attribute is empty."); } if (bodyType==null) { - bodyType = "characters"; + bodyType = ElementType.characters.name(); } String value = null; if ("characters".equals(bodyType)) { diff --git a/x4o-core/src/main/java/org/x4o/xml/element/AbstractElementLanguageModule.java b/x4o-core/src/main/java/org/x4o/xml/element/AbstractElementLanguageModule.java index 20f79a7..bcffcc1 100644 --- a/x4o-core/src/main/java/org/x4o/xml/element/AbstractElementLanguageModule.java +++ b/x4o-core/src/main/java/org/x4o/xml/element/AbstractElementLanguageModule.java @@ -138,7 +138,7 @@ public abstract class AbstractElementLanguageModule extends AbstractElementMetaB } /** - * @see org.x4o.xml.element.ElementLanguageModule#addGlobalElementConfigurator(ElementConfigurator) + * @see org.x4o.xml.element.ElementLanguageModule#addElementConfiguratorGlobal(ElementConfiguratorGlobal) */ public void addElementConfiguratorGlobal(ElementConfiguratorGlobal elementConfigurator) { if (elementConfigurator==null) { diff --git a/x4o-core/src/main/java/org/x4o/xml/sax/AttributeMap.java b/x4o-core/src/main/java/org/x4o/xml/sax/AttributeMap.java index d2978d8..913c2b4 100644 --- a/x4o-core/src/main/java/org/x4o/xml/sax/AttributeMap.java +++ b/x4o-core/src/main/java/org/x4o/xml/sax/AttributeMap.java @@ -125,8 +125,7 @@ public class AttributeMap implements Map { /** * Gets the value of the attributes. uses the uri if not null. * - * @param name - * The name of the attributes. + * @param name The name of the attributes. * @return The value of the attribute. */ private String getValue(String name) { @@ -140,9 +139,8 @@ public class AttributeMap implements Map { } /** - * @see getValue(String name) - * @param key - * The name of the attribute. + * Gets the attribute value. + * @param key The name of the attribute. * @return The value of the attribute. */ private String getValue(Object key) { diff --git a/x4o-core/src/main/resources/META-INF/cel/cel-core-1.0.xsd b/x4o-core/src/main/resources/META-INF/cel/cel-core-1.0.xsd index 62b7761..3ea1038 100644 --- a/x4o-core/src/main/resources/META-INF/cel/cel-core-1.0.xsd +++ b/x4o-core/src/main/resources/META-INF/cel/cel-core-1.0.xsd @@ -7,7 +7,7 @@ ModuleName: Core Element Languag Module Namespaces: 2 Namespace: http://cel.x4o.org/xml/ns/cel-core - Created on: Sun Nov 18 03:27:37 CET 2012 + Created on: Sun Nov 18 05:10:55 CET 2012 --> + - - + @@ -43,13 +43,13 @@ - - + + @@ -75,6 +75,7 @@ + @@ -83,8 +84,8 @@ - + @@ -105,8 +106,8 @@ - + diff --git a/x4o-core/src/main/resources/META-INF/cel/cel-root-1.0.xsd b/x4o-core/src/main/resources/META-INF/cel/cel-root-1.0.xsd index 659b78b..c737f78 100644 --- a/x4o-core/src/main/resources/META-INF/cel/cel-root-1.0.xsd +++ b/x4o-core/src/main/resources/META-INF/cel/cel-root-1.0.xsd @@ -7,7 +7,7 @@ ModuleName: Core Element Languag Module Namespaces: 2 Namespace: http://cel.x4o.org/xml/ns/cel-root - Created on: Sun Nov 18 03:27:37 CET 2012 + Created on: Sun Nov 18 05:10:55 CET 2012 --> - + \ No newline at end of file diff --git a/x4o-core/src/main/resources/META-INF/eld/eld-conv-1.0.xsd b/x4o-core/src/main/resources/META-INF/eld/eld-conv-1.0.xsd index a71162d..8d1bbf3 100644 --- a/x4o-core/src/main/resources/META-INF/eld/eld-conv-1.0.xsd +++ b/x4o-core/src/main/resources/META-INF/eld/eld-conv-1.0.xsd @@ -7,7 +7,7 @@ ModuleName: Element Language Definition Namespaces: 3 Namespace: http://eld.x4o.org/xml/ns/eld-conv - Created on: Sun Nov 18 03:32:55 CET 2012 + Created on: Sun Nov 18 05:06:09 CET 2012 --> - + - + @@ -53,11 +53,11 @@ + + - - @@ -121,14 +121,15 @@ + - - - + + + @@ -176,7 +177,12 @@ - + + + Defines an namespace for the language. + + + An ELD elementDescription field which lets you type text like this one in xml characters instead of an attribute. @@ -189,7 +195,12 @@ - + + + The xml element. + + + Defines an alias for an attribute name. @@ -226,7 +237,12 @@ - + + + XML Element Attribute tag. + + + Define an className in bean.class for an ElementBindingHandler interface. @@ -245,7 +261,12 @@ - + + + Config element objects by java interface. + + + Adds an parent element tag for xsd diff --git a/x4o-core/src/main/resources/META-INF/eld/eld-lang.eld b/x4o-core/src/main/resources/META-INF/eld/eld-lang.eld index 2071737..0fc932c 100644 --- a/x4o-core/src/main/resources/META-INF/eld/eld-lang.eld +++ b/x4o-core/src/main/resources/META-INF/eld/eld-lang.eld @@ -52,7 +52,9 @@ > - + + The module id. + The module root element. @@ -68,55 +70,89 @@ - + Defines an namespace for the language. + + The namespace id. + + The xml element. + The class of the wrapped object. - + + An custom element class to config object. - + Config element objects by java interface. + + The interface id. + + The interface class. - + + XML Element Attribute tag. + Define an className in bean.class for an ElementBindingHandler interface. - - + + The binding handler id. + + + The class of the binding handler. + Define an className in bean.class for an ElementAttributeHandler. - - - + + The atttribute handler id. + + + The class of the attribute handler. + + + The xml attribute name. + Define an className in bean.class for an ElementConfiguratorGlobal. - - - + + The global element configurator id. + + + The class of the element configurator. + + + If set to true then run in config phase. + Define an className in bean.class for an ElementConfigurator. - - - + + The element configurator id. + + + The class of the global element configurator. + + + If set to true then run in config phase. + @@ -129,6 +165,7 @@ + @@ -139,48 +176,69 @@ Adds an parent element tag for xsd - - + + The parent tag to have object for. + + + The element namespace uri if non local. + Adds an phase to skip to the parent element. - + + The name of the phase to skip. + Defines the parameter order. - + + The attribute name to run after this attribute. + Defines an alias for an attribute name. - + + The alias name to add to the attribute. + Defines an alias for an attribute name. - - - + + The id for this configurator. + + + The attribute name to fill the value. + + + See org.x4o.xml.element.Element.ElementType for options defaults to 'characters'. + Lets you dynamicly bind to object togecher. - + + The id for this binding handler. + + The parent class. + The child class. + The method name of the method used to add the child to the parent. @@ -190,7 +248,9 @@ Loads bean into the Element - + + The class name of the the class to load. + @@ -204,11 +264,14 @@ schemaResource="eld-conv-1.0.xsd" schemaPrefix="conv" name="Element Attribute Converters" + id="eld-conv" > Define an loadable in bean.class for an ObjectConverter. - + + The class name of the converter to load. + @@ -224,17 +287,20 @@ - - - - - + + The class name to convert the string to. + + + + + + - - - - + + + + \ No newline at end of file diff --git a/x4o-core/src/main/resources/META-INF/eld/eld-root-1.0.xsd b/x4o-core/src/main/resources/META-INF/eld/eld-root-1.0.xsd index c571920..2c32eae 100644 --- a/x4o-core/src/main/resources/META-INF/eld/eld-root-1.0.xsd +++ b/x4o-core/src/main/resources/META-INF/eld/eld-root-1.0.xsd @@ -7,7 +7,7 @@ ModuleName: Element Language Definition Namespaces: 3 Namespace: http://eld.x4o.org/xml/ns/eld-root - Created on: Sun Nov 18 03:32:55 CET 2012 + Created on: Sun Nov 18 05:06:09 CET 2012 --> + - diff --git a/x4o-core/src/test/java/org/x4o/xml/core/EmptyXmlTest.java b/x4o-core/src/test/java/org/x4o/xml/core/EmptyXmlTest.java index d42d2a2..cc68c5f 100644 --- a/x4o-core/src/test/java/org/x4o/xml/core/EmptyXmlTest.java +++ b/x4o-core/src/test/java/org/x4o/xml/core/EmptyXmlTest.java @@ -91,7 +91,6 @@ public class EmptyXmlTest extends TestCase { try { parser.parseResource("tests/empty-xml/empty-xml.xml"); } catch (SAXException e) { - e.printStackTrace(); boolean hasError = e.getMessage().contains("Premature end of file."); // java6+ sax message if (hasError==false) { hasError = e.getMessage().contains("A well-formed document requires a root element."); // xercesImpl sax message diff --git a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java index 2ce70fc..0d8cd7c 100644 --- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java +++ b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/EldDocHtmlWriter.java @@ -111,18 +111,15 @@ public class EldDocHtmlWriter { pw.write("\n\n"); pw.flush(); pw.print("body { background-color: #FFFFFF; color:#000000 }\n"); - pw.print("h1 { font-size: 145% }\n"); - pw.print(".TableHeadingColor { background: #CCCCFF; color:#000000 }\n"); + pw.print("h1 { font-size: 145%;text-align: center; }\n"); + pw.print(".Copyright { font-size: 70%;text-align: center; }\n"); + pw.print(".TableHeadingColor { background: #CCCCFF; color:#000000;font-weight: bold;font-size: 110%; }\n"); pw.print(".TableSubHeadingColor { background: #EEEEFF; color:#000000 }\n"); pw.print(".TableRowColor { background: #FFFFFF; color:#000000 }\n"); - pw.print(".FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }\n"); - pw.print(".FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }\n"); - pw.print(".FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }\n"); pw.print(".NavBarCell1 { background-color:#EEEEFF; color:#000000}\n"); pw.print(".NavBarCell1Rev { background-color:#00008B; color:#FFFFFF}\n"); - pw.print(".NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;}\n"); - pw.print(".NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;}\n"); - pw.print(".NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}\n"); + pw.print(".NavBarCell1 a { font-size: 120%;font-weight: bold;}\n"); + pw.print(".NavBarCell2 { font-size: 80%;font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}\n"); pw.print(".NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}\n"); pw.flush(); } finally { @@ -517,40 +514,38 @@ public class EldDocHtmlWriter { private void printTableStart(PrintWriter pw,String title) { pw.print("\n"); - pw.print("\n"); - pw.print("\n"); + pw.print("\t\t\n\n"); + pw.print("\n\t\n"); } private void printTableRowSummary(PrintWriter pw,String name,String description) { - pw.print("\n"); - pw.print("\n"); + pw.print("\t\t\n"); - pw.print("\n"); - pw.print("\n"); + pw.print("\t\t\n"); + pw.print("\t\n"); } private void printTableRowOverview(PrintWriter pw,String href,String hrefTitle,String description) { - pw.print("\n"); - pw.print("\n"); - pw.print("\n"); + pw.print("\t\t\n"); - pw.print("\n"); + pw.print("\t\t\n"); + pw.print("\t\n"); } private void printTableEnd(PrintWriter pw) { @@ -573,13 +568,13 @@ public class EldDocHtmlWriter { } private void printPageIndexTitle(PrintWriter pw,String title,String titleContext,String description) { - pw.print("

"); + pw.print("

"); pw.print(title); pw.print(" "); if (titleContext!=null) { pw.print(titleContext); } - pw.print("

\n"); + pw.print("\n"); if (description!=null) { pw.print(description); } @@ -609,25 +604,23 @@ public class EldDocHtmlWriter { pw.print("\n"); pw.print("
\n"); - pw.print(""); + pw.print("\t
\n"); pw.print(title); - pw.print(""); - pw.print("
"); + pw.print("\t
"); pw.print(name); pw.print("\n"); + pw.print("\t\t"); if (description!=null) { pw.print(description); } - pw.print("
\n"); + pw.print("\t\t"); pw.print(hrefTitle); - pw.print("\n"); + pw.print(""); if (description!=null) { pw.print(description); } - pw.print("
\n"); pw.print("\n"); - pw.print("\n"); - pw.print(""); + pw.print(""); pw.print("\n"); pw.print("\n"); - pw.print("\n"); - pw.print("\n"); + pw.print("\n"); + pw.print("\n"); pw.print("\n"); pw.print("
\n"); + pw.print("\n"); pw.print("\n"); pw.print("\n"); - pw.print("\n"); - //pw.print("\n"); + pw.print("\t\n"); printNavBar(pw,pathPrefix); - - pw.print("\n"); + pw.print("\t\n"); pw.print("
 Overview 
\n"); pw.print("
\n\n
\n"); - pw.print(" PREV  NEXT...\n"); + pw.print(" PREV  NEXT
\n"); @@ -645,23 +638,23 @@ public class EldDocHtmlWriter { pw.print("\n"); pw.print("\n"); pw.print("\n"); - pw.print("\n"); - pw.print(""); + pw.print(""); pw.print("\n"); pw.print("\n"); - pw.print("\n"); - pw.print("\n"); + pw.print("\n"); + pw.print("\n"); pw.print("\n"); pw.print("
\n"); + pw.print("\n"); pw.print("\n"); pw.print("\n"); - pw.print("\n"); + pw.print("\t\n"); printNavBar(pw,pathPrefix); - pw.print("\n"); + pw.print("\t\n"); pw.print("
\n"); pw.print("
\n\n
\n"); - pw.print(" PREV  NEXT...\n"); + pw.print(" PREV  NEXT
\n"); @@ -669,7 +662,9 @@ public class EldDocHtmlWriter { pw.print("
\n"); pw.print("\n"); + pw.print("
"); pw.print("Copyright © todo. All Rights Reserved.\n"); + pw.print("
\n"); pw.print("\n"); pw.print("\n"); @@ -678,8 +673,8 @@ public class EldDocHtmlWriter { } private void printNavBar(PrintWriter pw,String pathPrefix) throws IOException { - pw.print("Index \n"); - pw.print("Modules \n"); - pw.print("Namespaces \n"); + pw.print("\t\tIndex \n"); + pw.print("\t\tModules \n"); + pw.print("\t\tNamespaces \n"); } } diff --git a/x4o-meta/src/main/java/org/x4o/xml/meta/lang/BeanPropertyComparator.java b/x4o-meta/src/main/java/org/x4o/xml/meta/lang/BeanPropertyComparator.java index 8180b3a..7bfd5ba 100644 --- a/x4o-meta/src/main/java/org/x4o/xml/meta/lang/BeanPropertyComparator.java +++ b/x4o-meta/src/main/java/org/x4o/xml/meta/lang/BeanPropertyComparator.java @@ -114,8 +114,8 @@ public class BeanPropertyComparator implements Comparator { /** * Returns the Comparable property of the object. - * @param object - * @return + * @param object The object to get the property field of. + * @return Returns the Comparable casted object of the property field of the object. * @throws ClassCastException */ @SuppressWarnings("unchecked")