Author: ssmiweve
Date: 2008-10-21 21:47:38 +0200 (Tue, 21 Oct 2008)
New Revision: 6885

Added:
   trunk/mojo/src/main/java/no/sesat/mojo/modes/AbstractConfig.java
Removed:
   trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigAbstract.java
Modified:
   trunk/mojo/src/main/java/no/sesat/mojo/modes/Builder.java
   trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigAttribute.java
   trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigElement.java
   trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateDTD.java
   trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateFile.java
   trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateRelaxNG.java
   trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateSchemaFile.java
   trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateXSD.java
Log:
In GenerateXSD use unique identifying names for the type declaration within 
complexTypes.
 This allows query-transformers and result-handlers (just one example) to use 
the same names.
Other changes:
 - Abstract prefix to classname,
 - provide getter method to private fields rather than having protected fields,
 - use faster unsynchronised classes where appropriate.


Copied: trunk/mojo/src/main/java/no/sesat/mojo/modes/AbstractConfig.java (from 
rev 6883, trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigAbstract.java)
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/AbstractConfig.java            
                (rev 0)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/AbstractConfig.java    
2008-10-21 19:47:38 UTC (rev 6885)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ *   SESAT is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU Affero General Public License as published 
by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   SESAT is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Affero General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public License
+ *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package no.sesat.mojo.modes;
+
+/**
+ * Abstract configuration object eventually written to schema.
+ *
+ * @version $Id$
+ */
+public class AbstractConfig {
+    private String doc;
+    private String name;
+
+    protected AbstractConfig(final String name){
+        this.name =name;
+    }
+
+    /**
+     * @param name
+     *            Name of this attribute.
+     * @param doc
+     *            Doc for this attribute.
+     */
+    protected AbstractConfig(final String name, final String doc) {
+        this.name = name;
+        this.doc = doc;
+    }
+
+    /**
+     * @return true if it has documentation.
+     */
+    public boolean hasDoc() {
+        return (doc != null && !doc.trim().isEmpty());
+    }
+
+    protected String getDoc(){
+        return doc;
+    }
+
+    protected final void setDoc(final String doc){
+        this.doc = doc;
+    }
+
+    protected String getName(){
+        return name;
+    }
+
+    protected final void setName(final String name){
+        this.name = name;
+    }
+}


Property changes on: 
trunk/mojo/src/main/java/no/sesat/mojo/modes/AbstractConfig.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: trunk/mojo/src/main/java/no/sesat/mojo/modes/Builder.java
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/Builder.java   2008-10-21 
12:27:49 UTC (rev 6884)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/Builder.java   2008-10-21 
19:47:38 UTC (rev 6885)
@@ -24,7 +24,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
-import java.util.Vector;
 
 import com.sun.javadoc.ClassDoc;
 import com.sun.javadoc.RootDoc;
@@ -35,6 +34,8 @@
 import com.sun.tools.javadoc.Messager;
 import com.sun.tools.javadoc.ModifierFilter;
 import com.sun.tools.javadoc.RootDocImpl;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Builder to build a structure that mirrors the structure that should be used
@@ -111,13 +112,13 @@
      */
     public static boolean start(final RootDoc root) {
         final ConfigElement defaultConvert = new 
ConfigElement("default-convert");
-        defaultConvert.attributes.add(new ConfigAttribute("name"));
-        defaultConvert.attributes.add(new ConfigAttribute("prefix"));
-        defaultConvert.attributes.add(new ConfigAttribute("postfix"));
+        defaultConvert.getAttributes().add(new ConfigAttribute("name"));
+        defaultConvert.getAttributes().add(new ConfigAttribute("prefix"));
+        defaultConvert.getAttributes().add(new ConfigAttribute("postfix"));
 
-        final Vector<ConfigElement> commands = new Vector<ConfigElement>();
-        final Vector<ConfigElement> resultHandlers = new 
Vector<ConfigElement>();
-        final Vector<ConfigElement> queryTransformers = new 
Vector<ConfigElement>();
+        final List<ConfigElement> commands = new ArrayList<ConfigElement>();
+        final List<ConfigElement> resultHandlers = new 
ArrayList<ConfigElement>();
+        final List<ConfigElement> queryTransformers = new 
ArrayList<ConfigElement>();
         {
             final ClassDoc[] classes = root.classes();
             for (int i = 0; i < classes.length; i++) {
@@ -138,7 +139,7 @@
                                 return toXmlName(name.substring(0, 
name.lastIndexOf("ResultHandlerConfig")));
                             }
                         });
-                        if (!element.name.isEmpty()) {
+                        if (!element.getName().isEmpty()) {
                             resultHandlers.add(element);
                         }
                     } else if (name.endsWith("QueryTransformer") || 
(name.endsWith("QueryTransformerConfig"))) {
@@ -154,7 +155,7 @@
 
                         queryTransformers.add(element);
                     } else {
-                        System.out.println("Lost: " + element.name); // 
(authorized)
+                        System.out.println("Lost: " + element.getName()); // 
(authorized)
                         System.out.println(                          // 
(authorized)
                                 " non-abstract classes are expected to have 
one of the following suffixes: "
                                 + "CommandConfig, ResultHandlerConfig, 
QueryTransformer, or QueryTransformerConfig");
@@ -164,15 +165,15 @@
         }
 
         final ConfigElement modes = new ConfigElement("modes");
-        modes.attributes.add(new ConfigAttribute("template-prefix"));
+        modes.getAttributes().add(new ConfigAttribute("template-prefix"));
 
         final ConfigElement mode = new ConfigElement("mode");
         // TODO replace with introspection
-        mode.attributes.add(new ConfigAttribute("id"));
-        mode.attributes.add(new ConfigAttribute("inherit"));
-        mode.attributes.add(new ConfigAttribute("analysis"));
-        mode.attributes.add(new ConfigAttribute("executor"));
-        mode.attributes.add(new ConfigAttribute("auto-broadening"));
+        mode.getAttributes().add(new ConfigAttribute("id"));
+        mode.getAttributes().add(new ConfigAttribute("inherit"));
+        mode.getAttributes().add(new ConfigAttribute("analysis"));
+        mode.getAttributes().add(new ConfigAttribute("executor"));
+        mode.getAttributes().add(new ConfigAttribute("auto-broadening"));
 
         mode.addChildren(commands);
         modes.addChild(mode);
@@ -186,12 +187,12 @@
         final ConfigElement navigators = new ConfigElement("navigators");
         final ConfigElement navigator = new ConfigElement("navigator");
         // TODO replace with introspection
-        navigator.attributes.add(new ConfigAttribute("id", null, true));
-        navigator.attributes.add(new ConfigAttribute("name", null, true));
-        navigator.attributes.add(new ConfigAttribute("field", null, true));
-        navigator.attributes.add(new ConfigAttribute("display-name", null, 
true));
-        navigator.attributes.add(new ConfigAttribute("sort", null, false));
-        navigator.attributes.add(new ConfigAttribute("boundary-match"));
+        navigator.getAttributes().add(new ConfigAttribute("id", null, true));
+        navigator.getAttributes().add(new ConfigAttribute("name", null, true));
+        navigator.getAttributes().add(new ConfigAttribute("field", null, 
true));
+        navigator.getAttributes().add(new ConfigAttribute("display-name", 
null, true));
+        navigator.getAttributes().add(new ConfigAttribute("sort", null, 
false));
+        navigator.getAttributes().add(new ConfigAttribute("boundary-match"));
 
         // allow recursive nesting of navigator.
         navigator.addChild(navigator);

Deleted: trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigAbstract.java
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigAbstract.java    
2008-10-21 12:27:49 UTC (rev 6884)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigAbstract.java    
2008-10-21 19:47:38 UTC (rev 6885)
@@ -1,17 +0,0 @@
-package no.sesat.mojo.modes;
-
-/**
- *
- *
- */
-public class ConfigAbstract {
-    protected String doc;
-    protected String name;
-
-    /**
-     * @return true if it has documentation.
-     */
-    public boolean hasDoc() {
-        return (doc != null && !doc.trim().isEmpty());
-    }
-}

Modified: trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigAttribute.java
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigAttribute.java   
2008-10-21 12:27:49 UTC (rev 6884)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigAttribute.java   
2008-10-21 19:47:38 UTC (rev 6885)
@@ -1,3 +1,20 @@
+/*
+ * Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ *   SESAT is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU Affero General Public License as published 
by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   SESAT is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Affero General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public License
+ *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package no.sesat.mojo.modes;
 
 import com.sun.javadoc.MethodDoc;
@@ -5,56 +22,49 @@
 /**
  * Data representing an attribute.
  *
+ * @version $Id$
  */
-public class ConfigAttribute extends ConfigAbstract {
+public class ConfigAttribute extends AbstractConfig {
 
-    protected String type = "CDATA";
-    protected boolean required = false;
+    private String type = "CDATA";
+    private boolean required = false;
 
+    public ConfigAttribute(final String name) {
+        super(name);
+    }
+
     /**
      * @param method Construct this attribute from a Javadoc element.
      */
     public ConfigAttribute(final MethodDoc method) {
-        doc = parseDoc(method);
+        super(Builder.toXmlName(method.name()).substring(4) ,parseDoc(method));
 
-        name = Builder.toXmlName(method.name()).substring(4);
         type = "CDATA"; // method.parameters()[0].toString();
     }
 
     /**
      * @param name
      *            Name of this attribute.
-     */
-    protected ConfigAttribute(final String name) {
-        this.name = name;
-    }
-
-    /**
-     * @param name
-     *            Name of this attribute.
      * @param doc
      *            Doc for this attribute.
-     */
-    protected ConfigAttribute(final String name, final String doc) {
-        this.name = name;
-        this.doc = doc;
-    }
-
-    /**
-     * @param name
-     *            Name of this attribute.
-     * @param doc
-     *            Doc for this attribute.
      * @param required
      *            if this is required attribute or not
      */
     protected ConfigAttribute(final String name, final String doc, final 
boolean required) {
-        this.name = name;
-        this.doc = doc;
+        super(name, doc);
         this.required = required;
     }
 
-    private String parseDoc(final MethodDoc method) {
+    public String getType(){
+        return type;
+    }
+
+    public boolean isRequired(){
+        return required;
+    }
+
+    private static String parseDoc(final MethodDoc method) {
+
         if (method == null) {
             return null;
         }

Modified: trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigElement.java
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigElement.java     
2008-10-21 12:27:49 UTC (rev 6884)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/ConfigElement.java     
2008-10-21 19:47:38 UTC (rev 6885)
@@ -1,3 +1,20 @@
+/*
+ * Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ *   SESAT is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU Affero General Public License as published 
by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   SESAT is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Affero General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public License
+ *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package no.sesat.mojo.modes;
 
 import java.util.List;
@@ -3,39 +20,40 @@
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.Vector;
 
 import com.sun.javadoc.ClassDoc;
 import com.sun.javadoc.MethodDoc;
 import com.sun.javadoc.Parameter;
+import java.util.ArrayList;
 
 /**
  * Represent a class/xml element.
  *
+ * @version $Id$
  */
-public class ConfigElement extends ConfigAbstract {
+public class ConfigElement extends AbstractConfig {
 
-    protected final List<ConfigAttribute> attributes = new 
Vector<ConfigAttribute>();
+    private final List<ConfigAttribute> attributes = new 
ArrayList<ConfigAttribute>();
     private final Set<String> attribNames = new TreeSet<String>();
-    protected final int id;
+    private final int id;
     private static int idCounter = 0;
 
-    protected List<ConfigElement> children = new Vector<ConfigElement>();
+    private List<ConfigElement> children = new ArrayList<ConfigElement>();
 
-    /**
-     * @param name Name of this element.
-     */
     public ConfigElement(final String name) {
+        super(name);
         id = ++idCounter;
-        this.name = name;
     }
 
+    public ConfigElement(final String name, final String doc) {
+        super(name, doc);
+        id = ++idCounter;
+    }
+
     /**
      * @param klass Class that this element should be based on.
      */
     public ConfigElement(final ClassDoc klass) {
-        this(klass.name());
+        this(klass.name(), klass.commentText());
 
-        doc = klass.commentText();
-
         // some fake attributes
         attributes.add(new ConfigAttribute("inherit"));
@@ -44,11 +62,31 @@
         build(klass);
     }
 
+    public String getIdentifyingName(){
+        return getName() + id;
+    }
+
     /**
+     * The live (original) and mutable list of attributes.
+     * @return
+     */
+    public List<ConfigAttribute> getAttributes(){
+        return attributes;
+    }
+
+    /**
+     * The live (original) and mutable list of children.
+     * @return
+     */
+    public List<ConfigElement> getChildren(){
+        return children;
+    }
+
+    /**
      * @param filter filter used to modify the name
      */
     public void applyNameFilter(final NameFilter filter) {
-        name = filter.filter(name);
+        setName(filter.filter(getName()));
     }
 
     /**

Modified: trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateDTD.java
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateDTD.java       
2008-10-21 12:27:49 UTC (rev 6884)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateDTD.java       
2008-10-21 19:47:38 UTC (rev 6885)
@@ -1,3 +1,20 @@
+/*
+ * Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ *   SESAT is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU Affero General Public License as published 
by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   SESAT is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Affero General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public License
+ *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package no.sesat.mojo.modes;
 
 import java.util.Iterator;
@@ -29,44 +46,44 @@
      */
     @Override
     public void runImpl() {
-        println("<?xml version='1.0' encoding='UTF-8'?>\n");
-        println("<!-- " + id + " -->");
+        writeln("<?xml version='1.0' encoding='UTF-8'?>\n");
+        writeln("<!-- " + id + " -->");
         generate(root);
     }
 
     private void generate(final ConfigElement element) {
-        if (written.add(element.name)) {
+        if (written.add(element.getName())) {
 
             if (element.hasDoc()) {
-                println("<!-- " + element.doc + " -->");
+                writeln("<!-- " + element.getDoc() + " -->");
             }
 
-            print("<!ELEMENT " + element.name);
-            if (element.children.isEmpty()) {
-                print(" EMPTY");
+            write("<!ELEMENT " + element.getName());
+            if (element.getChildren().isEmpty()) {
+                write(" EMPTY");
             } else {
-                print(" (");
-                for (int i = 0; i < element.children.size(); i++) {
+                write(" (");
+                for (int i = 0; i < element.getChildren().size(); i++) {
                     if (i > 0) {
-                        print("|");
+                        write("|");
                     }
-                    print(element.children.get(i).name);
+                    write(element.getChildren().get(i).getName());
                 }
-                print(")*");
+                write(")*");
             }
-            println(">");
+            writeln(">");
 
-            generate(element.attributes);
-            printlnI("<!ATTLIST " + element.name + " ");
-            for (final Iterator<ConfigAttribute> iterator = 
element.attributes.iterator(); iterator.hasNext();) {
+            generate(element.getAttributes());
+            writelnI("<!ATTLIST " + element.getName() + " ");
+            for (final Iterator<ConfigAttribute> iterator = 
element.getAttributes().iterator(); iterator.hasNext();) {
                 final ConfigAttribute attrib = iterator.next();
-                print(attrib.name + " ");
+                write(attrib.getName() + " ");
                 generate(attrib);
             }
-            printlnU(">");
+            writelnU(">");
 
-            for (ConfigElement child : element.children) {
-                if (!written.contains(child.name)) {
+            for (ConfigElement child : element.getChildren()) {
+                if (!written.contains(child.getName())) {
                     generate(child);
                 }
             }
@@ -74,19 +91,19 @@
     }
 
     private void generate(final ConfigAttribute attrib) {
-        println(attrib.type + " " + (attrib.required ? "#REQUIRED" : 
"#IMPLIED"));
+        writeln(attrib.getType() + " " + (attrib.isRequired() ? "#REQUIRED" : 
"#IMPLIED"));
     }
 
     private void generate(final List<ConfigAttribute> attributes) {
-        println("<!--");
+        writeln("<!--");
         for (final Iterator<ConfigAttribute> iterator = attributes.iterator(); 
iterator.hasNext();) {
             final ConfigAttribute attrib = iterator.next();
-            print("   @attr " + attrib.name);
+            write("   @attr " + attrib.getName());
             if (attrib.hasDoc()) {
-                print(" " + attrib.doc);
+                write(" " + attrib.getDoc());
             }
-            println("");
+            writeln("");
         }
-        println("-->");
+        writeln("-->");
     }
 }

Modified: trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateFile.java
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateFile.java      
2008-10-21 12:27:49 UTC (rev 6884)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateFile.java      
2008-10-21 19:47:38 UTC (rev 6885)
@@ -1,3 +1,20 @@
+/*
+ * Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ *   SESAT is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU Affero General Public License as published 
by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   SESAT is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Affero General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public License
+ *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package no.sesat.mojo.modes;
 
 import java.io.File;
@@ -56,21 +73,21 @@
      * @param string
      *            String that will be printed
      */
-    protected void printlnI(final String string) {
-        println(string);
+    protected void writelnI(final String string) {
+        writeln(string);
         depth++;
     }
 
     /**
-     * Decrease indention level by one, and print text to file with a newline
+     * Decrease indention level by one, and write text to file with a newline
      * appended.
      *
      * @param string
      *            String that will be printed
      */
-    protected void printlnU(final String string) {
+    protected void writelnU(final String string) {
         depth--;
-        println(string);
+        writeln(string);
     }
 
     /**
@@ -79,7 +96,7 @@
      * @param string
      *            String that will be printed
      */
-    protected void print(final String string) {
+    protected void write(final String string) {
         if (indent) {
             for (int i = 1; i <= depth; i++) {
                 stream.print("    ");
@@ -95,8 +112,8 @@
      * @param string
      *            String that will be printed
      */
-    protected void println(final String string) {
-        print(string + "\n");
+    protected void writeln(final String string) {
+        write(string + "\n");
         indent = true;
     }
 

Modified: trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateRelaxNG.java
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateRelaxNG.java   
2008-10-21 12:27:49 UTC (rev 6884)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateRelaxNG.java   
2008-10-21 19:47:38 UTC (rev 6885)
@@ -1,3 +1,20 @@
+/*
+ * Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ *   SESAT is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU Affero General Public License as published 
by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   SESAT is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Affero General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public License
+ *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package no.sesat.mojo.modes;
 
 import java.util.Iterator;
@@ -30,66 +47,66 @@
     private void generate(final ConfigElement element) {
 
         if (element.hasDoc()) {
-            final String[] docArray = element.doc.split("\n");
+            final String[] docArray = element.getDoc().split("\n");
             for (int i = 0; i < docArray.length; i++) {
-                println("## " + docArray[i]);
+                writeln("## " + docArray[i]);
             }
         }
 
         // prevent blowing the stack. This is because we currently don't 
support
         // recursive elements in this RelaxNG generator.
         boolean empty = true;
-        for (ConfigElement child : element.children) {
-            if (!element.name.equals(child.name)) {
+        for (ConfigElement child : element.getChildren()) {
+            if (!element.getName().equals(child.getName())) {
                 empty = false;
             }
         }
 
-        println("element " + element.name + " {");
+        writeln("element " + element.getName() + " {");
         indent();
-        if (element.attributes.isEmpty() && empty) {
-            print(" empty ");
+        if (element.getAttributes().isEmpty() && empty) {
+            write(" empty ");
         } else {
-            for (final Iterator<ConfigAttribute> iterator = 
element.attributes.iterator(); iterator.hasNext();) {
+            for (final Iterator<ConfigAttribute> iterator = 
element.getAttributes().iterator(); iterator.hasNext();) {
                 final ConfigAttribute attrib = iterator.next();
 
                 generate(attrib);
                 if (iterator.hasNext() || !empty) {
-                    println(",");
+                    writeln(",");
                 } else {
-                    println("");
+                    writeln("");
                 }
             }
         }
 
         if (!empty) {
-            println("(");
+            writeln("(");
             boolean one = false;
-            for (ConfigElement child : element.children) {
-                if (!element.name.equals(child.name)) {
+            for (ConfigElement child : element.getChildren()) {
+                if (!element.getName().equals(child.getName())) {
                     if(one) {
-                        println("|");
+                        writeln("|");
                     } else {
                         one = true;
                     }
                     generate(child);
                 }
             }
-            println(")*");
+            writeln(")*");
         }
         unindent();
-        println("}*");
+        writeln("}*");
 
     }
 
     private void generate(final ConfigAttribute attrib) {
         if (attrib.hasDoc()) {
-            final String[] docArray = attrib.doc.split("\n");
+            final String[] docArray = attrib.getDoc().split("\n");
             for (int i = 0; i < docArray.length; i++) {
-                println("## " + docArray[i]);
+                writeln("## " + docArray[i]);
             }
         }
-        print("attribute " + attrib.name + " { text }" + (attrib.required ? "" 
: "?"));
+        write("attribute " + attrib.getName() + " { text }" + 
(attrib.isRequired() ? "" : "?"));
     }
 
 }

Modified: trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateSchemaFile.java
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateSchemaFile.java        
2008-10-21 12:27:49 UTC (rev 6884)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateSchemaFile.java        
2008-10-21 19:47:38 UTC (rev 6885)
@@ -1,3 +1,20 @@
+/*
+ * Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ *   SESAT is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU Affero General Public License as published 
by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   SESAT is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Affero General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public License
+ *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package no.sesat.mojo.modes;
 
 /**

Modified: trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateXSD.java
===================================================================
--- trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateXSD.java       
2008-10-21 12:27:49 UTC (rev 6884)
+++ trunk/mojo/src/main/java/no/sesat/mojo/modes/GenerateXSD.java       
2008-10-21 19:47:38 UTC (rev 6885)
@@ -1,3 +1,20 @@
+/*
+ * Copyright (2008) Schibsted Søk AS
+ * This file is part of SESAT.
+ *
+ *   SESAT is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU Affero General Public License as published 
by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *
+ *   SESAT is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Affero General Public License for more details.
+ *
+ *   You should have received a copy of the GNU Affero General Public License
+ *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package no.sesat.mojo.modes;
 
 import java.util.Iterator;
@@ -27,52 +44,52 @@
      */
     @Override
     protected void runImpl() {
-        println("<?xml version='1.0'?>");
-        println("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema' 
id='" + id + "'>");
+        writeln("<?xml version='1.0'?>");
+        writeln("<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema' 
id='" + id + "'>");
         indent();
-        println("<xsd:element name='" + root.name + "' type='" + root.name + 
"'/>");
+        writeln("<xsd:element name='" + root.getName() + "' type='" + 
root.getIdentifyingName() + "'/>");
         generate(root);
         unindent();
-        print("</xsd:schema>");
+        write("</xsd:schema>");
     }
 
     private void generate(final ConfigElement element) {
-        if (written.add(element.name)) {
-            printlnI("<xsd:complexType name='" + element.name + "'>");
+        if (written.add(element.getIdentifyingName())) {
+            writelnI("<xsd:complexType name='" + element.getIdentifyingName() 
+ "'>");
             if (element.hasDoc()) {
-                printlnI("<xsd:annotation>");
-                printlnI("<xsd:documentation>");
-                println("<![CDATA[" + element.doc + "]]>)");
-                printlnU("</xsd:documentation>");
-                printlnU("</xsd:annotation>");
+                writelnI("<xsd:annotation>");
+                writelnI("<xsd:documentation>");
+                writeln("<![CDATA[" + element.getDoc() + "]]>)");
+                writelnU("</xsd:documentation>");
+                writelnU("</xsd:annotation>");
             }
 
-            printlnI("<xsd:choice  minOccurs='0' maxOccurs='unbounded'>");
-            for (int i = 0; i < element.children.size(); i++) {
-                final ConfigElement child = element.children.get(i);
-                println("<xsd:element name='" + child.name + "' type='" + 
child.name + "'/>");
+            writelnI("<xsd:choice  minOccurs='0' maxOccurs='unbounded'>");
+            for (int i = 0; i < element.getChildren().size(); i++) {
+                final ConfigElement child = element.getChildren().get(i);
+                writeln("<xsd:element name='" + child.getName() + "' type='" + 
child.getIdentifyingName() + "'/>");
             }
-            printlnU("</xsd:choice>");
+            writelnU("</xsd:choice>");
 
-            for (final Iterator<ConfigAttribute> iterator = 
element.attributes.iterator(); iterator.hasNext();) {
+            for (final Iterator<ConfigAttribute> iterator = 
element.getAttributes().iterator(); iterator.hasNext();) {
                 final ConfigAttribute attrib = iterator.next();
                 if (attrib.hasDoc()) {
-                    printlnI("<xsd:attribute name='" + attrib.name + "'>");
-                    printlnI("<xsd:annotation>");
-                    printlnI("<xsd:documentation>");
-                    println("<![CDATA[" + attrib.doc + "]]>)");
-                    printlnU("</xsd:documentation>");
-                    printlnU("</xsd:annotation>");
-                    printlnU("</xsd:attribute>");
+                    writelnI("<xsd:attribute name='" + attrib.getName() + 
"'>");
+                    writelnI("<xsd:annotation>");
+                    writelnI("<xsd:documentation>");
+                    writeln("<![CDATA[" + attrib.getDoc() + "]]>)");
+                    writelnU("</xsd:documentation>");
+                    writelnU("</xsd:annotation>");
+                    writelnU("</xsd:attribute>");
                 } else {
-                    println("<xsd:attribute name='" + attrib.name + "'/>");
+                    writeln("<xsd:attribute name='" + attrib.getName() + 
"'/>");
                 }
             }
-            printlnU("</xsd:complexType>");
+            writelnU("</xsd:complexType>");
 
         }
-        for (ConfigElement child : element.children) {
-            if (!written.contains(child.name)) {
+        for (ConfigElement child : element.getChildren()) {
+            if (!written.contains(child.getIdentifyingName())) {
                 generate(child);
             }
         }

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to