You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2010/02/16 18:16:02 UTC
svn commit: r910600 [6/29] - in /db/torque/torque4/trunk:
maven-torque-gf-plugin/ maven-torque-gf-plugin/src/
maven-torque-gf-plugin/src/main/ maven-torque-gf-plugin/src/main/java/
maven-torque-gf-plugin/src/main/java/org/ maven-torque-gf-plugin/src/ma...
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/ApplyActionSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/ApplyActionSaxHandler.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/ApplyActionSaxHandler.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/ApplyActionSaxHandler.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,108 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_GENERATOR_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_ELEMENT_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_ACCEPT_NOT_SET_ATTRIBUTE;
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.SaxHelper;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.apache.torque.gf.control.action.ApplyAction;
+import org.apache.torque.gf.control.action.MergepointAction;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A SAX handler which reads the configuration for a ApplyAction
+ * and creates and configures the Action according to the values in the
+ * configuration XML.
+ */
+public class ApplyActionSaxHandler extends ActionSaxHandler
+{
+ /**
+ * Creates a ApplyActionSaxHandler for reading the configuration
+ * of a ApplyAction.
+ *
+ * @param uri The namespace URI of the action element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if Namespace processing is not being performed.
+ * @param qName The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element.
+ * @param configurationProvider for accessing the configuratiopn files,
+ * not null.
+ * @param projectPaths The organization of the surrounding project,
+ * not null.
+ *
+ * @throws NullPointerException if an argument is null.
+ * @throws SAXException if the element cannot be processed correctly.
+ */
+ public ApplyActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ super(createAction(attributes), configurationProvider, projectPaths);
+ }
+
+ /**
+ * Creates the action from the attributes of the action element.
+ *
+ * @param attributes the attributes of the action element.
+ *
+ * @return the action filled with the attribute values, not null.
+ *
+ * @throws SAXException if the creation of the action fails.
+ */
+ private static MergepointAction createAction(Attributes attributes)
+ throws SAXException
+ {
+ String generator = attributes.getValue(ACTION_GENERATOR_ATTRIBUTE);
+ String element = attributes.getValue(ACTION_ELEMENT_ATTRIBUTE);
+ Boolean acceptNotSet = SaxHelper.getBooleanAttribute(
+ ACTION_ACCEPT_NOT_SET_ATTRIBUTE,
+ attributes,
+ "the element " + element);
+ ApplyAction action = new ApplyAction(element, generator, acceptNotSet);
+ return action;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void startElement(
+ String uri,
+ String localName,
+ String rawName,
+ Attributes attributes)
+ throws SAXException
+ {
+ throw new SAXException("Unknown tag " + rawName);
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/ApplyActionSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/ApplyActionSaxHandlerFactory.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/ApplyActionSaxHandlerFactory.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/ApplyActionSaxHandlerFactory.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,86 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A Factory which creates a SAX handler for an ApplyAction.
+ */
+public class ApplyActionSaxHandlerFactory
+ implements ActionSaxHandlerFactory
+{
+ /**
+ * The type of the generators which can be processed by the
+ * ActionSaxHandlers created by this factory.
+ */
+ private static final String ACTION_TYPE = "applyAction";
+
+ /**
+ * Returns the generator type which can be handled by the
+ * GeneratorSaxHandlers created by this factory.
+ * @return "applyAction".
+ */
+ public String getType()
+ {
+ return ACTION_TYPE;
+ }
+
+ /**
+ * Returns a ApplyActionSaxHandler for reading the configuration of
+ * ApplyActions.
+ *
+ * @param uri The namespace URI of the action element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if namespace processing is not being performed.
+ * @param qName The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element.
+ * @param configurationProvider for accessing the configuration files,
+ * not null.
+ * @param projectPaths The organization of the surrounding project,
+ * not null.
+ *
+ * @return a new ApplyActionSaxHandler.
+ */
+ public final ApplyActionSaxHandler getActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ return new ApplyActionSaxHandler(
+ uri,
+ localName,
+ qName,
+ attributes,
+ configurationProvider,
+ projectPaths);
+ }
+
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointConfigurationTags.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointConfigurationTags.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointConfigurationTags.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointConfigurationTags.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,68 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * The element and attribute names for mergepoint configuration.
+ */
+public final class MergepointConfigurationTags
+{
+ /**
+ * private constructor for utility class.
+ */
+ private MergepointConfigurationTags()
+ {
+ }
+
+ /** Tag name for the "mergepoint" tag. */
+ public static final String MERGEPOINT_TAG = "mergepoint";
+
+ /** Attribute name for the "name" attribute of the "mergepoint" tag. */
+ public static final String MERGEPOINT_NAME_ATTRIBUTE = "name";
+
+ /** Tag name for the "action" tag. */
+ public static final String ACTION_TAG = "action";
+
+ /** Attribute name for the "type" attribute of the "action" tag. */
+ public static final String ACTION_TYPE_ATTRIBUTE = "type";
+
+ /** Attribute name for the "generator" attribute of the "action" tag. */
+ public static final String ACTION_GENERATOR_ATTRIBUTE = "generator";
+
+ /** Attribute name for the "attribute" attribute of the "action" tag. */
+ public static final String ACTION_ATTRIBUTE_ATTRIBUTE = "attribute";
+
+ /** Attribute name for the "element" attribute of the "action" tag. */
+ public static final String ACTION_ELEMENT_ATTRIBUTE = "element";
+
+ /** Attribute name for the "acceptEmpty" attribute of the "action" tag. */
+ public static final String ACTION_ACCEPT_EMPTY_ATTRIBUTE = "acceptEmpty";
+
+ /** Attribute name for the "acceptNotSet" attribute of the "action" tag. */
+ public static final String ACTION_ACCEPT_NOT_SET_ATTRIBUTE = "acceptNotSet";
+
+ /** Attribute name for the "option" attribute of the "action" tag. */
+ public static final String ACTION_OPTION_ATTRIBUTE = "option";
+
+ /** Attribute name for the "value" attribute of the "action" tag. */
+ public static final String ACTION_VALUE_ATTRIBUTE = "value";
+}
+
+
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointMapping.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointMapping.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointMapping.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointMapping.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,169 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.torque.gf.control.action.MergepointAction;
+
+/**
+ * A mapping between the name of an mergepoint and and the action which should
+ * be performed at this point.
+ */
+public class MergepointMapping
+{
+ /**
+ * The name of the mergepoint.
+ */
+ private String name;
+
+ /**
+ * The list of actions whichare executed at the mergepoint.
+ */
+ private List<MergepointAction> actions = new ArrayList<MergepointAction>();
+
+ /**
+ * Constructor.
+ *
+ * @param name the name of the mergepoint, not null.
+ *
+ * @throws IllegalArgumentException if name is null.
+ */
+ public MergepointMapping(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ this.name = name;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name the name of the mergepoint, not null.
+ * @param actions the actions in this mergepoint.
+ *
+ * @throws IllegalArgumentException if name is null.
+ */
+ public MergepointMapping(String name, List<MergepointAction> actions)
+ {
+ this(name);
+ this.actions.addAll(actions);
+ }
+
+ /**
+ * Returns the name of the mergepoint.
+ *
+ * @return the name of the mergepoint, not null.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the list of actions executed at the mergepoint.
+ *
+ * @return the list of actions. Not null, may be empty.
+ */
+ public List<MergepointAction> getActions()
+ {
+ return actions;
+ }
+
+ /**
+ * Adds an action to this mergepont mapping at the end of the action list.
+ *
+ * @param action the action to add, not null.
+ *
+ * @throws NullPointerException if action is null.
+ */
+ public void addAction(MergepointAction action)
+ {
+ if (action == null)
+ {
+ throw new NullPointerException("action is null");
+ }
+ this.actions.add(action);
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer result = new StringBuffer();
+ result.append("(name=").append(name)
+ .append(",actions=").append(actions)
+ .append(")");
+ return result.toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ final MergepointMapping other = (MergepointMapping) obj;
+ if (actions == null)
+ {
+ if (other.actions != null)
+ {
+ return false;
+ }
+ }
+ else if (!actions.equals(other.actions))
+ {
+ return false;
+ }
+ if (name == null)
+ {
+ if (other.name != null)
+ {
+ return false;
+ }
+ }
+ else if (!name.equals(other.name))
+ {
+ return false;
+ }
+ return true;
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointSaxHandler.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointSaxHandler.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/MergepointSaxHandler.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,245 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_TAG;
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.MERGEPOINT_NAME_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.MERGEPOINT_TAG;
+
+import org.apache.torque.gf.configuration.ConfigurationHandlers;
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.XMLConstants;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A SAX Handler which processes a mergepoint configuration in a generator.
+ */
+public class MergepointSaxHandler
+{
+ /**
+ * The mergepoint mapping which is created and filled using the
+ * information in the parsed XML element.
+ */
+ private MergepointMapping mergepointMapping;
+
+ /**
+ * The access object for the configuration files, not null.
+ */
+ private ConfigurationProvider configurationProvider;
+
+ /**
+ * The paths of the surrounding project, not null.
+ */
+ private ProjectPaths projectPaths;
+
+ /**
+ * The available configuration handlers.
+ */
+ private ConfigurationHandlers configurationHandlers;
+
+ /**
+ * A SAX handler which parses nested elements. Null if no nested element
+ * is currently parsed.
+ */
+ private ActionSaxHandler delegateHandler;
+
+ /**
+ * Whether the mergepoint element is completely parsed.
+ */
+ private boolean finished = false;
+
+ /**
+ * Constructor.
+ *
+ * @param configurationProvider The access object for the configuration
+ * files, not null.
+ * @param projectPaths The paths of the surrounding project, not null.
+ * @param configurationHandlers the available configuration handlers,
+ * not null.
+ *
+ * @throws NullPointerException if an argument is null.
+ */
+ public MergepointSaxHandler(
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths,
+ ConfigurationHandlers configurationHandlers)
+ {
+ if (configurationProvider == null)
+ {
+ throw new NullPointerException(
+ "configurationProvider must not be null");
+ }
+ if (projectPaths == null)
+ {
+ throw new NullPointerException("projectPaths must not be null");
+ }
+ if (configurationHandlers == null)
+ {
+ throw new NullPointerException(
+ "configurationHandlers must not be null");
+ }
+ this.configurationProvider = configurationProvider;
+ this.projectPaths = projectPaths;
+ this.configurationHandlers = configurationHandlers;
+ }
+
+ /**
+ * Returns the mergepointMapping configured by this SaxHandler.
+ * If this method is called before the mergepoint tag has been processed
+ * completely, it will throw an IllegalStateException.
+ *
+ * @return the complete mergepointMapping, never null.
+ *
+ * @throws IllegalStateException if the mergepoint tag has not been
+ * processed completely.
+ */
+ public MergepointMapping getMergepointMapping()
+ {
+ if (!finished)
+ {
+ throw new IllegalStateException("not finished parsing");
+ }
+ return mergepointMapping;
+ }
+
+ /**
+ * Callback method which is called by the SAX parser if an XML element is
+ * started.
+ * If a known element is encountered, its settings are read and applied to
+ * the generator; if an unknown element is encountered, a SaxException is
+ * thrown.
+ *
+ * @param uri The namespace URI of the started element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if Namespace processing is not being performed.
+ * @param qName The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element.
+ *
+ * @throws SAXException if an error occurs during parsing.
+ *
+ * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
+ */
+ public void startElement(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes)
+ throws SAXException
+ {
+ if (delegateHandler != null)
+ {
+ delegateHandler.startElement(uri, localName, qName, attributes);
+ }
+ else if (MERGEPOINT_TAG.equals(qName))
+ {
+ String name = attributes.getValue(MERGEPOINT_NAME_ATTRIBUTE);
+ if (name == null)
+ {
+ throw new SAXException("The tag "
+ + MERGEPOINT_TAG
+ + " needs to have the attribute "
+ + MERGEPOINT_NAME_ATTRIBUTE);
+ }
+ mergepointMapping = new MergepointMapping(name);
+ }
+ else if (ACTION_TAG.equals(qName))
+ {
+ String type = attributes.getValue(
+ XMLConstants.XSI_NAMESPACE,
+ XMLConstants.XSI_TYPE_ATTRBUTE_NAME);
+ if (type == null)
+ {
+ throw new SAXException("The tag " + ACTION_TAG
+ + " requires the attribute "
+ + XMLConstants.XSI_NAMESPACE
+ + ":"
+ + XMLConstants.XSI_TYPE_ATTRBUTE_NAME);
+ }
+
+ ActionSaxHandlerFactories actionSaxHandlerFactories
+ = configurationHandlers.getActionSaxHandlerFactories();
+ ActionSaxHandlerFactory handlerFactory
+ = actionSaxHandlerFactories.getActionSaxHandlerFactory(type);
+ if (handlerFactory == null)
+ {
+ throw new SAXException("No handler found for the action "
+ + "of type "
+ + type);
+ }
+
+ delegateHandler = handlerFactory.getActionSaxHandler(
+ uri,
+ localName,
+ qName,
+ attributes,
+ configurationProvider,
+ projectPaths);
+ }
+ else
+ {
+ throw new SAXException("unknown element : " + qName);
+ }
+ }
+
+ /**
+ * Callback method which is called by the SAX parser if an XML element is
+ * ended.
+ * If an action element is ended, the action is added to the action
+ * list for the mergepoint. If the mergepoint element is ended, the parser
+ * marks itself as finished.
+ *
+ * @param uri The namespace URI of the ended element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if Namespace processing is not being performed.
+ * @param qName The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ *
+ * @see org.xml.sax.ContentHandler#endElement(String, String, String)
+ */
+ public void endElement(String uri, String localName, String qName)
+ {
+ if (ACTION_TAG.equals(qName))
+ {
+ mergepointMapping.addAction(delegateHandler.getAction());
+ delegateHandler = null;
+ }
+ else if (MERGEPOINT_TAG.equals(qName))
+ {
+ finished = true;
+ }
+ }
+
+ /**
+ * Returns whether the parser has finished parsing the mergepoint tag.
+ *
+ * @return true if the parser has finished, false otherwise.
+ */
+ public boolean isFinished()
+ {
+ return finished;
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionActionSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionActionSaxHandler.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionActionSaxHandler.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionActionSaxHandler.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,105 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_ACCEPT_NOT_SET_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_OPTION_ATTRIBUTE;
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.SaxHelper;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.apache.torque.gf.control.action.OptionAction;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A SAX handler which reads the configuration for a OptionAction
+ * and creates and configures the Action according to the values in the
+ * configuration XML.
+ */
+public class OptionActionSaxHandler extends ActionSaxHandler
+{
+ /**
+ * Creates a OptionActionSaxHandler for reading the configuration
+ * of a OptionAction.
+ * @param uri - The Namespace URI, or the empty string if the
+ * element has no Namespace URI or if Namespace processing is not
+ * being performed.
+ * @param localName - The local name (without prefix), or
+ * the empty string if Namespace processing is not being performed.
+ * @param qName - The qualified name (with prefix), or the empty string if
+ * qualified names are not available.
+ * @param attributes - The attributes attached to the element.
+ * If there are no attributes, it shall be an empty Attributes
+ * object.
+ * @param configurationProvider The access object for the configuration
+ * files, not null.
+ * @param projectPaths The paths of the surrounding project, not null.
+ *
+ * @throws NullPointerException if an argument is null.
+ * @throws SAXException if the element cannot be processed correctly.
+ */
+ public OptionActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ super(createAction(attributes), configurationProvider, projectPaths);
+ }
+
+ /**
+ * Creates the action from the attributes of the action element.
+ *
+ * @param attributes the attributes of the action element.
+ *
+ * @return the action filled with the attribute values, not null.
+ *
+ * @throws SAXException if the creation of the action fails.
+ */
+ private static OptionAction createAction(Attributes attributes)
+ throws SAXException
+ {
+ String option = attributes.getValue(ACTION_OPTION_ATTRIBUTE);
+ Boolean acceptNotSet = SaxHelper.getBooleanAttribute(
+ ACTION_ACCEPT_NOT_SET_ATTRIBUTE,
+ attributes,
+ "the OptionAction " + option);
+ OptionAction action = new OptionAction(option, acceptNotSet);
+ return action;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void startElement(
+ String uri,
+ String localName,
+ String rawName,
+ Attributes attributes)
+ throws SAXException
+ {
+ throw new SAXException("Unknown tag " + rawName);
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionActionSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionActionSaxHandlerFactory.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionActionSaxHandlerFactory.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionActionSaxHandlerFactory.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,86 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A Factory which creates a SAX handler for an OptionAction.
+ */
+public class OptionActionSaxHandlerFactory
+ implements ActionSaxHandlerFactory
+{
+ /**
+ * The type of the generators which can be processed by the
+ * ActionSaxHandlers created by this factory.
+ */
+ private static final String ACTION_TYPE = "optionAction";
+
+ /**
+ * Returns the generator type which can be handled by the
+ * GeneratorSaxHandlers created by this factory.
+ * @return "optionAction".
+ */
+ public String getType()
+ {
+ return ACTION_TYPE;
+ }
+
+ /**
+ * Returns a OptionActionSaxHandler for reading the configuration of
+ * OptionActions.
+ *
+ * @param uri The namespace URI of the action element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if namespace processing is not being performed.
+ * @param qName The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element.
+ * @param configurationProvider for accessing the configuration files,
+ * not null.
+ * @param projectPaths The organization of the surrounding project,
+ * not null.
+ *
+ * @return a new OptionActionSaxHandler.
+ */
+ public final OptionActionSaxHandler getActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ return new OptionActionSaxHandler(
+ uri,
+ localName,
+ qName,
+ attributes,
+ configurationProvider,
+ projectPaths);
+ }
+
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionsSaxHandlerFactories.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionsSaxHandlerFactories.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionsSaxHandlerFactories.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OptionsSaxHandlerFactories.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,110 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.torque.gf.configuration.ConfigurationException;
+import org.apache.torque.gf.configuration.option.OptionsSaxHandlerFactory;
+import org.apache.torque.gf.configuration.option.PropertiesOptionsSaxHandlerFactory;
+import org.apache.torque.gf.configuration.option.XmlOptionsSaxHandlerFactory;
+
+/**
+ * A registry of OptionsSaxHandlerFactories.
+ *
+ * $Id: $
+ */
+public class OptionsSaxHandlerFactories
+{
+ /** The class log. */
+ private static Log log
+ = LogFactory.getLog(OptionsSaxHandlerFactories.class);
+
+ /**
+ * A map containing all known ActionSaxHandlerFactories,
+ * keyed by the type of the action.
+ */
+ private Map<String, OptionsSaxHandlerFactory> factories
+ = new HashMap<String, OptionsSaxHandlerFactory>();
+
+ /**
+ * Constructor. Registers the default OptionsSaxHandlerFactories.
+ */
+ public OptionsSaxHandlerFactories()
+ {
+ try
+ {
+ register(new XmlOptionsSaxHandlerFactory());
+ register(new PropertiesOptionsSaxHandlerFactory());
+ }
+ catch (ConfigurationException e)
+ {
+ // should not happen
+ log.error("caught ConfigurationException while registering "
+ + "the default Options Sax Handler Factories", e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Registers a new OptionsSaxHandlerFactory.
+ *
+ * @param optionsSaxHandlerFactory the factory to register, not null.
+ *
+ * @throws ConfigurationException if the type of the registered factory
+ * already exists.
+ */
+ public void register(OptionsSaxHandlerFactory optionsSaxHandlerFactory)
+ throws ConfigurationException
+ {
+ String type = optionsSaxHandlerFactory.getType();
+
+ OptionsSaxHandlerFactory oldFactory = factories.get(type);
+ if (oldFactory != null)
+ {
+ throw new ConfigurationException(
+ "Attempted to register an OptionsSaxHandlerFactory "
+ + "of type "
+ + optionsSaxHandlerFactory.getType()
+ + " and class "
+ + optionsSaxHandlerFactory.getClass().getName()
+ + " : A factory with this type already exists, "
+ + " it has the class "
+ + oldFactory.getClass().getName());
+ }
+ factories.put(type, optionsSaxHandlerFactory);
+ }
+
+ /**
+ * Returns the OptionsSaxHandlerFactory associated with the given type.
+ *
+ * @param type the type top look for, not null.
+ *
+ * @return the OptionsSaxHandlerFactory associated with the given type,
+ * or null if no OptionsSaxHandlerFactory exists for the given type.
+ */
+ public OptionsSaxHandlerFactory getOptionsSaxHandlerFactory(String type)
+ {
+ return factories.get(type);
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OutputActionSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OutputActionSaxHandler.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OutputActionSaxHandler.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OutputActionSaxHandler.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,99 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_VALUE_ATTRIBUTE;
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.apache.torque.gf.control.action.OutputAction;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A SAX handler which reads the configuration for a OutputAction
+ * and creates and configures the Action according to the values in the
+ * configuration XML.
+ */
+public class OutputActionSaxHandler extends ActionSaxHandler
+{
+ /**
+ * Creates a OutputActionSaxHandler for reading the configuration
+ * of a OptionAction.
+ * @param uri - The Namespace URI, or the empty string if the
+ * element has no Namespace URI or if Namespace processing is not
+ * being performed.
+ * @param localName - The local name (without prefix), or
+ * the empty string if Namespace processing is not being performed.
+ * @param qName - The qualified name (with prefix), or the empty string if
+ * qualified names are not available.
+ * @param attributes - The attributes attached to the element.
+ * If there are no attributes, it shall be an empty Attributes
+ * object.
+ * @param configurationProvider The access object for the configuration
+ * files, not null.
+ * @param projectPaths The paths of the surrounding project, not null.
+ *
+ * @throws NullPointerException if an argument is null.
+ * @throws SAXException if the element cannot be processed correctly.
+ */
+ public OutputActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ super(createAction(attributes), configurationProvider, projectPaths);
+ }
+
+ /**
+ * Creates the action from the attributes of the action element.
+ *
+ * @param attributes the attributes of the action element.
+ *
+ * @return the action filled with the attribute values, not null.
+ *
+ * @throws SAXException if the creation of the action fails.
+ */
+ private static OutputAction createAction(Attributes attributes)
+ throws SAXException
+ {
+ String value = attributes.getValue(ACTION_VALUE_ATTRIBUTE);
+ OutputAction action = new OutputAction(value);
+ return action;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void startElement(
+ String uri,
+ String localName,
+ String rawName,
+ Attributes attributes)
+ throws SAXException
+ {
+ throw new SAXException("Unknown tag " + rawName);
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OutputActionSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OutputActionSaxHandlerFactory.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OutputActionSaxHandlerFactory.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/OutputActionSaxHandlerFactory.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,86 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A Factory which creates a SAX handler for an OutputAction.
+ */
+public class OutputActionSaxHandlerFactory
+ implements ActionSaxHandlerFactory
+{
+ /**
+ * The type of the generators which can be processed by the
+ * ActionSaxHandlers created by this factory.
+ */
+ private static final String ACTION_TYPE = "outputAction";
+
+ /**
+ * Returns the generator type which can be handled by the
+ * GeneratorSaxHandlers created by this factory.
+ * @return "outputAction".
+ */
+ public String getType()
+ {
+ return ACTION_TYPE;
+ }
+
+ /**
+ * Returns a OutputActionSaxHandler for reading the configuration of
+ * OptionActions.
+ *
+ * @param uri The namespace URI of the action element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if namespace processing is not being performed.
+ * @param qName The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element.
+ * @param configurationProvider for accessing the configuration files,
+ * not null.
+ * @param projectPaths The organization of the surrounding project,
+ * not null.
+ *
+ * @return a new OptionActionSaxHandler.
+ */
+ public final OutputActionSaxHandler getActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ return new OutputActionSaxHandler(
+ uri,
+ localName,
+ qName,
+ attributes,
+ configurationProvider,
+ projectPaths);
+ }
+
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/SourceElementAttributeActionSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/SourceElementAttributeActionSaxHandler.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/SourceElementAttributeActionSaxHandler.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/SourceElementAttributeActionSaxHandler.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,111 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_ATTRIBUTE_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_ELEMENT_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_ACCEPT_NOT_SET_ATTRIBUTE;
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.SaxHelper;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.apache.torque.gf.control.action.SourceElementAttributeAction;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A SAX handler which reads the configuration for a
+ * SourceElementAttributeAction and creates and configures the Action
+ * according to the values in the configuration XML.
+ */
+public class SourceElementAttributeActionSaxHandler extends ActionSaxHandler
+{
+ /**
+ * Creates a OptionActionSaxHandler for reading the configuration
+ * of a SourceElementAttributeAction.
+ * @param uri The namespace URI of the action element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if Namespace processing is not being performed.
+ * @param qName - The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element.
+ * @param configurationProvider for accessing the configuratiopn files,
+ * not null.
+ * @param projectPaths The organization of the surrounding project,
+ * not null.
+ *
+ * @throws NullPointerException if an argument is null.
+ * @throws SAXException if the element cannot be processed correctly.
+ */
+ public SourceElementAttributeActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ super(createAction(attributes), configurationProvider, projectPaths);
+ }
+
+ /**
+ * Creates the action from the attributes of the action element.
+ *
+ * @param attributes the attributes of the action element.
+ *
+ * @return the action filled with the attribute values, not null.
+ *
+ * @throws SAXException if the creation of the action fails.
+ */
+ private static SourceElementAttributeAction createAction(
+ Attributes attributes)
+ throws SAXException
+ {
+ String element = attributes.getValue(ACTION_ELEMENT_ATTRIBUTE);
+ String attribute = attributes.getValue(ACTION_ATTRIBUTE_ATTRIBUTE);
+ Boolean acceptNotSet = SaxHelper.getBooleanAttribute(
+ ACTION_ACCEPT_NOT_SET_ATTRIBUTE,
+ attributes,
+ "the SourceElementAttributeAction " + element);
+ SourceElementAttributeAction action
+ = new SourceElementAttributeAction(
+ element,
+ attribute,
+ acceptNotSet);
+ return action;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void startElement(
+ String uri,
+ String localName,
+ String rawName,
+ Attributes attributes)
+ throws SAXException
+ {
+ throw new SAXException("Unknown tag " + rawName);
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/SourceElementAttributeActionSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/SourceElementAttributeActionSaxHandlerFactory.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/SourceElementAttributeActionSaxHandlerFactory.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/SourceElementAttributeActionSaxHandlerFactory.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,86 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A Factory which creates a SAX handler for a SourceElementAttributeAction.
+ */
+public class SourceElementAttributeActionSaxHandlerFactory
+ implements ActionSaxHandlerFactory
+{
+ /**
+ * The type of the generators which can be processed by the
+ * ActionSaxHandlers created by this factory.
+ */
+ private static final String ACTION_TYPE = "sourceElementAttributeAction";
+
+ /**
+ * Returns the generator type which can be handled by the
+ * GeneratorSaxHandlers created by this factory.
+ * @return "sourceElementAction".
+ */
+ public String getType()
+ {
+ return ACTION_TYPE;
+ }
+
+ /**
+ * Returns a OptionActionSaxHandler for reading the configuration of
+ * SourceElementAttributeActions.
+ *
+ * @param uri The namespace URI of the action element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if namespace processing is not being performed.
+ * @param qName The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element.
+ * @param configurationProvider for accessing the configuration files,
+ * not null.
+ * @param projectPaths The organization of the surrounding project,
+ * not null.
+ *
+ * @return a new SourceElementAttributeActionSaxHandler.
+ */
+ public final SourceElementAttributeActionSaxHandler getActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ return new SourceElementAttributeActionSaxHandler(
+ uri,
+ localName,
+ qName,
+ attributes,
+ configurationProvider,
+ projectPaths);
+ }
+
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/TraverseAllActionSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/TraverseAllActionSaxHandler.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/TraverseAllActionSaxHandler.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/TraverseAllActionSaxHandler.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,110 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_ACCEPT_EMPTY_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_ELEMENT_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.mergepoint.MergepointConfigurationTags.ACTION_GENERATOR_ATTRIBUTE;
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.SaxHelper;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.apache.torque.gf.control.action.MergepointAction;
+import org.apache.torque.gf.control.action.TraverseAllAction;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A SAX handler which reads the configuration for a TraverseAllAction
+ * and creates and configures the Action according to the values in the
+ * configuration XML.
+ */
+public class TraverseAllActionSaxHandler extends ActionSaxHandler
+{
+ /**
+ * Creates a TraverseAllActionSaxHandler for redaing the configuration
+ * of a TraverseAllAction.
+ * @param uri The namespace URI of the action element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if Namespace processing is not being performed.
+ * @param qName - The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element.
+ * @param configurationProvider for accessing the configuratiopn files,
+ * not null.
+ * @param projectPaths The organization of the surrounding project,
+ * not null.
+ *
+ * @throws NullPointerException if an argument is null.
+ * @throws SAXException if the element cannot be processed correctly.
+ */
+ public TraverseAllActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ super(createAction(attributes), configurationProvider, projectPaths);
+ }
+
+ /**
+ * Creates the action from the attributes of the action element.
+ *
+ * @param attributes the attributes of the action element.
+ *
+ * @return the action filled with the attribute values, not null.
+ *
+ * @throws SAXException if the creation of the action fails.
+ */
+ private static MergepointAction createAction(Attributes attributes)
+ throws SAXException
+ {
+ String element = attributes.getValue(ACTION_ELEMENT_ATTRIBUTE);
+ String generator = attributes.getValue(ACTION_GENERATOR_ATTRIBUTE);
+ Boolean acceptEmpty = SaxHelper.getBooleanAttribute(
+ ACTION_ACCEPT_EMPTY_ATTRIBUTE,
+ attributes,
+ "the element " + element);
+ TraverseAllAction action = new TraverseAllAction(
+ element,
+ generator,
+ acceptEmpty);
+ return action;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void startElement(
+ String uri,
+ String localName,
+ String rawName,
+ Attributes attributes)
+ throws SAXException
+ {
+ throw new SAXException("Unknown tag " + rawName);
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/TraverseAllActionSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/TraverseAllActionSaxHandlerFactory.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/TraverseAllActionSaxHandlerFactory.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/TraverseAllActionSaxHandlerFactory.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,86 @@
+package org.apache.torque.gf.configuration.mergepoint;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A Factory which creates a SAX handler for a TraverseAllAction.
+ */
+public class TraverseAllActionSaxHandlerFactory
+ implements ActionSaxHandlerFactory
+{
+ /**
+ * The type of the generators which can be processed by the
+ * ActionSaxHandlers created by this factory.
+ */
+ private static final String ACTION_TYPE = "traverseAllAction";
+
+ /**
+ * Returns the generator type which can be handled by the
+ * GeneratorSaxHandlers created by this factory.
+ * @return "traverseAllAction".
+ */
+ public String getType()
+ {
+ return ACTION_TYPE;
+ }
+
+ /**
+ * Returns a TraverseAllActionSaxHandler for reading the configuration of
+ * TraverseAllActions.
+ *
+ * @param uri The namespace URI of the action element,
+ * or the empty string if the element has no namespace URI
+ * or if namespace processing is not being performed.
+ * @param localName The local name (without prefix), or
+ * the empty string if namespace processing is not being performed.
+ * @param qName The qualified name (with prefix, if present),
+ * or the empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element.
+ * @param configurationProvider for accessing the configuration files,
+ * not null.
+ * @param projectPaths The organization of the surrounding project,
+ * not null.
+ *
+ * @return a new TraverseAllActionSaxHandler.
+ */
+ public final TraverseAllActionSaxHandler getActionSaxHandler(
+ String uri,
+ String localName,
+ String qName,
+ Attributes attributes,
+ ConfigurationProvider configurationProvider,
+ ProjectPaths projectPaths)
+ throws SAXException
+ {
+ return new TraverseAllActionSaxHandler(
+ uri,
+ localName,
+ qName,
+ attributes,
+ configurationProvider,
+ projectPaths);
+ }
+
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/package.html
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/package.html?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/package.html (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/mergepoint/package.html Tue Feb 16 17:15:43 2010
@@ -0,0 +1,26 @@
+<!--
+ Copyright 2001-2006 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License")
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+ <head>
+ <title>Configuring Torque-gf mergepoints</title>
+ </head>
+ <body>
+ <p>
+ This package contains the classes for reading the mergepoint mappings for
+ Torque-gf units of generation.
+ </p>
+ </body>
+</html>
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/FileOptionsConfiguration.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/FileOptionsConfiguration.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/FileOptionsConfiguration.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/FileOptionsConfiguration.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,69 @@
+package org.apache.torque.gf.configuration.option;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * An options configuration which reads options from a file.
+ *
+ * $Id: $
+ */
+public abstract class FileOptionsConfiguration extends OptionsConfigurationBase
+{
+ /**
+ * The path to the options file.
+ */
+ private String path;
+
+ /**
+ * Sets the path to the options file.
+ *
+ * @param path the path, not null.
+ *
+ * @throws NullPointerException if path is null.
+ */
+ void setPath(String path)
+ {
+ if (path == null)
+ {
+ throw new NullPointerException("path must not be null");
+ }
+ this.path = path;
+ }
+
+ /**
+ * Returns the path to the options file.
+ *
+ * @return the path, not null if type is xml or properties.
+ */
+ public String getPath()
+ {
+ return path;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer result = new StringBuffer();
+ result.append("(path=")
+ .append(path);
+ result.append(")");
+ return result.toString();
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/FileOptionsSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/FileOptionsSaxHandler.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/FileOptionsSaxHandler.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/FileOptionsSaxHandler.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,90 @@
+package org.apache.torque.gf.configuration.option;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.torque.gf.configuration.option.OptionTags.OPTIONS_PATH_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.option.OptionTags.OPTIONS_TAG;
+
+import org.apache.torque.gf.configuration.SaxHelper;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * Reads a file options configuration.
+ */
+public class FileOptionsSaxHandler extends OptionsSaxHandler
+{
+ /** The option configuration which is currently filled. */
+ private FileOptionsConfiguration optionsConfiguration;
+
+ public FileOptionsSaxHandler(FileOptionsConfiguration optionsConfiguration)
+ {
+ super(optionsConfiguration);
+ if (optionsConfiguration == null)
+ {
+ throw new NullPointerException(
+ "optionsConfiguration must not be null");
+ }
+ this.optionsConfiguration = optionsConfiguration;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void startElement(String uri, String localName, String qName,
+ Attributes attributes)
+ throws SAXException
+ {
+ String unqualifiedName = SaxHelper.getUnqualifiedName(localName, qName);
+ if (OPTIONS_TAG.equals(unqualifiedName))
+ {
+ String path = attributes.getValue(OPTIONS_PATH_ATTRIBUTE);
+ if (path == null)
+ {
+ throw new SAXException(
+ "path must not be null for file options");
+ }
+ optionsConfiguration.setPath(path);
+ }
+ else
+ {
+ throw new SAXException("Unknown element " + unqualifiedName);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException
+ {
+ String unqualifiedName = SaxHelper.getUnqualifiedName(localName, qName);
+ if (OPTIONS_TAG.equals(unqualifiedName))
+ {
+ finished();
+ }
+ else
+ {
+ throw new SAXException("Unknown element " + unqualifiedName);
+ }
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/MapOptionsConfiguration.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/MapOptionsConfiguration.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/MapOptionsConfiguration.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/MapOptionsConfiguration.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,86 @@
+package org.apache.torque.gf.configuration.option;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.torque.gf.configuration.ConfigurationException;
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.option.Option;
+
+/**
+ * An option configuration in which the options are provided inside a java map.
+ *
+ * $Id: $
+ */
+public class MapOptionsConfiguration extends OptionsConfigurationBase
+{
+ /** The map containing the options. */
+ private Map<String, String> optionMap;
+
+ /**
+ * Constructor.
+ *
+ * @param content the options to set.
+ *
+ * @throws NullPointerException if content is null.
+ */
+ public MapOptionsConfiguration(final Map<String, String> content)
+ {
+ optionMap = new HashMap<String, String>(content);
+ }
+
+ /**
+ * Returns the options map.
+ *
+ * @return the options map, not null.
+ */
+ public Map<String, String> getOptionMap()
+ {
+ return optionMap;
+ }
+
+ /**
+ * Returns the contained options.
+ *
+ * @param configurationProvider the configuration provider to access
+ * configuration files, not null.
+ *
+ * @return the options contained in this configuration, not null.
+ */
+ public Collection<Option> getOptions(
+ ConfigurationProvider configurationProvider)
+ throws ConfigurationException
+ {
+ return toOptions(optionMap);
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer result = new StringBuffer();
+ result.append("(optionMap=")
+ .append(optionMap);
+ result.append(")");
+ return result.toString();
+ }
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionTags.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionTags.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionTags.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionTags.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,42 @@
+package org.apache.torque.gf.configuration.option;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * The element and attribute names for the option configuration.
+ */
+public final class OptionTags
+{
+ /**
+ * Private constructor for utility class.
+ */
+ private OptionTags()
+ {
+ }
+
+ /** Tag name for the "options" tag. */
+ public static final String OPTIONS_TAG = "options";
+
+ /** Attribute name for the "path" attribute of the "options" tag. */
+ public static final String OPTIONS_PATH_ATTRIBUTE = "path";
+
+ /** Attribute name for the "type" attribute of the "options" tag. */
+ public static final String OPTIONS_TYPE_ATTRIBUTE = "type";
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionsConfiguration.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionsConfiguration.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionsConfiguration.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionsConfiguration.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,47 @@
+package org.apache.torque.gf.configuration.option;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collection;
+
+import org.apache.torque.gf.configuration.ConfigurationException;
+import org.apache.torque.gf.configuration.ConfigurationProvider;
+import org.apache.torque.gf.option.Option;
+
+/**
+ * The part of the configuration which provides information to set options.
+ */
+public interface OptionsConfiguration
+{
+ /**
+ * Retrieves the configured options and returns them.
+ *
+ * @param configurationProvider The configuration provider to access
+ * the option files.
+ *
+ * @return the read options, not null.
+ *
+ * @throws ConfigurationException if an error occurs while reading
+ * the options.
+ */
+ Collection<Option> getOptions(
+ ConfigurationProvider configurationProvider)
+ throws ConfigurationException;
+}
Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionsConfigurationBase.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionsConfigurationBase.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionsConfigurationBase.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/option/OptionsConfigurationBase.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,70 @@
+package org.apache.torque.gf.configuration.option;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.torque.gf.option.Option;
+import org.apache.torque.gf.option.OptionImpl;
+
+/**
+ * Base class with common functionality for all option configurations.
+ *
+ * $Id: $
+ */
+abstract class OptionsConfigurationBase implements OptionsConfiguration
+{
+ /** The class log. */
+ private static Log log = LogFactory.getLog(OptionsConfigurationBase.class);
+
+ /**
+ * Creates options from a Map and returns them.
+ *
+ * @param optionsMap the map containing the option qualified names as key
+ * and the option value as value; not null.
+ *
+ * @return the options, not null.
+ */
+ protected Collection<Option> toOptions(
+ Map<? extends Object, ? extends Object> optionsMap)
+ {
+ Set<Option> options = new HashSet<Option>();
+ for (Entry<? extends Object, ? extends Object> entry
+ : optionsMap.entrySet())
+ {
+ Option option = new OptionImpl(
+ entry.getKey().toString(),
+ entry.getValue().toString());
+ options.add(option);
+ if (log.isTraceEnabled())
+ {
+ log.trace("Setting option " + entry.getKey()
+ + " to value " + entry.getValue());
+ }
+ }
+ return options;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org