001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.mashup.db.model;
042:
043: import java.io.File;
044: import java.util.Map;
045:
046: import org.netbeans.modules.sql.framework.model.SQLDBTable;
047:
048: /**
049: * Extends DBTable to support metadata and behavior of a flatfile as an analogue for a
050: * database table.
051: *
052: * @author Jonathan Giron
053: * @author Ahimanikya Satapathy
054: * @version $Revision$
055: */
056: public interface FlatfileDBTable extends SQLDBTable {
057:
058: public static final String PROP_CREATE_IF_NOT_EXIST = "CREATE_IF_NOT_EXIST";
059:
060: /* Constant: property name for file name */
061: public static final String PROP_FILENAME = "FILENAME"; // NOI18N
062:
063: /* Constant: prefix of names for wizard-only properties */
064: public static final String PROP_WIZARD = "WIZARD"; // NOI18N
065:
066: /**
067: * Clone a deep copy of DBTable.
068: *
069: * @return a copy of DBTable.
070: */
071: Object clone();
072:
073: /**
074: * Compares DBTable with another object for lexicographical ordering. Null objects and
075: * those DBTables with null names are placed at the end of any ordered collection
076: * using this method.
077: *
078: * @param refObj Object to be compared.
079: * @return -1 if the column name is less than obj to be compared. 0 if the column name
080: * is the same. 1 if the column name is greater than obj to be compared.
081: */
082: int compareTo(Object refObj);
083:
084: /**
085: * Performs deep copy of contents of given FlatfileDBTable. We deep copy (that is, the
086: * method clones all child objects such as columns) because columns have a
087: * parent-child relationship that must be preserved internally.
088: *
089: * @param source FlatfileDBTable providing contents to be copied.
090: */
091: void copyFrom(FlatfileDBTable source);
092:
093: /**
094: * Convenience class to create FlatfileDBColumnImpl instance (with the given column
095: * name, data source name, JDBC type, scale, precision, and nullable), and add it to
096: * this FlatfileDBTableImpl instance.
097: *
098: * @param columnName Column name
099: * @param jdbcType JDBC type defined in SQL.Types
100: * @param scale Scale
101: * @param precision Precision
102: * @param isPK true if part of primary key, false otherwise
103: * @param isFK true if part of foreign key, false otherwise
104: * @param isIndexed true if indexed, false otherwise
105: * @param nullable Nullable
106: * @return new FlatfileDBColumnImpl instance
107: */
108: FlatfileDBColumn createColumn(String columnName, int jdbcType,
109: int scale, int precision, boolean isPK, boolean isFK,
110: boolean isIndexed, boolean nullable);
111:
112: /**
113: * Overrides default implementation to return value based on memberwise comparison.
114: *
115: * @param obj Object against which we compare this instance
116: * @return true if obj is functionally identical to this ETLTable instance; false
117: * otherwise
118: */
119: @Override
120: boolean equals(Object obj);
121:
122: /**
123: * Gets the Create Statement SQL for creating table for a flat file
124: *
125: * @return SQL for this Flatfile with getTableName()
126: */
127: String getCreateStatementSQL();
128:
129: /**
130: * Gets the SQL create statement to create a text table representing this flatfile.
131: *
132: * @return SQL statement to create a text table representing the contents of this
133: * flatfile
134: */
135: String getCreateStatementSQL(String directory, String theTableName,
136: String runtimeName, boolean isDynamicFilePath,
137: boolean createDataFileIfNotExist);
138:
139: String getDropStatementSQL();
140:
141: /**
142: * Gets the encoding scheme.
143: *
144: * @return encoding scheme
145: */
146: String getEncodingScheme();
147:
148: String getFlatfilePropertiesSQL();
149:
150: String getFileName();
151:
152: /**
153: * Gets local path to sample file.
154: *
155: * @return path (in local workstation file system) to file, excluding the filename.
156: */
157: String getLocalFilePath();
158:
159: String getParserType();
160:
161: Map getProperties();
162:
163: /**
164: * Gets property string associated with the given name.
165: *
166: * @param key property key
167: * @return property associated with propName, or null if no such property exists.
168: */
169: String getProperty(String key);
170:
171: String getSelectStatementSQL(int rows);
172:
173: /**
174: * Gets the table name.
175: *
176: * @return Table name
177: */
178: String getTableName();
179:
180: /**
181: * Overrides default implementation to compute hashCode value for those members used
182: * in equals() for comparison.
183: *
184: * @return hash code for this object
185: * @see java.lang.Object#hashCode
186: */
187: @Override
188: int hashCode();
189:
190: /**
191: * Sets description text for this instance.
192: *
193: * @param newDesc new descriptive text
194: */
195: void setDescription(String newDesc);
196:
197: /**
198: * Sets the encoding scheme.
199: *
200: * @param newEncoding encoding scheme
201: */
202: void setEncodingScheme(String newEncoding);
203:
204: /**
205: * Sets the file name.
206: *
207: * @param newName new file name
208: */
209: void setFileName(String newName);
210:
211: /**
212: * Sets local path to sample file.
213: *
214: * @param localFile File representing path to sample file. If localFile represents the
215: * file itself, only the directory path will be stored.
216: */
217: void setLocalFilePath(File localFile);
218:
219: void setParseType(String type);
220:
221: void setProperties(Map newProps);
222:
223: boolean setProperty(String key, Object value);
224:
225: /**
226: * Overrides default implementation to return fully-qualified name of this DBTable
227: * (including name of parent DatabaseModel).
228: *
229: * @return table name.
230: */
231: @Override
232: String toString();
233:
234: void updateProperties(Map newProps);
235: }
|