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,v 1.1 2007-10-21 07:57:27 abyrne Exp $ 030 */ 031 public class IdMethodParameter 032 { 033 private String name; 034 private String value; 035 private Table parentTable; 036 037 /** 038 * Imports foreign key from an XML specification 039 */ 040 public void loadFromXML (Attributes attrib) 041 { 042 name = attrib.getValue("name"); 043 value = attrib.getValue("value"); 044 } 045 046 /** 047 * Get the parameter name 048 */ 049 public String getName() 050 { 051 return name; 052 } 053 054 /** 055 * Set the parameter name 056 */ 057 public void setName(String name) 058 { 059 this.name = name; 060 } 061 062 /** 063 * Get the parameter value 064 */ 065 public String getValue() 066 { 067 return value; 068 } 069 070 /** 071 * Set the parameter value 072 */ 073 public void setValue(String value) 074 { 075 this.value = value; 076 } 077 078 /** 079 * Set the parent Table of the id method 080 */ 081 public void setTable(Table parent) 082 { 083 parentTable = parent; 084 } 085 086 /** 087 * Get the parent Table of the id method 088 */ 089 public Table getTable() 090 { 091 return parentTable; 092 } 093 094 /** 095 * Returns the Name of the table the id method is in 096 */ 097 public String getTableName() 098 { 099 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 }