Author: tfennelly
Date: 2010-06-04 04:03:49 -0400 (Fri, 04 Jun 2010)
New Revision: 22539
Added:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/TemplatingModelBuilder.java
Removed:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/ModelBuilder.java
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/ModelNodeResolver.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/csv/CSVModelBuilder.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/xml/XMLSampleModelBuilder.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/xml/XSDModelBuilder.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/TemplateBuilder.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/csv/CSVFreeMarkerTemplateBuilder.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/xml/XMLFreeMarkerTemplateBuilder.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerAttrModel.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerModelAnalyzer.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateModelLabelProvider.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateXMLModel.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateContentGraphModelProviderImpl.java
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/SmooksFreemarkerTemplateGraphicalEditor.java
Log:
Renamed the templating ModelBuilder class to TemplatingModelBuilder, so as not to clash
with the Dynamic ModelBuilder class in Smooks
Deleted:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/ModelBuilder.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/ModelBuilder.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/ModelBuilder.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -1,272 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.tools.smooks.templating.model;
-
-import java.util.Properties;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.milyn.xml.DomUtils;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
-
-/**
- * Abstract message model builder.
- *
- * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
- */
-public abstract class ModelBuilder {
-
- public static final String NAMESPACE =
"http://www.jboss.org/xsd/tools/smooks"; // TODO: Make same as JBT eclipse
extension namespace ?? //$NON-NLS-1$
- public static final String REQUIRED = "#required"; //$NON-NLS-1$
- public static final String OPTIONAL = "#optional"; //$NON-NLS-1$
-
- private static final String HIDDEN_ELEMENT = "hidden"; //$NON-NLS-1$
-
- public static enum ElementType {
- simple,
- complex
- }
-
- private Properties namespaces = new Properties();
-
- /**
- * Build the message model.
- * @return The message model.
- * @throws ModelBuilderException Error building model.
- */
- public abstract Document buildModel() throws ModelBuilderException;
-
- /**
- * Get the namespace prefix-to-URI mappings for this model.
- * @return The namespace prefix-to-URI mappings for this model.
- */
- public Properties getNamespaces() {
- return namespaces;
- }
-
-
-
- /**
- * Mark a fragment as being hidden.
- * <p/>
- * When hidden, it is illegal to attempt a mapping onto a fragment.
- *
- * @param fragment The fragment to be marked as hidden.
- */
- public static void hideFragment(Element fragment) {
- fragment.setAttributeNS(NAMESPACE, HIDDEN_ELEMENT, "true");
//$NON-NLS-1$
- }
-
- /**
- * Unmark a fragment as being hidden.
- * <p/>
- * When hidden, it is illegal to attempt a mapping onto a fragment.
- *
- * @param fragment The fragment to be unmarked as hidden.
- */
- public static void unhideFragment(Element fragment) {
- fragment.removeAttributeNS(NAMESPACE, HIDDEN_ELEMENT);
- }
-
- /**
- * Is the specified node marked as being hidden.
- * <p/>
- * When hidden, it is illegal to attempt a mapping onto a fragment.
- *
- * @return True if the node is hidden, otherwise false.
- */
- public static boolean isHidden(Node node) {
- if(node != null) {
- switch(node.getNodeType()) {
- case Node.ATTRIBUTE_NODE :
- return isHidden(node.getParentNode());
- case Node.ELEMENT_NODE :
- if(((Element)node).getAttributeNS(NAMESPACE,
HIDDEN_ELEMENT).equals("true")) { //$NON-NLS-1$
- return true;
- }
- return isHidden(node.getParentNode());
- }
- }
-
- return false;
- }
-
- /**
- * Is the specified node required.
- * <p/>
- * For an Element node, this means does it have a minOccurs > 0. For an Attr
node,
- * it means is its value set to "#REQUIRED".
- *
- * @return True if the node is hidden, otherwise false.
- */
- public static boolean isRequired(Node node) {
- if(node != null) {
- switch(node.getNodeType()) {
- case Node.ATTRIBUTE_NODE :
- return (REQUIRED.equals(node.getTextContent()) ||
XMLConstants.XML_NS_URI.equals(node.getNamespaceURI()));
- case Node.ELEMENT_NODE :
- if(getMinOccurs((Element) node) > 0) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Is the specified node in the reserved namespace.
- *
- * @return True if the node is in the reserved namespace, otherwise false.
- */
- public static boolean isInReservedNamespace(Node node) {
- if(node != null) {
- return NAMESPACE.equals(node.getNamespaceURI());
- }
-
- return false;
- }
-
- protected Document createModelInstance() throws ModelBuilderException {
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder;
-
- try {
- builder = builderFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- throw new ModelBuilderException("Error constructing DOM
DocumentBuilder.", e); //$NON-NLS-1$
- }
-
- return builder.newDocument();
- }
-
- public static void setMinMax(Element element, int minOccurs, int maxOccurs) {
- element.setAttributeNS(NAMESPACE, "smk:minOccurs",
Integer.toString(minOccurs)); //$NON-NLS-1$
- element.setAttributeNS(NAMESPACE, "smk:maxOccurs",
Integer.toString(maxOccurs)); //$NON-NLS-1$
- }
-
- public static Node getParentNode(Node node) {
- if(node.getNodeType() == Node.ATTRIBUTE_NODE) {
- return ((Attr)node).getOwnerElement();
- } else {
- return node.getParentNode();
- }
- }
-
- public static int getMinOccurs(Element element) {
- String minOccurs = element.getAttributeNS(NAMESPACE, "minOccurs");
//$NON-NLS-1$
-
- if(minOccurs.equals("")) { //$NON-NLS-1$
- return 1;
- }
-
- return Integer.parseInt(minOccurs);
- }
-
- public static int getMaxOccurs(Element element) {
- String maxOccurs = element.getAttributeNS(NAMESPACE, "maxOccurs");
//$NON-NLS-1$
-
- if(maxOccurs.equals("")) { //$NON-NLS-1$
- return 1;
- }
-
- return Integer.parseInt(maxOccurs);
- }
-
- public static boolean isCollection(Element element) {
- int maxOccurs = getMaxOccurs(element);
-
- return (maxOccurs > 1 || maxOccurs == -1);
- }
-
- public static void setElementType(Element element, ElementType type) {
- element.setAttributeNS(NAMESPACE, "smk:elementType", type.toString());
//$NON-NLS-1$
- }
-
- public static ElementType getElementType(Element element) {
- String elementType = element.getAttributeNS(NAMESPACE, "elementType");
//$NON-NLS-1$
-
- if(elementType == null || elementType.length() == 0) {
- return null;
- }
-
- return ElementType.valueOf(elementType);
- }
-
- /**
- * Create a compositor Element.
- * @param document Owner Document node.
- * @return The compositor Element.
- */
- public static Element createCompositor(Document document) {
- return document.createElementNS(NAMESPACE, "smk:compositor"); //$NON-NLS-1$
- }
-
- /**
- * Is the supplied DOM node the compositor Element.
- * @param node The DOM node to test.
- * @return True if the node is the compositor element, otherwise false.
- */
- public static boolean isCompositor(Node node) {
- if(node.getNodeType() == Node.ELEMENT_NODE) {
- if(DomUtils.getName((Element)node).equals("compositor")) { //$NON-NLS-1$
- if(NAMESPACE.equals(node.getNamespaceURI())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Turn on/off enforcement of collection sub-mapping rules.
- * <p/>
- * If turned on, the collection mapping must be made on the model collection element
(having maxOccurs > 1)
- * before mappings can be made on sub elements.
- *
- * @param element The model element.
- * @param enforce True if enforcement is to be turned on, otherwise false.
- */
- public static void setEnforceCollectionSubMappingRules(Element element, boolean enforce)
{
- element.setAttributeNS(NAMESPACE,
"smk:enforceCollectionSubMappingRules", Boolean.toString(enforce));
//$NON-NLS-1$
- }
-
- /**
- * Is collection sub-mapping rules turned on for the supplied model element.
- * @param element The model element.
- * @return True if enforcement is turned on, otherwise false.
- * @see #setEnforceCollectionSubMappingRules(Element, boolean)
- */
- public static boolean getEnforceCollectionSubMappingRules(Element element) {
- String enforce = element.getAttributeNS(NAMESPACE,
"enforceCollectionSubMappingRules"); //$NON-NLS-1$
-
- if(enforce == null || enforce.length() == 0) {
- return true;
- }
-
- return !enforce.equals("false"); //$NON-NLS-1$
- }
-}
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/ModelNodeResolver.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/ModelNodeResolver.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/ModelNodeResolver.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -54,7 +54,7 @@
StringBuilder pathBuilder = new StringBuilder();
while(node != null && node.getNodeType() != Node.DOCUMENT_NODE) {
- if(!ModelBuilder.isInReservedNamespace(node)) {
+ if(!TemplatingModelBuilder.isInReservedNamespace(node)) {
if(pathBuilder.length() > 0) {
pathBuilder.insert(0, '/'); //$NON-NLS-1$
}
@@ -76,7 +76,7 @@
}
}
- node = ModelBuilder.getParentNode(node);
+ node = TemplatingModelBuilder.getParentNode(node);
}
return pathBuilder.toString();
@@ -85,7 +85,7 @@
private void buildModelNodeMap(Element element, String parentPath) {
String elementPath = parentPath;
- if(!ModelBuilder.isInReservedNamespace(element)) {
+ if(!TemplatingModelBuilder.isInReservedNamespace(element)) {
String elNS = element.getNamespaceURI();
if(parentPath.length() > 0) {
@@ -104,7 +104,7 @@
int attrCount = attributes.getLength();
for(int i = 0; i < attrCount; i++) {
Attr attribute = (Attr) attributes.item(i);
- if(!ModelBuilder.isInReservedNamespace(attribute)) {
+ if(!TemplatingModelBuilder.isInReservedNamespace(attribute)) {
String attrNS = attribute.getNamespaceURI();
if(attrNS != null && attrNS.length() > 0) {
modelNodeMap.put(elementPath + "/@" + getPrefix(attrNS) + ":" +
attribute.getName(), attribute); //$NON-NLS-1$ //$NON-NLS-2$
Copied:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/TemplatingModelBuilder.java
(from rev 22508,
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/ModelBuilder.java)
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/TemplatingModelBuilder.java
(rev 0)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/TemplatingModelBuilder.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -0,0 +1,272 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.tools.smooks.templating.model;
+
+import java.util.Properties;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.milyn.xml.DomUtils;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * Abstract message model builder.
+ *
+ * @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
+ */
+public abstract class TemplatingModelBuilder {
+
+ public static final String NAMESPACE =
"http://www.jboss.org/xsd/tools/smooks"; // TODO: Make same as JBT eclipse
extension namespace ?? //$NON-NLS-1$
+ public static final String REQUIRED = "#required"; //$NON-NLS-1$
+ public static final String OPTIONAL = "#optional"; //$NON-NLS-1$
+
+ private static final String HIDDEN_ELEMENT = "hidden"; //$NON-NLS-1$
+
+ public static enum ElementType {
+ simple,
+ complex
+ }
+
+ private Properties namespaces = new Properties();
+
+ /**
+ * Build the message model.
+ * @return The message model.
+ * @throws ModelBuilderException Error building model.
+ */
+ public abstract Document buildModel() throws ModelBuilderException;
+
+ /**
+ * Get the namespace prefix-to-URI mappings for this model.
+ * @return The namespace prefix-to-URI mappings for this model.
+ */
+ public Properties getNamespaces() {
+ return namespaces;
+ }
+
+
+
+ /**
+ * Mark a fragment as being hidden.
+ * <p/>
+ * When hidden, it is illegal to attempt a mapping onto a fragment.
+ *
+ * @param fragment The fragment to be marked as hidden.
+ */
+ public static void hideFragment(Element fragment) {
+ fragment.setAttributeNS(NAMESPACE, HIDDEN_ELEMENT, "true");
//$NON-NLS-1$
+ }
+
+ /**
+ * Unmark a fragment as being hidden.
+ * <p/>
+ * When hidden, it is illegal to attempt a mapping onto a fragment.
+ *
+ * @param fragment The fragment to be unmarked as hidden.
+ */
+ public static void unhideFragment(Element fragment) {
+ fragment.removeAttributeNS(NAMESPACE, HIDDEN_ELEMENT);
+ }
+
+ /**
+ * Is the specified node marked as being hidden.
+ * <p/>
+ * When hidden, it is illegal to attempt a mapping onto a fragment.
+ *
+ * @return True if the node is hidden, otherwise false.
+ */
+ public static boolean isHidden(Node node) {
+ if(node != null) {
+ switch(node.getNodeType()) {
+ case Node.ATTRIBUTE_NODE :
+ return isHidden(node.getParentNode());
+ case Node.ELEMENT_NODE :
+ if(((Element)node).getAttributeNS(NAMESPACE,
HIDDEN_ELEMENT).equals("true")) { //$NON-NLS-1$
+ return true;
+ }
+ return isHidden(node.getParentNode());
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Is the specified node required.
+ * <p/>
+ * For an Element node, this means does it have a minOccurs > 0. For an Attr
node,
+ * it means is its value set to "#REQUIRED".
+ *
+ * @return True if the node is hidden, otherwise false.
+ */
+ public static boolean isRequired(Node node) {
+ if(node != null) {
+ switch(node.getNodeType()) {
+ case Node.ATTRIBUTE_NODE :
+ return (REQUIRED.equals(node.getTextContent()) ||
XMLConstants.XML_NS_URI.equals(node.getNamespaceURI()));
+ case Node.ELEMENT_NODE :
+ if(getMinOccurs((Element) node) > 0) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Is the specified node in the reserved namespace.
+ *
+ * @return True if the node is in the reserved namespace, otherwise false.
+ */
+ public static boolean isInReservedNamespace(Node node) {
+ if(node != null) {
+ return NAMESPACE.equals(node.getNamespaceURI());
+ }
+
+ return false;
+ }
+
+ protected Document createModelInstance() throws ModelBuilderException {
+ DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder;
+
+ try {
+ builder = builderFactory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ throw new ModelBuilderException("Error constructing DOM
DocumentBuilder.", e); //$NON-NLS-1$
+ }
+
+ return builder.newDocument();
+ }
+
+ public static void setMinMax(Element element, int minOccurs, int maxOccurs) {
+ element.setAttributeNS(NAMESPACE, "smk:minOccurs",
Integer.toString(minOccurs)); //$NON-NLS-1$
+ element.setAttributeNS(NAMESPACE, "smk:maxOccurs",
Integer.toString(maxOccurs)); //$NON-NLS-1$
+ }
+
+ public static Node getParentNode(Node node) {
+ if(node.getNodeType() == Node.ATTRIBUTE_NODE) {
+ return ((Attr)node).getOwnerElement();
+ } else {
+ return node.getParentNode();
+ }
+ }
+
+ public static int getMinOccurs(Element element) {
+ String minOccurs = element.getAttributeNS(NAMESPACE, "minOccurs");
//$NON-NLS-1$
+
+ if(minOccurs.equals("")) { //$NON-NLS-1$
+ return 1;
+ }
+
+ return Integer.parseInt(minOccurs);
+ }
+
+ public static int getMaxOccurs(Element element) {
+ String maxOccurs = element.getAttributeNS(NAMESPACE, "maxOccurs");
//$NON-NLS-1$
+
+ if(maxOccurs.equals("")) { //$NON-NLS-1$
+ return 1;
+ }
+
+ return Integer.parseInt(maxOccurs);
+ }
+
+ public static boolean isCollection(Element element) {
+ int maxOccurs = getMaxOccurs(element);
+
+ return (maxOccurs > 1 || maxOccurs == -1);
+ }
+
+ public static void setElementType(Element element, ElementType type) {
+ element.setAttributeNS(NAMESPACE, "smk:elementType", type.toString());
//$NON-NLS-1$
+ }
+
+ public static ElementType getElementType(Element element) {
+ String elementType = element.getAttributeNS(NAMESPACE, "elementType");
//$NON-NLS-1$
+
+ if(elementType == null || elementType.length() == 0) {
+ return null;
+ }
+
+ return ElementType.valueOf(elementType);
+ }
+
+ /**
+ * Create a compositor Element.
+ * @param document Owner Document node.
+ * @return The compositor Element.
+ */
+ public static Element createCompositor(Document document) {
+ return document.createElementNS(NAMESPACE, "smk:compositor"); //$NON-NLS-1$
+ }
+
+ /**
+ * Is the supplied DOM node the compositor Element.
+ * @param node The DOM node to test.
+ * @return True if the node is the compositor element, otherwise false.
+ */
+ public static boolean isCompositor(Node node) {
+ if(node.getNodeType() == Node.ELEMENT_NODE) {
+ if(DomUtils.getName((Element)node).equals("compositor")) { //$NON-NLS-1$
+ if(NAMESPACE.equals(node.getNamespaceURI())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Turn on/off enforcement of collection sub-mapping rules.
+ * <p/>
+ * If turned on, the collection mapping must be made on the model collection element
(having maxOccurs > 1)
+ * before mappings can be made on sub elements.
+ *
+ * @param element The model element.
+ * @param enforce True if enforcement is to be turned on, otherwise false.
+ */
+ public static void setEnforceCollectionSubMappingRules(Element element, boolean enforce)
{
+ element.setAttributeNS(NAMESPACE,
"smk:enforceCollectionSubMappingRules", Boolean.toString(enforce));
//$NON-NLS-1$
+ }
+
+ /**
+ * Is collection sub-mapping rules turned on for the supplied model element.
+ * @param element The model element.
+ * @return True if enforcement is turned on, otherwise false.
+ * @see #setEnforceCollectionSubMappingRules(Element, boolean)
+ */
+ public static boolean getEnforceCollectionSubMappingRules(Element element) {
+ String enforce = element.getAttributeNS(NAMESPACE,
"enforceCollectionSubMappingRules"); //$NON-NLS-1$
+
+ if(enforce == null || enforce.length() == 0) {
+ return true;
+ }
+
+ return !enforce.equals("false"); //$NON-NLS-1$
+ }
+}
Property changes on:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/TemplatingModelBuilder.java
___________________________________________________________________
Name: svn:executable
+ *
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/csv/CSVModelBuilder.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/csv/CSVModelBuilder.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/csv/CSVModelBuilder.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -20,7 +20,7 @@
package org.jboss.tools.smooks.templating.model.csv;
import org.eclipse.core.runtime.Assert;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.model.ModelBuilderException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -29,7 +29,7 @@
* CSV Model Builder.
* @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
*/
-public class CSVModelBuilder extends ModelBuilder {
+public class CSVModelBuilder extends TemplatingModelBuilder {
public static final String CSV_RECORD_ELEMENT = "csv-record";
//$NON-NLS-1$
private String[] csvFields;
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/xml/XMLSampleModelBuilder.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/xml/XMLSampleModelBuilder.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/xml/XMLSampleModelBuilder.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -38,7 +38,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.model.ModelBuilderException;
import org.jboss.tools.smooks.templating.template.xml.XMLFreeMarkerTemplateBuilder;
import org.milyn.xml.DomUtils;
@@ -50,7 +50,7 @@
*
* @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
*/
-public class XMLSampleModelBuilder extends ModelBuilder {
+public class XMLSampleModelBuilder extends TemplatingModelBuilder {
private static DocumentBuilder docBuilder;
private Document model;
@@ -115,7 +115,7 @@
if(childCount > 0) {
// Has child elements, therefore it's a "complex" element type...
- ModelBuilder.setElementType(element, ElementType.complex);
+ TemplatingModelBuilder.setElementType(element, ElementType.complex);
for(int i = 0; i < childCount; i++) {
Node child = children.item(i);
@@ -128,7 +128,7 @@
}
} else {
// Has no child elements, therefore it's a "simple" element type...
- ModelBuilder.setElementType(element, ElementType.simple);
+ TemplatingModelBuilder.setElementType(element, ElementType.simple);
}
}
@@ -147,19 +147,19 @@
Element earlierOccurance = childElementByNames.get(elementName);
// Mark every element as being optional and possibly being multiple...
- ModelBuilder.setMinMax(childElement, 0, -1);
+ TemplatingModelBuilder.setMinMax(childElement, 0, -1);
if(earlierOccurance != null) {
// According to the sample XML, this element is definitely a
// collection item because it exists more than once, so lets mark it
// such that sub mappings on this element require this collection to be mapped
beforehand...
- ModelBuilder.setEnforceCollectionSubMappingRules(earlierOccurance, true);
+ TemplatingModelBuilder.setEnforceCollectionSubMappingRules(earlierOccurance, true);
// And remove the duplicates...
removeableChildren.add(childElement);
} else {
// We've no way of knowing whether or not this element is a collection
// item or not, so lets not enforce the collection sub mapping rules...
- ModelBuilder.setEnforceCollectionSubMappingRules(childElement, false);
+ TemplatingModelBuilder.setEnforceCollectionSubMappingRules(childElement, false);
}
configureModelElementCardinality(childElement);
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/xml/XSDModelBuilder.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/xml/XSDModelBuilder.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/model/xml/XSDModelBuilder.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -31,7 +31,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.model.ModelBuilderException;
import org.jboss.tools.smooks.templating.template.xml.XMLFreeMarkerTemplateBuilder;
@@ -56,7 +56,7 @@
*
* @author <a
href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
*/
-public class XSDModelBuilder extends ModelBuilder {
+public class XSDModelBuilder extends TemplatingModelBuilder {
private Map<String, XSDElementDeclaration> elements = new
LinkedHashMap<String, XSDElementDeclaration>();
private Map<String, XSDTypeDefinition> types = new LinkedHashMap<String,
XSDTypeDefinition>();
@@ -207,17 +207,17 @@
parent.appendChild(element);
if(typeDef instanceof XSDComplexTypeDefinition) {
- ModelBuilder.setElementType(element, ElementType.complex);
+ TemplatingModelBuilder.setElementType(element, ElementType.complex);
processComplexType(document, element, (XSDComplexTypeDefinition)
typeDef);
} else if(typeDef instanceof XSDSimpleTypeDefinition) {
XSDSimpleTypeDefinition simpleTypeDef = (XSDSimpleTypeDefinition)
typeDef;
XSDTypeDefinition loadedType = types.get(simpleTypeDef.getName());
if(loadedType instanceof XSDComplexTypeDefinition) {
- ModelBuilder.setElementType(element, ElementType.complex);
+ TemplatingModelBuilder.setElementType(element, ElementType.complex);
processComplexType(document, element, (XSDComplexTypeDefinition)
loadedType);
} else {
- ModelBuilder.setElementType(element, ElementType.simple);
+ TemplatingModelBuilder.setElementType(element, ElementType.simple);
}
} else if(typeDef != null) {
System.out.println("?? " + typeDef); //$NON-NLS-1$
@@ -256,7 +256,7 @@
String compositorType = compositor.getName();
if(particles.size() > 1 && compositorType.equals("choice"))
{ //$NON-NLS-1$
- Element compositorEl = ModelBuilder.createCompositor(document);
+ Element compositorEl = TemplatingModelBuilder.createCompositor(document);
compositorEl.setAttribute("type", compositorType); //$NON-NLS-1$
setMinMax(compositorEl, minOccurs, maxOccurs);
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/TemplateBuilder.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/TemplateBuilder.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/TemplateBuilder.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -34,7 +34,7 @@
import javax.xml.xpath.XPathFactory;
import org.eclipse.core.runtime.Assert;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.model.ModelBuilderException;
import org.jboss.tools.smooks.templating.model.ModelNodeResolver;
import org.jboss.tools.smooks.templating.template.exception.InvalidMappingException;
@@ -56,7 +56,7 @@
*/
public abstract class TemplateBuilder {
- private ModelBuilder modelBuilder;
+ private TemplatingModelBuilder modelBuilder;
private Document model;
private List<Mapping> mappings = new ArrayList<Mapping>();
private XPathFactory xpathFactory = XPathFactory.newInstance();
@@ -70,7 +70,7 @@
* @throws ModelBuilderException
* Error building model.
*/
- public TemplateBuilder(ModelBuilder modelBuilder) throws ModelBuilderException {
+ public TemplateBuilder(TemplatingModelBuilder modelBuilder) throws ModelBuilderException
{
Assert.isNotNull(modelBuilder, "modelBuilder"); //$NON-NLS-1$
this.modelBuilder = modelBuilder;
this.model = modelBuilder.buildModel();
@@ -112,13 +112,13 @@
}
/**
- * Get the {@link ModelBuilder} instance associated with this
+ * Get the {@link TemplatingModelBuilder} instance associated with this
* {@link TemplateBuilder}.
*
- * @return The {@link ModelBuilder} instance associated with this
+ * @return The {@link TemplatingModelBuilder} instance associated with this
* {@link TemplateBuilder}.
*/
- public ModelBuilder getModelBuilder() {
+ public TemplatingModelBuilder getModelBuilder() {
return modelBuilder;
}
@@ -187,7 +187,7 @@
for (Node hiddenNode : hideNodes) {
if (hiddenNode.getNodeType() == Node.ELEMENT_NODE) {
if (!isOnMappingPath((Element) hiddenNode)) {
- ModelBuilder.unhideFragment((Element) hiddenNode);
+ TemplatingModelBuilder.unhideFragment((Element) hiddenNode);
showNodes.add(hiddenNode);
}
}
@@ -198,19 +198,19 @@
}
private void addHideNodes(Node modelPath, Mapping mapping) {
- Node parent = ModelBuilder.getParentNode(modelPath);
+ Node parent = TemplatingModelBuilder.getParentNode(modelPath);
while (parent != null) {
- if (ModelBuilder.isCompositor(parent)) {
+ if (TemplatingModelBuilder.isCompositor(parent)) {
Element compositor = (Element) parent;
- int maxOccurs = ModelBuilder.getMaxOccurs(compositor);
+ int maxOccurs = TemplatingModelBuilder.getMaxOccurs(compositor);
int numElementsOnMappingPath = getNumElementsOnMappingPath(compositor);
if (numElementsOnMappingPath == maxOccurs) {
hideUnmappedPaths(compositor, mapping);
}
}
- parent = ModelBuilder.getParentNode(parent);
+ parent = TemplatingModelBuilder.getParentNode(parent);
}
}
@@ -224,7 +224,7 @@
Element nodeToHide = (Element) child;
if (!isOnMappingPath(nodeToHide)) {
mapping.addHideNode(nodeToHide);
- ModelBuilder.hideFragment(nodeToHide);
+ TemplatingModelBuilder.hideFragment(nodeToHide);
}
}
}
@@ -264,11 +264,11 @@
throw new InvalidMappingException(
"Unsupported XML target node mapping. Support XML elements and attributes
only."); //$NON-NLS-1$
}
- if (ModelBuilder.NAMESPACE.equals(mappingNode.getNamespaceURI())) {
+ if (TemplatingModelBuilder.NAMESPACE.equals(mappingNode.getNamespaceURI())) {
throw new InvalidMappingException(
- "Unsupported XML target node mapping. Cannot map to a reserved model node from
the '" + ModelBuilder.NAMESPACE + "' namespace."); //$NON-NLS-1$
//$NON-NLS-2$
+ "Unsupported XML target node mapping. Cannot map to a reserved model node from
the '" + TemplatingModelBuilder.NAMESPACE + "' namespace.");
//$NON-NLS-1$ //$NON-NLS-2$
}
- if (ModelBuilder.isHidden(mappingNode)) {
+ if (TemplatingModelBuilder.isHidden(mappingNode)) {
throw new InvalidMappingException(
"Illegal XML target node mapping for node '" + mappingNode +
"'. This node (or one of it's ancestors) is hidden."); //$NON-NLS-1$
//$NON-NLS-2$
}
@@ -278,7 +278,7 @@
Element collectionElement = getNearestCollectionElement(mappingNode);
if (collectionElement != null) {
CollectionMapping parentCollectionMapping = getCollectionMapping(collectionElement);
- if (parentCollectionMapping == null &&
ModelBuilder.getEnforceCollectionSubMappingRules(collectionElement)) {
+ if (parentCollectionMapping == null &&
TemplatingModelBuilder.getEnforceCollectionSubMappingRules(collectionElement)) {
throw new UnmappedCollectionNodeException(collectionElement);
}
}
@@ -299,12 +299,12 @@
while (nextNode != null) {
if (nextNode.getNodeType() == Node.ELEMENT_NODE) {
- if(ModelBuilder.isCollection((Element) nextNode)) {
+ if(TemplatingModelBuilder.isCollection((Element) nextNode)) {
return (Element) nextNode;
}
}
- nextNode = ModelBuilder.getParentNode(nextNode);
+ nextNode = TemplatingModelBuilder.getParentNode(nextNode);
}
return null;
@@ -347,11 +347,11 @@
// it's attributes and
// child elements) i.e. it is not a parent of any of the mappings.
- if (ModelBuilder.isInReservedNamespace(element)) {
+ if (TemplatingModelBuilder.isInReservedNamespace(element)) {
return false;
- } else if (ModelBuilder.isHidden(element)) {
+ } else if (TemplatingModelBuilder.isHidden(element)) {
return false;
- } else if (ModelBuilder.getMinOccurs(element) == 0 &&
!isOnMappingPath(element)) {
+ } else if (TemplatingModelBuilder.getMinOccurs(element) == 0 &&
!isOnMappingPath(element)) {
return false;
}
@@ -375,7 +375,7 @@
if (element == pathNode) {
return true;
}
- pathNode = ModelBuilder.getParentNode(pathNode);
+ pathNode = TemplatingModelBuilder.getParentNode(pathNode);
}
}
@@ -404,8 +404,8 @@
if (child.getNodeType() == Node.ELEMENT_NODE) {
Node targetModelNode = modelNodeResolver.resolveNodeMapping(child);
- String srcPath = element.getAttributeNS(ModelBuilder.NAMESPACE, "srcPath");
//$NON-NLS-1$
- String collectionItemName = element.getAttributeNS(ModelBuilder.NAMESPACE,
"collectionItemName"); //$NON-NLS-1$
+ String srcPath = element.getAttributeNS(TemplatingModelBuilder.NAMESPACE,
"srcPath"); //$NON-NLS-1$
+ String collectionItemName = element.getAttributeNS(TemplatingModelBuilder.NAMESPACE,
"collectionItemName"); //$NON-NLS-1$
addCollectionMapping(srcPath, (Element) targetModelNode, collectionItemName);
@@ -435,7 +435,7 @@
}
public static void writeListStart(StringWriter writer, String srcPath, String
collectionItemName) {
- writer.write("<smk:list smk:srcPath=\"" + srcPath + "\"
smk:collectionItemName=\"" + collectionItemName + "\"
xmlns:smk=\"" + ModelBuilder.NAMESPACE + "\">"); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ writer.write("<smk:list smk:srcPath=\"" + srcPath + "\"
smk:collectionItemName=\"" + collectionItemName + "\"
xmlns:smk=\"" + TemplatingModelBuilder.NAMESPACE + "\">");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
public static void writeListEnd(StringWriter writer) {
@@ -443,7 +443,7 @@
}
public static boolean isListElement(Element element) {
- if (ModelBuilder.isInReservedNamespace(element)) {
+ if (TemplatingModelBuilder.isInReservedNamespace(element)) {
if (DomUtils.getName(element).equals("list")) { //$NON-NLS-1$
return true;
}
@@ -473,7 +473,7 @@
public String getNamespaceURI(String prefix) {
if (prefix.equals("smk")) { //$NON-NLS-1$
- return ModelBuilder.NAMESPACE;
+ return TemplatingModelBuilder.NAMESPACE;
} else {
return namespaces.getProperty(prefix);
}
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/csv/CSVFreeMarkerTemplateBuilder.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/csv/CSVFreeMarkerTemplateBuilder.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/csv/CSVFreeMarkerTemplateBuilder.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -26,7 +26,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.model.ModelBuilderException;
import org.jboss.tools.smooks.templating.template.*;
import org.jboss.tools.smooks.templating.template.exception.TemplateBuilderException;
@@ -59,7 +59,7 @@
* @param includeFieldNames True if field names are to be added at the start of the
generated message, otherwise false.
* @throws ModelBuilderException Error building model.
*/
- public CSVFreeMarkerTemplateBuilder(ModelBuilder modelBuilder, char separatorChar,
char quoteChar, boolean includeFieldNames) throws ModelBuilderException {
+ public CSVFreeMarkerTemplateBuilder(TemplatingModelBuilder modelBuilder, char
separatorChar, char quoteChar, boolean includeFieldNames) throws ModelBuilderException {
super(modelBuilder);
this.separatorChar = separatorChar;
this.quoteChar = quoteChar;
@@ -77,7 +77,7 @@
* @throws ModelBuilderException Error building model.
* @throws TemplateBuilderException Error adding mappings extracted from template.
*/
- public CSVFreeMarkerTemplateBuilder(ModelBuilder modelBuilder, char separatorChar,
char quoteChar, boolean includeFieldNames, String ftlTemplate) throws
ModelBuilderException, TemplateBuilderException {
+ public CSVFreeMarkerTemplateBuilder(TemplatingModelBuilder modelBuilder, char
separatorChar, char quoteChar, boolean includeFieldNames, String ftlTemplate) throws
ModelBuilderException, TemplateBuilderException {
this(modelBuilder, separatorChar, quoteChar, includeFieldNames);
addMappings(ftlTemplate);
}
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/xml/XMLFreeMarkerTemplateBuilder.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/xml/XMLFreeMarkerTemplateBuilder.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.templating/src/org/jboss/tools/smooks/templating/template/xml/XMLFreeMarkerTemplateBuilder.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -33,10 +33,10 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.model.ModelBuilderException;
import org.jboss.tools.smooks.templating.model.ModelNodeResolver;
-import org.jboss.tools.smooks.templating.model.ModelBuilder.ElementType;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder.ElementType;
import org.jboss.tools.smooks.templating.model.xml.XSDModelBuilder;
import org.jboss.tools.smooks.templating.template.*;
import org.jboss.tools.smooks.templating.template.exception.InvalidMappingException;
@@ -63,13 +63,13 @@
* <p/>
* This constructor is used when an existing template doesn't exist i.e. for
creating new
* templates with a new set of mappings. When creating an {@link
XMLFreeMarkerTemplateBuilder} instance to incorporate
- * mappings from an existing template, use the {@link
#XMLFreeMarkerTemplateBuilder(ModelBuilder, String)}
+ * mappings from an existing template, use the {@link
#XMLFreeMarkerTemplateBuilder(TemplatingModelBuilder, String)}
* constructor.
*
- * @param modelBuilder The {@link ModelBuilder} instance that describes the XML model
(e.g. {@link XSDModelBuilder}).
- * @throws ModelBuilderException Invalid {@link ModelBuilder} instance.
+ * @param modelBuilder The {@link TemplatingModelBuilder} instance that describes the
XML model (e.g. {@link XSDModelBuilder}).
+ * @throws ModelBuilderException Invalid {@link TemplatingModelBuilder} instance.
*/
- public XMLFreeMarkerTemplateBuilder(ModelBuilder modelBuilder) throws
ModelBuilderException {
+ public XMLFreeMarkerTemplateBuilder(TemplatingModelBuilder modelBuilder) throws
ModelBuilderException {
super(modelBuilder);
}
@@ -79,12 +79,12 @@
* Used to construct an {@link XMLFreeMarkerTemplateBuilder} instance to incorporate
mappings from an
* existing FreeMarker template.
*
- * @param modelBuilder The {@link ModelBuilder} instance that describes the XML model
(e.g. {@link XSDModelBuilder}).
+ * @param modelBuilder The {@link TemplatingModelBuilder} instance that describes the
XML model (e.g. {@link XSDModelBuilder}).
* @param ftlTemplate FreeMarker template from which to extract existing {@link
ValueMapping mappings}.
- * @throws ModelBuilderException Invalid {@link ModelBuilder} instance.
+ * @throws ModelBuilderException Invalid {@link TemplatingModelBuilder} instance.
* @throws TemplateBuilderException Error processing FreeMarker template.
*/
- public XMLFreeMarkerTemplateBuilder(ModelBuilder modelBuilder, String ftlTemplate)
throws ModelBuilderException, TemplateBuilderException {
+ public XMLFreeMarkerTemplateBuilder(TemplatingModelBuilder modelBuilder, String
ftlTemplate) throws ModelBuilderException, TemplateBuilderException {
super(modelBuilder);
addMappings(ftlTemplate);
}
@@ -125,7 +125,7 @@
*/
private void writeElement(Element element, int indent, boolean addNewline, Writer
templateWriter) {
try {
- if(ModelBuilder.isInReservedNamespace(element)) {
+ if(TemplatingModelBuilder.isInReservedNamespace(element)) {
writeElementChildren(element, indent, templateWriter);
} else if(assertAddNodeToTemplate(element)) {
if(addNewline) {
@@ -171,12 +171,12 @@
for(int i = 0; i < attributes.getLength(); i++) {
Attr attribute = (Attr) attributes.item(i);
- if(!ModelBuilder.isInReservedNamespace(attribute)) {
+ if(!TemplatingModelBuilder.isInReservedNamespace(attribute)) {
Mapping mapping = getMapping(attribute);
if(mapping != null) {
writeAttribute(attribute.getNodeName(),
FreeMarkerUtil.toFreeMarkerVariable((ValueMapping)mapping), templateWriter);
//$NON-NLS-1$
- } else if(ModelBuilder.isRequired(attribute)) {
+ } else if(TemplatingModelBuilder.isRequired(attribute)) {
writeAttribute(attribute.getNodeName(), attribute.getValue(), templateWriter);
}
}
@@ -213,16 +213,16 @@
if(children.getLength() == 0) {
Mapping mapping = getMapping(element);
- if(ModelBuilder.getElementType(element) == ElementType.simple) {
+ if(TemplatingModelBuilder.getElementType(element) == ElementType.simple) {
templateWriter.write(">"); //$NON-NLS-1$
if(mapping != null) {
templateWriter.write(FreeMarkerUtil.toFreeMarkerVariable((ValueMapping)mapping));
} else {
- templateWriter.write(ModelBuilder.REQUIRED);
+ templateWriter.write(TemplatingModelBuilder.REQUIRED);
}
}
} else {
- if(!ModelBuilder.isInReservedNamespace(element)) {
+ if(!TemplatingModelBuilder.isInReservedNamespace(element)) {
templateWriter.write(">"); //$NON-NLS-1$
}
for(int i = 0; i < children.getLength(); i++) {
@@ -232,7 +232,7 @@
numElementsWritten++;
}
}
- if(!ModelBuilder.isInReservedNamespace(element)) {
+ if(!TemplatingModelBuilder.isInReservedNamespace(element)) {
templateWriter.write('\n'); //$NON-NLS-1$
}
}
@@ -241,7 +241,7 @@
}
private void writeElementEnd(Element element, boolean hasChildren, Writer
templateWriter) throws IOException {
- if(hasChildren || ModelBuilder.getElementType(element) == ElementType.simple) {
+ if(hasChildren || TemplatingModelBuilder.getElementType(element) == ElementType.simple)
{
templateWriter.write("</"); //$NON-NLS-1$
templateWriter.write(element.getNodeName());
templateWriter.write(">"); //$NON-NLS-1$
@@ -295,7 +295,7 @@
private void addMappings(Element element, ModelNodeResolver modelNodeResolver) throws
TemplateBuilderException {
if(TemplateBuilder.isListElement(element)) {
addCollectionMapping(element, modelNodeResolver);
- } else if(!ModelBuilder.isInReservedNamespace(element)) {
+ } else if(!TemplatingModelBuilder.isInReservedNamespace(element)) {
String elementText = DomUtils.getAllText(element, false);
// Handle the element itself...
@@ -309,7 +309,7 @@
for(int i = 0; i < attribCount; i++) {
Attr attribute = (Attr) attributes.item(i);
- if(!ModelBuilder.isInReservedNamespace(attribute)) {
+ if(!TemplatingModelBuilder.isInReservedNamespace(attribute)) {
String attrValue = attribute.getValue();
if(FreeMarkerUtil.isDollarVariable(attrValue)) {
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerAttrModel.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerAttrModel.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerAttrModel.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -15,7 +15,7 @@
import org.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject;
import org.jboss.tools.smooks.configuration.editors.xml.TagPropertyObject;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.template.Mapping;
import org.jboss.tools.smooks.templating.template.ValueMapping;
import org.jboss.tools.smooks.templating.template.TemplateBuilder;
@@ -47,7 +47,7 @@
public boolean isRequired() {
Attr element = this.getReferenceAttibute();
if (element != null) {
- return ModelBuilder.isRequired(element);
+ return TemplatingModelBuilder.isRequired(element);
}
return false;
}
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerModelAnalyzer.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerModelAnalyzer.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerModelAnalyzer.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -24,7 +24,7 @@
import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
import org.jboss.tools.smooks.configuration.editors.xml.TagPropertyObject;
import org.jboss.tools.smooks.configuration.editors.xml.XMLUtils;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -120,7 +120,7 @@
if (element != null) {
Node parentNode = element.getParentNode();
if (parentNode instanceof Element) {
- if (ModelBuilder.isCompositor(parentNode)) {
+ if (TemplatingModelBuilder.isCompositor(parentNode)) {
return true;
}
}
@@ -134,7 +134,7 @@
return null;
boolean canAdd = false;
TagObject tag = null;
- if (ModelBuilder.isCompositor(element)) {
+ if (TemplatingModelBuilder.isCompositor(element)) {
tag = parentTag;
} else {
tag = getChildTagByName(element.getNodeName(), parentTag, ignoreNodeNames);
@@ -207,7 +207,7 @@
localName = name;
}
- if(ModelBuilder.isInReservedNamespace(attr)) {
+ if(TemplatingModelBuilder.isInReservedNamespace(attr)) {
continue;
}
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateModelLabelProvider.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateModelLabelProvider.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateModelLabelProvider.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -15,7 +15,7 @@
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataLabelProvider;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -41,7 +41,7 @@
}
Node modelNode = ((FreemarkerTemplateXMLModel) element).getModelNode();
if (((FreemarkerTemplateXMLModel) element).isManyOccurs()) {
- if(modelNode instanceof Element &&
ModelBuilder.getEnforceCollectionSubMappingRules((Element) modelNode)) {
+ if(modelNode instanceof Element &&
TemplatingModelBuilder.getEnforceCollectionSubMappingRules((Element) modelNode)) {
return imageRegistry.get(GraphicsConstants.IMAGE_XSL_FOREACH);
}
}
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateXMLModel.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateXMLModel.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateXMLModel.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -17,7 +17,7 @@
import org.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject;
import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
import org.jboss.tools.smooks.configuration.editors.xml.TagPropertyObject;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.template.Mapping;
import org.jboss.tools.smooks.templating.template.ValueMapping;
import org.jboss.tools.smooks.templating.template.TemplateBuilder;
@@ -67,7 +67,7 @@
return false;
}
if (element != null) {
- return ModelBuilder.isRequired(element);
+ return TemplatingModelBuilder.isRequired(element);
}
return false;
}
@@ -75,7 +75,7 @@
public boolean isManyOccurs() {
Element refElement = this.getReferenceElement();
if (refElement != null) {
- return ModelBuilder.isCollection(refElement);
+ return TemplatingModelBuilder.isCollection(refElement);
}
return false;
}
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/javamapping/JavaBeanChildGraphModel.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -56,7 +56,7 @@
import org.jboss.tools.smooks.model.javabean12.Javabean12Package;
import org.jboss.tools.smooks.model.javabean12.ValueType;
import org.jboss.tools.smooks.model.javabean12.WiringType;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.template.TemplateBuilder;
import org.jboss.tools.smooks.templating.template.ValueMapping;
import org.w3c.dom.Element;
@@ -179,7 +179,7 @@
if (iFreemarkerTemplateModel.isManyOccurs() &&
pgm.getTargetConnections().isEmpty()) {
Node modelNode = iFreemarkerTemplateModel.getModelNode();
if (modelNode instanceof Element) {
- return !ModelBuilder.getEnforceCollectionSubMappingRules((Element) modelNode);
+ return !TemplatingModelBuilder.getEnforceCollectionSubMappingRules((Element)
modelNode);
} else {
return false;
}
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateContentGraphModelProviderImpl.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateContentGraphModelProviderImpl.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateContentGraphModelProviderImpl.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -33,7 +33,7 @@
import
org.jboss.tools.smooks.graphical.editors.model.freemarker.FreemarkerTemplateXMLModel;
import
org.jboss.tools.smooks.graphical.editors.model.freemarker.FreemarkerXMLNodeGraphicalModel;
import org.jboss.tools.smooks.model.freemarker.Freemarker;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.model.ModelBuilderException;
import org.jboss.tools.smooks.templating.model.csv.CSVModelBuilder;
import org.jboss.tools.smooks.templating.model.xml.XMLSampleModelBuilder;
@@ -147,7 +147,7 @@
String filePath = SmooksModelUtils.getFreemarkerXMLFilePath(freemarker);
String rootName = SmooksModelUtils.getFreemarkerXMLRootName(freemarker);
String newFilePath = SmooksUIUtils.parseFilePath(filePath);
- ModelBuilder builder;
+ TemplatingModelBuilder builder;
if (SmooksModelUtils.KEY_XML_FILE_TYPE_XSD.equals(fileType)) {
builder = new XSDModelBuilder(URI.createFileURI(newFilePath));
Modified:
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/SmooksFreemarkerTemplateGraphicalEditor.java
===================================================================
---
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/SmooksFreemarkerTemplateGraphicalEditor.java 2010-06-04
07:28:16 UTC (rev 22538)
+++
workspace/smooks-dmb/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/SmooksFreemarkerTemplateGraphicalEditor.java 2010-06-04
08:03:49 UTC (rev 22539)
@@ -29,7 +29,7 @@
import
org.jboss.tools.smooks.graphical.editors.model.freemarker.FreemarkerTemplateGraphicalModel;
import
org.jboss.tools.smooks.graphical.editors.model.freemarker.IFreemarkerTemplateModel;
import org.jboss.tools.smooks.model.freemarker.Freemarker;
-import org.jboss.tools.smooks.templating.model.ModelBuilder;
+import org.jboss.tools.smooks.templating.model.TemplatingModelBuilder;
import org.jboss.tools.smooks.templating.template.TemplateBuilder;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
import org.w3c.dom.Element;
@@ -163,7 +163,7 @@
if (data instanceof IFreemarkerTemplateModel) {
Node modelNode = ((IFreemarkerTemplateModel) data).getModelNode();
if(modelNode instanceof Element) {
- return ModelBuilder.getEnforceCollectionSubMappingRules((Element) modelNode);
+ return TemplatingModelBuilder.getEnforceCollectionSubMappingRules((Element)
modelNode);
}
}
return true;