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.sql.framework.model;
042:
043: import java.util.Collection;
044: import java.util.List;
045:
046: import org.w3c.dom.Element;
047:
048: import com.sun.sql.framework.exception.BaseException;
049: import com.sun.sql.framework.utils.Attribute;
050:
051: /**
052: * Root interface for all objects in the UI Object Model. Classes which implement this
053: * interface are considered to be valid inputs to any instance of a class implementing
054: * SQLConnectableObject.
055: *
056: * @author Jonathan Giron
057: * @version $Revision$
058: * @see org.netbeans.modules.sql.framework.model.SQLConnectableObject
059: */
060: public interface SQLObject extends Cloneable {
061:
062: /** XML attribute name for argument name */
063: public static final String ATTR_ARGNAME = "argName";
064:
065: // xml tag constants
066: /** XML attribute name for display name */
067: public static final String DISPLAY_NAME = "displayName";
068:
069: /** XML attribute name for ID */
070: public static final String ID = "id";
071:
072: /** XML attribute name for object type */
073: public static final String OBJECT_TYPE = "objectType";
074:
075: /** XML tag name for input */
076: public static final String TAG_INPUT = "input";
077:
078: /** XML tag name for SQLObject (root element) */
079: public static final String TAG_SQLOBJECT = "sql-object";
080:
081: /** XML attribute name for type */
082: public static final String TYPE = "type";
083:
084: /**
085: * all sql objects are cloneable
086: */
087: public Object cloneSQLObject() throws CloneNotSupportedException;
088:
089: /**
090: * Gets an Attribute based on its name
091: *
092: * @param attrName attribute Name
093: * @return Attribute instance associated with attrName, or null if none exists
094: */
095: public Attribute getAttribute(String attrName);
096:
097: /**
098: * Gets Collection of active attribute names.
099: *
100: * @return Collection of attribute names
101: */
102: public Collection getAttributeNames();
103:
104: /**
105: * Gets the object referenced by a named Attribute, if it exists.
106: *
107: * @param attrName attribute Name
108: * @return Object referenced by Attributed with name attrName, or null if none exists
109: */
110: public Object getAttributeObject(String attrName);
111:
112: /**
113: * Gets List of child SQLObjects belonging to this instance.
114: *
115: * @return List of child SQLObjects
116: */
117: public List getChildSQLObjects();
118:
119: /**
120: * Gets display name of this SQLObject instance.
121: *
122: * @return display name
123: */
124: public String getDisplayName();
125:
126: /**
127: * Gets the XML footer string for this instance; called by subclasses while generating
128: * XML output.
129: *
130: * @return String footer
131: */
132: public String getFooter();
133:
134: /**
135: * Gets the XML header string for this instance; called by subclasses while generating
136: * XML output.
137: *
138: * @return String header
139: */
140: public String getHeader();
141:
142: /**
143: * Gets unique ID for this instance of SQLObject.
144: *
145: * @return String representing unique instance ID
146: */
147: public String getId();
148:
149: /**
150: * Gets JDBC type of output, if any.
151: *
152: * @return JDBC type of output, or SQLConstants.JDBCSQL_TYPE_UNDEFINED if output is
153: * undefined for this instance
154: */
155: public int getJdbcType();
156:
157: /**
158: * Gets specific type of SQLObject (as an enumerated int value) that this instance
159: * represents.
160: *
161: * @return int value representing specific object type
162: */
163: public int getObjectType();
164:
165: /**
166: * Gets reference to SQLObject corresponding to given argument name that can be linked
167: * to an SQLConnectableObject.
168: *
169: * @param argName argument name of linkable SQLObject
170: * @return linkable SQLObject corresponding to argName
171: * @throws BaseException if object cannot be linked to an SQLConnectableObject
172: */
173: public SQLObject getOutput(String argName) throws BaseException;
174:
175: /**
176: * Gets parent object for this SQLObject instance.
177: *
178: * @return reference to parent object
179: */
180: public Object getParentObject();
181:
182: /**
183: * Populates the member variables and collections of this SQLObject instance, parsing
184: * the given DOM Element as the source for reconstituting its contents.
185: *
186: * @param element DOM element containing XML marshalled version of this SQLObject
187: * instance
188: * @throws BaseException if element is null or error occurs during parsing
189: */
190: public void parseXML(Element element) throws BaseException;
191:
192: /**
193: * Clear id and parent object
194: */
195: public void reset();
196:
197: /**
198: * Parses elements which require a second round of parsing to resolve their
199: * references.
200: *
201: * @param element DOM element containing XML marshalled version of this SQLObject
202: * instance
203: * @throws BaseException if element is null or error occurs during parsing
204: */
205: public void secondPassParse(Element element) throws BaseException;
206:
207: /**
208: * Sets an attribute name-value pair. The name of the Attribute should be one of the
209: * String constants defined in this class.
210: *
211: * @param attrName attribute Name
212: * @param val value of the attribute
213: */
214: public void setAttribute(String attrName, Object val);
215:
216: /**
217: * Sets display name of this SQLObject instance.
218: *
219: * @param newName new display name
220: */
221: public void setDisplayName(String newName);
222:
223: /**
224: * Sets ID for this instance of SQLObject; must be unique in any collection of
225: * SQLObjects within which this instance is a part.
226: *
227: * @param newId new instance ID for this SQLObject; must be a unique value
228: * @throws BaseException if newID is null or invalid, or if error occurs while setting
229: * ID value
230: */
231: public void setId(String newId) throws BaseException;
232:
233: /**
234: * Sets JDBC type of output, if any.
235: *
236: * @param newType new JDBC type of output; ignored if output is undefined for this
237: * instance
238: */
239: public void setJdbcType(int newType);
240:
241: /**
242: * Sets parent object for this SQLObject instance.
243: *
244: * @param newParent reference to new pagetObjectTyperent object.
245: * @throws BaseException if newParent reference is null or error occurs while setting
246: * parent reference
247: */
248: public void setParentObject(Object newParent) throws BaseException;
249:
250: /**
251: * Gets XML representation of this SQLObject, appending the given String to the
252: * beginning of each new line.
253: *
254: * @param prefix String to append to each new line of the XML representation
255: * @return XML representation of this SQLObject instance
256: */
257:
258: public String toXMLString(String prefix) throws BaseException;
259:
260: }
|