1 package org.apache.torque.engine.database.model;
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 org.xml.sax.Attributes;
23
24 /**
25 * Information related to an ID method.
26 *
27 * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
28 * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
29 * @version $Id: IdMethodParameter.java,v 1.1 2007-10-21 07:57:27 abyrne Exp $
30 */
31 public class IdMethodParameter
32 {
33 private String name;
34 private String value;
35 private Table parentTable;
36
37 /**
38 * Imports foreign key from an XML specification
39 */
40 public void loadFromXML (Attributes attrib)
41 {
42 name = attrib.getValue("name");
43 value = attrib.getValue("value");
44 }
45
46 /**
47 * Get the parameter name
48 */
49 public String getName()
50 {
51 return name;
52 }
53
54 /**
55 * Set the parameter name
56 */
57 public void setName(String name)
58 {
59 this.name = name;
60 }
61
62 /**
63 * Get the parameter value
64 */
65 public String getValue()
66 {
67 return value;
68 }
69
70 /**
71 * Set the parameter value
72 */
73 public void setValue(String value)
74 {
75 this.value = value;
76 }
77
78 /**
79 * Set the parent Table of the id method
80 */
81 public void setTable(Table parent)
82 {
83 parentTable = parent;
84 }
85
86 /**
87 * Get the parent Table of the id method
88 */
89 public Table getTable()
90 {
91 return parentTable;
92 }
93
94 /**
95 * Returns the Name of the table the id method is in
96 */
97 public String getTableName()
98 {
99 return parentTable.getName();
100 }
101
102 /**
103 * XML representation of the foreign key.
104 */
105 public String toString()
106 {
107 StringBuffer result = new StringBuffer();
108 result.append(" <id-method-parameter");
109 if (getName() != null)
110 {
111 result.append(" name=\"")
112 .append(getName())
113 .append("\"");
114 }
115 result.append(" value=\"")
116 .append(getValue())
117 .append("\">\n");
118 return result.toString();
119 }
120 }