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:
042: package org.netbeans.modules.sql.framework.model;
043:
044: import java.util.Collection;
045: import org.w3c.dom.Element;
046: import com.sun.sql.framework.exception.BaseException;
047:
048: /**
049: * @author Ritesh Adval
050: */
051: public interface SQLContainerObject {
052:
053: /**
054: * Adds given SQLObject instance to this SQLDefinition.
055: *
056: * @param newObject new instance to add
057: * @throws BaseException if add fails or instance implements an unrecognized object
058: * type.
059: */
060: public void addObject(SQLObject newObject) throws BaseException;
061:
062: /**
063: * Adds SQLObject to list of object references to be resolved in a second pass.
064: *
065: * @param sqlObj to be added
066: * @param element DOM Element of SQLObject to be resolved later
067: */
068: public void addSecondPassSQLObject(SQLObject sqlObj, Element element);
069:
070: /**
071: * all sql objects are cloneable
072: * @return cloned sql object
073: * @throws java.lang.CloneNotSupportedException
074: */
075: public Object cloneSQLObject() throws CloneNotSupportedException;
076:
077: /**
078: * Creates a new SQLObject instance of the given type with the given display name -
079: * does not associated the vended SQLObject with this instance. To associate the
080: * returned SQLObject instance with this instance, the calling method should call
081: * addSQLObject(SQLObject) which will ensure the parent-child relationship is
082: * preserved.
083: *
084: * @param objTag objTag of object to create
085: * @return new SQLObject instance
086: * @throws BaseException if error occurs during creation
087: * @see #addObject(SQLObject)
088: */
089: public SQLObject createObject(String objTag) throws BaseException;
090:
091: /**
092: * Creates a new SQLObject instance of the given type with the given display name -
093: * does not associated the vended SQLObject with this instance. To associate the
094: * returned SQLObject instance with this instance, the calling method should call
095: * addSQLObject(SQLObject) which will ensure the parent-child relationship is
096: * preserved.
097: *
098: * @param className className of object to create
099: * @return new SQLObject instance
100: * @throws BaseException if error occurs during creation
101: * @see #addObject(SQLObject)
102: */
103: public SQLObject createSQLObject(String className)
104: throws BaseException;
105:
106: /**
107: * Gets the Collection of active SQLObjects.
108: *
109: * @return Collection of current SQLObjects in this SQLDefinition instance.
110: */
111: public Collection<SQLObject> getAllObjects();
112:
113: /**
114: * Gets associated SQLObject instance, if any, with the given object ID.
115: *
116: * @param objectId ID of SQLObject instance to be retrieved
117: * @param type type of object to retrieve
118: * @return associated SQLObject instance, or null if no such instance exists
119: */
120: public SQLObject getObject(String objectId, int type);
121:
122: /**
123: * Gets a Collection of SQLObjects, if any, with the given type
124: *
125: * @param type SQLObject type to retrieve
126: * @return Collection (possibly empty) of SQLObjects with the given type
127: */
128: public Collection getObjectsOfType(int type);
129:
130: /**
131: * Gets parent object, if any, that owns this SQLDefinition instance.
132: *
133: * @return parent object
134: */
135: public Object getParent();
136:
137: /**
138: * Parses the XML content, if any, using the given Element as a source for
139: * reconstituting the member variables and collections of this instance.
140: *
141: * @param xmlElement DOM element containing XML marshalled version of a SQLDefinition
142: * instance
143: * @throws BaseException thrown while parsing XML, or if xmlElement is null
144: */
145: public void parseXML(Element xmlElement) throws BaseException;
146:
147: /**
148: * Remove all objects from this container
149: */
150: public void removeAllObjects();
151:
152: /**
153: * Removes the given object from SQLDefinition
154: *
155: * @param sqlObj to be removed
156: * @throws BaseException while removing
157: */
158: public void removeObject(SQLObject sqlObj) throws BaseException;
159:
160: /**
161: * Removes SQLObjects passed.
162: *
163: * @param sqlObjs Collection of SQLObjects to be removed
164: * @throws BaseException while removing
165: */
166: public void removeObjects(Collection sqlObjs) throws BaseException;
167:
168: /**
169: * Sets parent object, if any, that owns this SQLDefinition instance.
170: *
171: * @param newParent new parent object
172: */
173: public void setParent(Object newParent);
174:
175: /**
176: * Returns the XML representation of collabSegment.
177: *
178: * @param prefix the xml.
179: * @return Returns the XML representation of colabSegment.
180: * @throws com.sun.sql.framework.exception.BaseException
181: */
182: public String toXMLString(String prefix) throws BaseException;
183: }
|