From d4f80f338a2045bd17262371aef7931256391ed4 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Fri, 9 Aug 2013 19:34:52 +0200 Subject: [PATCH] Updated buid info and made package list consistant. --- build.txt | 11 +++-- src/site/apt/examples/start-language.apt | 4 ++ src/site/apt/usage.apt | 2 +- .../src/main/java/org/x4o/xml/X4ODriver.java | 4 +- .../java/org/x4o/xml/X4ODriverManager.java | 10 +++++ .../java/org/x4o/xml/conv/package-info.java | 2 +- .../org/x4o/xml/conv/text/package-info.java | 2 +- .../org/x4o/xml/io/sax/ext/package-info.java | 29 +++++++++++++ .../java/org/x4o/xml/io/sax/package-info.java | 2 +- .../xml/eld/doc/api/ApiDocNodeWriterBean.java | 28 +++++++----- .../eld/doc/api/ApiDocNodeWriterMethod.java | 2 +- .../org/x4o/xml/eld/doc/api/ApiDocWriter.java | 43 ++++++++++++++++++- .../xml/eld/doc/api/dom/ApiDocNodeWriter.java | 1 + .../x4o/xml/eld/doc/api/dom/package-info.java | 2 +- .../org/x4o/xml/eld/doc/api/package-info.java | 2 +- .../java/org/x4o/plugin/ant/package-info.java | 2 +- .../org/x4o/plugin/maven/package-info.java | 2 +- 17 files changed, 122 insertions(+), 26 deletions(-) create mode 100644 x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/package-info.java diff --git a/build.txt b/build.txt index 1e02d93..fd288d7 100644 --- a/build.txt +++ b/build.txt @@ -41,8 +41,9 @@ src/main/build/jvm-test.sh /usr/lib/jvm/jdk1.5.0_22/ -- Make release build -- -# todo make work -cd project-root/; +cd /tmp; +git clone ssh://@git.sv.gnu.org/srv/git/x4o.git; +cd x4o; mvn clean package; mvn -B -Dusername= clean install release:clean release:prepare release:perform; src/main/build/gnu-up.sh @@ -51,8 +52,10 @@ src/main/build/gnu-up.sh -- Make site -- cd project-root/; -MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m" mvn -Pbuild-site-x4o-support clean package site site:stage - +mvn clean install; # (installs the snapshots plugins so we can run the current eld-doc task in site phase) +MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m" mvn -Pbuild-site-x4o-support clean package site site:stage; +cp -r target/staging/x4o-* target/site/; +cp -r target/site/ ~/public_html/site-x4o; -- Check for code style -- diff --git a/src/site/apt/examples/start-language.apt b/src/site/apt/examples/start-language.apt index 0a9176c..d464d83 100644 --- a/src/site/apt/examples/start-language.apt +++ b/src/site/apt/examples/start-language.apt @@ -53,6 +53,9 @@ public class TestFooBarDriver extends X4ODriver { return LANGUAGE_VERSIONS; } + // Convenience method not really needed but like this it limits a few non-needed objects. + // and does makes sure only only one instance is registered to the X4ODriverManager. + // thus it is currently the preferred way to create and get an instance of your language driver. static public TestFooBarDriver getInstance() { return (TestFooBarDriver)X4ODriverManager.getX4ODriver(LANGUAGE_NAME); } @@ -172,6 +175,7 @@ writer.writeFile(result, new File("/tmp/test-bean.xml"); +-- And writer gives output like; + (please note that full write support is not yet completed) +-- diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt index c7e0e99..1945cc6 100644 --- a/src/site/apt/usage.apt +++ b/src/site/apt/usage.apt @@ -64,7 +64,7 @@ Usage org.x4o.plugin x4o-plugin-ant - ${project.version} + 0.8.6-SNAPSHOT +-- diff --git a/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java b/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java index cee4da5..fe6fb64 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java +++ b/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java @@ -48,9 +48,9 @@ public abstract class X4ODriver { public final static String DEFAULT_LANGUAGE_VERSION = "1.0"; /** - * Public constructor. + * marker constructor. */ - public X4ODriver() { + public X4ODriver(/*X4ODriverManager.ConstructorMarker marker*/) { } /** diff --git a/x4o-driver/src/main/java/org/x4o/xml/X4ODriverManager.java b/x4o-driver/src/main/java/org/x4o/xml/X4ODriverManager.java index f8f41a3..a50a4a6 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/X4ODriverManager.java +++ b/x4o-driver/src/main/java/org/x4o/xml/X4ODriverManager.java @@ -207,6 +207,8 @@ public final class X4ODriverManager { } try { Class driverClass = X4OLanguageClassLoader.loadClass(driverClassName); + //Constructor markedConstructor = driverClass.getDeclaredConstructor(new Class[]{ConstructorMarker.class}); + //X4ODriver driver = (X4ODriver)markedConstructor.newInstance(new Object[]{new ConstructorMarker()}); X4ODriver driver = (X4ODriver)driverClass.newInstance(); registerX4ODriver(driver); return driver; @@ -215,6 +217,14 @@ public final class X4ODriverManager { } } + /* + * Class to make sure all driver instances are created by this manager instance. + + final public class ConstructorMarker { + private ConstructorMarker() { + } + }*/ + /** * Loads all defined language drivers in classpath. */ diff --git a/x4o-driver/src/main/java/org/x4o/xml/conv/package-info.java b/x4o-driver/src/main/java/org/x4o/xml/conv/package-info.java index a19ad50..7b4a3a5 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/conv/package-info.java +++ b/x4o-driver/src/main/java/org/x4o/xml/conv/package-info.java @@ -21,7 +21,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** - * Provides interfaces for two way object converters. + * The interfaces for two way object converters. * * * @since 1.0 diff --git a/x4o-driver/src/main/java/org/x4o/xml/conv/text/package-info.java b/x4o-driver/src/main/java/org/x4o/xml/conv/text/package-info.java index 79fcc1b..75cd5a1 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/conv/text/package-info.java +++ b/x4o-driver/src/main/java/org/x4o/xml/conv/text/package-info.java @@ -21,7 +21,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** - * Provides implementations of object to text converters. + * The default implementations to convert text to objects. * * * @since 1.0 diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/package-info.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/package-info.java new file mode 100644 index 0000000..130d007 --- /dev/null +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/ext/package-info.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2004-2013, Willem Cazander + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * The SAX Extended classes and interfaces. + * + * @since 1.0 + */ + +package org.x4o.xml.io.sax.ext; diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/package-info.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/package-info.java index 9d556be..8f75712 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/package-info.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/package-info.java @@ -21,7 +21,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** - * The Sax based classes and interfaces. + * The SAX based classes and interfaces. * * @since 1.0 */ diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterBean.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterBean.java index e7229ca..fb5e79e 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterBean.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterBean.java @@ -42,7 +42,7 @@ import org.xml.sax.SAXException; public class ApiDocNodeWriterBean implements ApiDocNodeWriter { private ApiDocNodeBody nodeBody = null; - private Integer nodeBodyOrder = null; + private List nodeBodyOrders = null; private Object bean = null; private String method = null; private List> targetClasses = null; @@ -75,10 +75,18 @@ public class ApiDocNodeWriterBean implements ApiDocNodeWriter { if (ammo==null) { continue; } - ApiDocNodeWriterBean methodWriter = new ApiDocNodeWriterBean(ammo.nodeBody(), bean, method.getName(), ammo.targetClasses()); - if (ammo.nodeBodyOrder()!=-1) { - methodWriter.setNodeBodyOrder(ammo.nodeBodyOrder()); + if (ammo.targetClasses().length==0) { + throw new IllegalArgumentException("Can't configure writer bean with empty 'targetClasses' parameter."); } + if (ammo.targetClasses().length!=ammo.nodeBodyOrders().length) { + throw new IllegalArgumentException("Can't configure writer bean with non-equal array size of 'nodeBodyOrders'("+ammo.nodeBodyOrders().length+") and 'targetClasses'("+ammo.targetClasses().length+") parameters."); + } + ApiDocNodeWriterBean methodWriter = new ApiDocNodeWriterBean(ammo.nodeBody(), bean, method.getName(), ammo.targetClasses()); + List nodeBodyOrder = new ArrayList(); + for (int order:ammo.nodeBodyOrders()) { + nodeBodyOrder.add(order); + } + methodWriter.setNodeBodyOrders(nodeBodyOrder); if (ammo.contentGroup().length()>0) { methodWriter.setContentGroup(ammo.contentGroup()); } @@ -154,17 +162,17 @@ public class ApiDocNodeWriterBean implements ApiDocNodeWriter { } /** - * @return the nodeBodyOrder + * @return the nodeBodyOrders */ - public Integer getNodeBodyOrder() { - return nodeBodyOrder; + public List getNodeBodyOrders() { + return nodeBodyOrders; } /** - * @param nodeBodyOrder the nodeBodyOrder to set + * @param nodeBodyOrders the nodeBodyOrders to set */ - public void setNodeBodyOrder(Integer nodeBodyOrder) { - this.nodeBodyOrder = nodeBodyOrder; + public void setNodeBodyOrders(List nodeBodyOrders) { + this.nodeBodyOrders = nodeBodyOrders; } /** diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterMethod.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterMethod.java index 04081b3..6666d45 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterMethod.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocNodeWriterMethod.java @@ -43,7 +43,7 @@ public @interface ApiDocNodeWriterMethod { ApiDocNodeBody nodeBody(); - int nodeBodyOrder() default -1; + int[] nodeBodyOrders() default {-1}; String contentGroup() default ""; diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocWriter.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocWriter.java index f422cf4..0c0ef9f 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocWriter.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/ApiDocWriter.java @@ -34,6 +34,8 @@ import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -387,7 +389,7 @@ public class ApiDocWriter { private List findNodeBodyWriters(ApiDocNode node,ApiDocNodeBody nodeBody) { List result = new ArrayList(); - Class objClass = node.getUserData().getClass(); + final Class objClass = node.getUserData().getClass(); for (ApiDocNodeWriter writer:doc.getNodeBodyWriters()) { if (!nodeBody.equals(writer.getNodeBody())) { continue; @@ -398,6 +400,45 @@ public class ApiDocWriter { } } } + Collections.sort(result, new Comparator() { + public int compare(ApiDocNodeWriter o1, ApiDocNodeWriter o2) { + int index1 = -1; + int index2 = -1; + for (int i=0;i c = o1.getTargetClasses().get(i); + if (c.isAssignableFrom(objClass)) { + index1 = i; + break; + } + } + for (int i=0;i c = o2.getTargetClasses().get(i); + if (c.isAssignableFrom(objClass)) { + index1 = i; + break; + } + } + // TODO: note check return value if are oke in order.. + if (index1==-1 && index2==-1) { + return 0; + } + if (index1==-1) { + return 1; + } + if (index2==-1) { + return -1; + } + int orderValue1 = o1.getNodeBodyOrders().get(index1); + int orderValue2 = o2.getNodeBodyOrders().get(index2); + if (orderValue1==orderValue2) { + return 0; + } + if (orderValue1 > orderValue2) { + return -1; + } + return 1; + } + }); return result; } diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeWriter.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeWriter.java index c0659f0..fa668f0 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeWriter.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/ApiDocNodeWriter.java @@ -36,6 +36,7 @@ public interface ApiDocNodeWriter { ApiDocNodeBody getNodeBody(); List> getTargetClasses(); + List getNodeBodyOrders(); void writeNodeContent(ApiDocWriteEvent e) throws SAXException; } diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/package-info.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/package-info.java index 714f1cc..f45d798 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/package-info.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/dom/package-info.java @@ -22,7 +22,7 @@ */ /** - * Api Doc Dom classes. + * The Api Doc Dom classes. * * @author Willem Cazander * @since 1.0 May 12,2013 diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/package-info.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/package-info.java index 8a72477..3a2e753 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/package-info.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/api/package-info.java @@ -22,7 +22,7 @@ */ /** - * Api Doc Writer classes. + * The Api Doc Writer classes. * * @author Willem Cazander * @since 1.0 May 12,2013 diff --git a/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/package-info.java b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/package-info.java index 54af185..ac7995c 100644 --- a/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/package-info.java +++ b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/package-info.java @@ -21,7 +21,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** - * The ant plugin tasks. + * The Ant plugin tasks. * * @since 1.0 */ diff --git a/x4o-plugin/x4o-plugin-maven/src/main/java/org/x4o/plugin/maven/package-info.java b/x4o-plugin/x4o-plugin-maven/src/main/java/org/x4o/plugin/maven/package-info.java index a19b561..ccd7d61 100644 --- a/x4o-plugin/x4o-plugin-maven/src/main/java/org/x4o/plugin/maven/package-info.java +++ b/x4o-plugin/x4o-plugin-maven/src/main/java/org/x4o/plugin/maven/package-info.java @@ -21,7 +21,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** - * The maven plugin mojos. + * The Maven plugin mojos. * * @since 1.0 */