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: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.amber.field;
031:
032: import com.caucho.amber.expr.AmberExpr;
033: import com.caucho.amber.expr.EmbeddedExpr;
034: import com.caucho.amber.expr.PathExpr;
035: import com.caucho.amber.query.QueryParser;
036: import com.caucho.amber.table.Column;
037: import com.caucho.amber.table.Table;
038: import com.caucho.amber.type.EmbeddableType;
039: import com.caucho.amber.type.RelatedType;
040: import com.caucho.amber.type.Type;
041: import com.caucho.config.ConfigException;
042: import com.caucho.java.JavaWriter;
043: import com.caucho.log.Log;
044: import com.caucho.util.CharBuffer;
045: import com.caucho.util.L10N;
046:
047: import java.io.IOException;
048: import java.util.ArrayList;
049: import java.util.HashMap;
050: import java.util.Map;
051: import java.util.logging.Logger;
052:
053: /**
054: * Represents the sub-field of an embedded type.
055: */
056: public class KeyEmbeddedSubField extends EmbeddedSubField implements
057: IdField {
058: public KeyEmbeddedSubField(EntityEmbeddedField embeddedField,
059: AmberField embeddableField, int index)
060: throws ConfigException {
061: super (embeddedField, embeddableField, index);
062: }
063:
064: /**
065: * Returns the columns
066: */
067: public ArrayList<Column> getColumns() {
068: ArrayList<Column> columns = new ArrayList<Column>();
069:
070: columns.add(getColumn());
071:
072: return columns;
073: }
074:
075: /**
076: * Returns the column type
077: */
078: public Type getType() {
079: return getColumn().getType();
080: }
081:
082: /**
083: * Returns true for a generator.
084: */
085: public boolean isAutoGenerate() {
086: // XXX: can an @EmbeddedId have a @Generated field?
087: return false;
088: }
089:
090: /**
091: * Sets true if there are multiple keys.
092: */
093: public void setKeyField(boolean isKey) {
094: throw new UnsupportedOperationException();
095: }
096:
097: /**
098: * Returns the foreign type.
099: */
100: public String getForeignTypeName() {
101: return getColumn().getType().getForeignTypeName();
102: }
103:
104: /**
105: * Returns the component count.
106: */
107: public int getComponentCount() {
108: return 1;
109: }
110:
111: /**
112: * Returns the generator.
113: */
114: public String getGenerator() {
115: return null;
116: }
117:
118: /**
119: * Generates code to copy to an object.
120: */
121: public void generateCopy(JavaWriter out, String dest, String source)
122: throws IOException {
123: throw new UnsupportedOperationException(getClass().getName());
124: }
125:
126: /**
127: * Generates the setter for a key property
128: */
129: public String generateSetKeyProperty(String key, String value)
130: throws IOException {
131: throw new UnsupportedOperationException();
132: }
133:
134: /**
135: * Generates the getter for a key property
136: */
137: public String generateGetKeyProperty(String key) throws IOException {
138: throw new UnsupportedOperationException();
139: }
140:
141: /**
142: * Generates the property getter for an EJB proxy
143: *
144: * @param value the non-null value
145: */
146: public String generateGetProxyProperty(String value) {
147: throw new UnsupportedOperationException();
148: }
149:
150: /**
151: * Generates the set clause.
152: */
153: public void generateSetGeneratedKeys(JavaWriter out, String pstmt)
154: throws IOException {
155:
156: }
157:
158: /**
159: * Generates the set for an insert.
160: */
161: public void generateCheckCreateKey(JavaWriter out)
162: throws IOException {
163: throw new UnsupportedOperationException();
164: }
165:
166: /**
167: * Generates the set for an insert.
168: */
169: public void generateSetInsert(JavaWriter out, String pstmt,
170: String index) throws IOException {
171: // XXX: autogenerate stuff, see KeyPropertyField
172:
173: generateSet(out, pstmt, index);
174: }
175:
176: /**
177: * Returns the foreign type.
178: */
179: public int generateLoadForeign(JavaWriter out, String rs,
180: String indexVar, int index) throws IOException {
181: throw new UnsupportedOperationException();
182: }
183:
184: /**
185: * Returns the foreign type.
186: */
187: public int generateLoadForeign(JavaWriter out, String rs,
188: String indexVar, int index, String name) throws IOException {
189: throw new UnsupportedOperationException();
190: }
191:
192: /**
193: * Returns a test for null.
194: */
195: public String generateIsNull(String value) {
196: throw new UnsupportedOperationException();
197: }
198:
199: /**
200: * Returns the where code
201: */
202: public String generateRawWhere(String id) {
203: throw new UnsupportedOperationException();
204: }
205:
206: /**
207: * Returns the key code
208: */
209: public String generateMatchArgWhere(String id) {
210: throw new UnsupportedOperationException();
211: }
212:
213: /**
214: * Converts from an object.
215: */
216: public String toValue(String value) {
217: throw new UnsupportedOperationException();
218: }
219: }
|