View Javadoc

1   package org.apache.torque.generator.configuration.mergepoint;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import static org.apache.torque.generator.configuration.mergepoint.MergepointConfigurationTags.ACTION_VALUE_ATTRIBUTE;
23  
24  import org.apache.torque.generator.configuration.ConfigurationProvider;
25  import org.apache.torque.generator.configuration.paths.ProjectPaths;
26  import org.apache.torque.generator.control.action.OutputAction;
27  import org.xml.sax.Attributes;
28  import org.xml.sax.SAXException;
29  
30  /**
31   * A SAX handler which reads the configuration for a OutputAction
32   * and creates and configures the Action according to the values in the
33   * configuration XML.
34   */
35  public class OutputActionSaxHandler extends ActionSaxHandler
36  {
37      /**
38       * Creates a OutputActionSaxHandler for reading the configuration
39       * of a OptionAction.
40       * @param uri - The Namespace URI, or the empty string if the
41       *         element has no Namespace URI or if Namespace processing is not
42       *         being performed.
43       * @param localName - The local name (without prefix), or
44       *         the empty string if Namespace processing is not being performed.
45       * @param qName - The qualified name (with prefix), or the empty string if
46       *          qualified names are not available.
47       * @param attributes - The attributes attached to the element.
48       *          If there are no attributes, it shall be an empty Attributes
49       *          object.
50       * @param configurationProvider The access object for the configuration
51       *        files, not null.
52       * @param projectPaths The paths of the surrounding project, not null.
53       *
54       * @throws NullPointerException if an argument is null.
55       * @throws SAXException if the element cannot be processed correctly.
56       */
57      public OutputActionSaxHandler(
58              String uri,
59              String localName,
60              String qName,
61              Attributes attributes,
62              ConfigurationProvider configurationProvider,
63              ProjectPaths projectPaths)
64           throws SAXException
65       {
66          super(createAction(attributes), configurationProvider, projectPaths);
67       }
68  
69      /**
70       * Creates the action from the attributes of the action element.
71       *
72       * @param attributes the attributes of the action element.
73       *
74       * @return the action filled with the attribute values, not null.
75       *
76       * @throws SAXException if the creation of the action fails.
77       */
78      private static OutputAction createAction(Attributes attributes)
79              throws SAXException
80      {
81          String value = attributes.getValue(ACTION_VALUE_ATTRIBUTE);
82          OutputAction action = new OutputAction(value);
83          return action;
84      }
85  
86      /**
87       * {@inheritDoc}
88       */
89      @Override
90      public void startElement(
91              String uri,
92              String localName,
93              String rawName,
94              Attributes attributes)
95          throws SAXException
96      {
97          throw new SAXException("Unknown tag " + rawName);
98      }
99  }