001: package org.apache.torque.engine.database.model;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.xml.sax.Attributes;
023:
024: /**
025: * Information related to an ID method.
026: *
027: * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
028: * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
029: * @version $Id: IdMethodParameter.java 473814 2006-11-11 22:30:30Z tv $
030: */
031: public class IdMethodParameter {
032: private String name;
033: private String value;
034: private Table parentTable;
035:
036: /**
037: * Imports foreign key from an XML specification
038: */
039: public void loadFromXML(Attributes attrib) {
040: name = attrib.getValue("name");
041: value = attrib.getValue("value");
042: }
043:
044: /**
045: * Get the parameter name
046: */
047: public String getName() {
048: return name;
049: }
050:
051: /**
052: * Set the parameter name
053: */
054: public void setName(String name) {
055: this .name = name;
056: }
057:
058: /**
059: * Get the parameter value
060: */
061: public String getValue() {
062: return value;
063: }
064:
065: /**
066: * Set the parameter value
067: */
068: public void setValue(String value) {
069: this .value = value;
070: }
071:
072: /**
073: * Set the parent Table of the id method
074: */
075: public void setTable(Table parent) {
076: parentTable = parent;
077: }
078:
079: /**
080: * Get the parent Table of the id method
081: */
082: public Table getTable() {
083: return parentTable;
084: }
085:
086: /**
087: * Returns the Name of the table the id method is in
088: */
089: public String getTableName() {
090: return parentTable.getName();
091: }
092:
093: /**
094: * XML representation of the foreign key.
095: */
096: public String toString() {
097: StringBuffer result = new StringBuffer();
098: result.append(" <id-method-parameter");
099: if (getName() != null) {
100: result.append(" name=\"").append(getName()).append("\"");
101: }
102: result.append(" value=\"").append(getValue()).append("\">\n");
103: return result.toString();
104: }
105: }
|