KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > torque > engine > database > model > IdMethodParameter


1 package org.apache.torque.engine.database.model;
2
3 /*
4  * Copyright 2001,2004 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 JavaDoc;
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,v 1.3 2004/02/22 06:27:19 jmcnally Exp $
27  */

28 public class IdMethodParameter
29 {
30     private String JavaDoc name;
31     private String JavaDoc value;
32     private Table parentTable;
33
34     /**
35      * Imports foreign key from an XML specification
36      */

37     public void loadFromXML (Attributes JavaDoc attrib)
38     {
39         name = attrib.getValue("name");
40         value = attrib.getValue("value");
41     }
42
43     /**
44      * Get the parameter name
45      */

46     public String JavaDoc getName()
47     {
48         return name;
49     }
50
51     /**
52      * Set the parameter name
53      */

54     public void setName(String JavaDoc name)
55     {
56         this.name = name;
57     }
58
59     /**
60      * Get the parameter value
61      */

62     public String JavaDoc getValue()
63     {
64         return value;
65     }
66
67     /**
68      * Set the parameter value
69      */

70     public void setValue(String JavaDoc 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 JavaDoc getTableName()
95     {
96         return parentTable.getName();
97     }
98
99     /**
100      * XML representation of the foreign key.
101      */

102     public String JavaDoc toString()
103     {
104         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
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 }
118
Popular Tags