001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free Software Foundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.amber.field;
030:
031: import com.caucho.amber.table.Column;
032: import com.caucho.amber.type.Type;
033: import com.caucho.java.JavaWriter;
034:
035: import java.io.IOException;
036: import java.util.ArrayList;
037:
038: /**
039: * Configuration for a bean's field
040: */
041: public interface IdField extends AmberField {
042: /**
043: * Returns the columns
044: */
045: public ArrayList<Column> getColumns();
046:
047: /**
048: * Returns type
049: */
050: public Type getType();
051:
052: /**
053: * Returns true for a generator.
054: */
055: public boolean isAutoGenerate();
056:
057: /**
058: * Sets true if there are multiple keys.
059: */
060: public void setKeyField(boolean isKey);
061:
062: /**
063: * Returns the foreign type.
064: */
065: public String getForeignTypeName();
066:
067: /**
068: * Returns the java type name.
069: */
070: public String getJavaTypeName();
071:
072: /**
073: * Returns the component count.
074: */
075: public int getComponentCount();
076:
077: /**
078: * Returns the generator.
079: */
080: public String getGenerator();
081:
082: //
083: // Java code generation
084: //
085:
086: /**
087: * Generates the set for an insert.
088: */
089: public void generateCheckCreateKey(JavaWriter out)
090: throws IOException;
091:
092: /**
093: * Generates code to copy to an object.
094: */
095: public void generateCopy(JavaWriter out, String dest, String source)
096: throws IOException;
097:
098: /**
099: * Generates the getter for a key property
100: */
101: public String generateGetKeyProperty(String key) throws IOException;
102:
103: /**
104: * Generates the property getter for an EJB proxy
105: *
106: * @param value the non-null value
107: */
108: public String generateGetProxyProperty(String value);
109:
110: /**
111: * Returns a test for null.
112: */
113: public String generateIsNull(String value);
114:
115: /**
116: * Returns the foreign type.
117: */
118: public int generateLoadForeign(JavaWriter out, String rs,
119: String indexVar, int index) throws IOException;
120:
121: /**
122: * Returns the foreign type.
123: */
124: public int generateLoadForeign(JavaWriter out, String rs,
125: String indexVar, int index, String name) throws IOException;
126:
127: /**
128: * Generates the set clause.
129: */
130: public void generateSetGeneratedKeys(JavaWriter out, String pstmt)
131: throws IOException;
132:
133: /**
134: * Generates the setter for a key property
135: */
136: public String generateSetKeyProperty(String key, String value)
137: throws IOException;
138:
139: /**
140: * Generates the set for an insert.
141: */
142: public void generateSetInsert(JavaWriter out, String pstmt,
143: String index) throws IOException;
144:
145: //
146: // SQL generation
147: //
148:
149: /**
150: * Returns the where code
151: */
152: public String generateRawWhere(String id);
153:
154: /**
155: * Returns the key code
156: */
157: public String generateMatchArgWhere(String id);
158:
159: /**
160: * Converts from an object.
161: */
162: public String toValue(String value);
163: }
|