View Javadoc

1   package org.apache.torque.engine.database.model;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.xml.sax.Attributes;
20  
21  /***
22   * Information related to an ID method.
23   *
24   * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
25   * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
26   * @version $Id: IdMethodParameter.java 239624 2005-08-24 12:18:03Z henning $
27   */
28  public class IdMethodParameter
29  {
30      private String name;
31      private String value;
32      private Table parentTable;
33  
34      /***
35       * Imports foreign key from an XML specification
36       */
37      public void loadFromXML (Attributes attrib)
38      {
39          name = attrib.getValue("name");
40          value = attrib.getValue("value");
41      }
42  
43      /***
44       * Get the parameter name
45       */
46      public String getName()
47      {
48          return name;
49      }
50  
51      /***
52       * Set the parameter name
53       */
54      public void setName(String name)
55      {
56          this.name = name;
57      }
58  
59      /***
60       * Get the parameter value
61       */
62      public String getValue()
63      {
64          return value;
65      }
66  
67      /***
68       * Set the parameter value
69       */
70      public void setValue(String value)
71      {
72          this.value = value;
73      }
74  
75      /***
76       * Set the parent Table of the id method
77       */
78      public void setTable(Table parent)
79      {
80          parentTable = parent;
81      }
82  
83      /***
84       * Get the parent Table of the id method
85       */
86      public Table getTable()
87      {
88          return parentTable;
89      }
90  
91      /***
92       * Returns the Name of the table the id method is in
93       */
94      public String getTableName()
95      {
96          return parentTable.getName();
97      }
98  
99      /***
100      * XML representation of the foreign key.
101      */
102     public String toString()
103     {
104         StringBuffer result = new StringBuffer();
105         result.append(" <id-method-parameter");
106         if (getName() != null)
107         {
108             result.append(" name=\"")
109                   .append(getName())
110                   .append("\"");
111         }
112         result.append(" value=\"")
113               .append(getValue())
114               .append("\">\n");
115         return result.toString();
116     }
117 }