Source Code Cross Referenced for ColumnRefImpl.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » sql » framework » model » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » etl.project » org.netbeans.modules.sql.framework.model.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.impl;
042:
043:        import org.netbeans.modules.sql.framework.common.utils.TagParserUtility;
044:        import org.netbeans.modules.sql.framework.model.ColumnRef;
045:        import org.netbeans.modules.sql.framework.model.GUIInfo;
046:        import org.netbeans.modules.sql.framework.model.SQLCondition;
047:        import org.netbeans.modules.sql.framework.model.SQLConstants;
048:        import org.netbeans.modules.sql.framework.model.SQLDBColumn;
049:        import org.netbeans.modules.sql.framework.model.SQLDefinition;
050:        import org.netbeans.modules.sql.framework.model.SQLObject;
051:        import org.netbeans.modules.sql.framework.model.utils.GeneratorUtil;
052:        import org.w3c.dom.Element;
053:        import org.w3c.dom.Node;
054:        import org.w3c.dom.NodeList;
055:
056:        import com.sun.sql.framework.exception.BaseException;
057:
058:        /**
059:         * @author Ritesh Adval
060:         */
061:        public class ColumnRefImpl extends AbstractSQLObject implements 
062:                ColumnRef {
063:
064:            /** Constant for column metadata name tag. */
065:            static final String ELEMENT_TAG = "dbColumnRef"; // NOI18N
066:
067:            /** String to use in prefixing each line of a generated XML document */
068:            protected static final String INDENT = "\t";
069:
070:            private SQLDBColumn columnRef;
071:
072:            /** Contains UI state information */
073:            private GUIInfo guiInfo = new GUIInfo();
074:
075:            /** Creates a new instance of ColumnRefImpl */
076:            public ColumnRefImpl() {
077:                guiInfo = new GUIInfo();
078:                init();
079:            }
080:
081:            /**
082:             * New instance
083:             * 
084:             * @param src - source
085:             */
086:            public ColumnRefImpl(ColumnRef src) {
087:                this ();
088:                if (src == null) {
089:                    throw new IllegalArgumentException(
090:                            "can not create ColumnRefImpl using copy constructor, src is null");
091:                }
092:
093:                copyFrom(src);
094:            }
095:
096:            /**
097:             * New instance
098:             * 
099:             * @param aColumnRef SQLDBColumn to be referenced by this instance
100:             */
101:            public ColumnRefImpl(SQLDBColumn aColumnRef) {
102:                this ();
103:                this .columnRef = aColumnRef;
104:            }
105:
106:            /**
107:             * Clone
108:             * 
109:             * @return cloned object
110:             */
111:            public Object clone() {
112:                return new ColumnRefImpl(this );
113:            }
114:
115:            /**
116:             * all SQL objects are cloneable
117:             * 
118:             * @exception CloneNotSupportedException - exception
119:             * @return cloned object
120:             */
121:            public Object cloneSQLObject() throws CloneNotSupportedException {
122:                return this .clone();
123:            }
124:
125:            /**
126:             * Copies contents of given ConditionColumn instance to this object.
127:             * 
128:             * @param src ConditionColumn from which to copy contents
129:             */
130:            public void copyFrom(ColumnRef src) {
131:                super .copyFromSource(src);
132:
133:                GUIInfo gInfo = src.getGUIInfo();
134:
135:                this .guiInfo = gInfo != null ? (GUIInfo) gInfo.clone() : null;
136:                SQLDBColumn sCol = (SQLDBColumn) src.getColumn();
137:                try {
138:                    this .columnRef = sCol != null ? (SQLDBColumn) sCol
139:                            .cloneSQLObject() : null;
140:                } catch (CloneNotSupportedException e) {
141:                    throw new InternalError(e.toString());
142:                }
143:
144:                this .parentObject = src.getParentObject();
145:            }
146:
147:            /**
148:             * @see org.netbeans.modules.sql.framework.model.impl.AbstractDBColumn#equals(java.lang.Object)
149:             */
150:            public boolean equals(Object refObj) {
151:                if (!(refObj instanceof  ColumnRef)) {
152:                    return false;
153:                }
154:
155:                ColumnRef refMeta = (ColumnRef) refObj;
156:                boolean result = super .equals(refMeta);
157:
158:                result &= (this .getColumn() != null) ? this .getColumn().equals(
159:                        refMeta.getColumn()) : (refMeta.getColumn() == null);
160:
161:                return result;
162:            }
163:
164:            /**
165:             * Get column
166:             * 
167:             * @return SQLObject
168:             */
169:            public SQLObject getColumn() {
170:                return columnRef;
171:            }
172:
173:            /**
174:             * Get display name
175:             * 
176:             * @return display name
177:             */
178:            public String getDisplayName() {
179:                if (columnRef != null) {
180:                    return columnRef.getDisplayName();
181:                }
182:
183:                return "Undefined";
184:            }
185:
186:            /**
187:             * Gets GUI-related attributes for this instance in the form of a GuiInfo instance.
188:             * 
189:             * @return associated GuiInfo instance
190:             * @see GUIInfo
191:             */
192:            public GUIInfo getGUIInfo() {
193:                return guiInfo;
194:            }
195:
196:            /**
197:             * Gets JDBC type of output, if any.
198:             * 
199:             * @return JDBC type of output, or SQLConstants.JDBCSQL_TYPE_UNDEFINED if output is
200:             *         undefined for this instance
201:             */
202:            public int getJdbcType() {
203:                return columnRef.getJdbcType();
204:            }
205:
206:            /**
207:             * Gets reference to SQLObject corresponding to given argument name that can be linked
208:             * to an SQLConnectableObject.
209:             * 
210:             * @param argName argument name of linkable SQLObject
211:             * @return linkable SQLObject corresponding to argName
212:             * @throws BaseException if object cannot be linked to an SQLConnectableObject
213:             */
214:            public SQLObject getOutput(String argName) throws BaseException {
215:                return this ;
216:            }
217:
218:            /**
219:             * @see org.netbeans.modules.sql.framework.model.impl.AbstractDBColumn#hashCode
220:             */
221:            public int hashCode() {
222:                return super .hashCode()
223:                        + ((this .getColumn() != null) ? this .getColumn()
224:                                .hashCode() : 0);
225:            }
226:
227:            /**
228:             * Populates the member variables and collections of this SQLObject instance, parsing
229:             * the given DOM Element as the source for reconstituting its contents.
230:             * 
231:             * @param columnElement DOM element containing XML marshalled version of this
232:             *        SQLObject instance
233:             * @throws BaseException if element is null or error occurs during parsing
234:             */
235:            public void parseXML(Element columnElement) throws BaseException {
236:                super .parseXML(columnElement);
237:
238:                NodeList childNodeList = columnElement.getChildNodes();
239:                if (childNodeList != null && childNodeList.getLength() != 0) {
240:                    for (int i = 0; i < childNodeList.getLength(); i++) {
241:                        if (childNodeList.item(i).getNodeType() == Node.ELEMENT_NODE) {
242:                            Element childElement = (Element) childNodeList
243:                                    .item(i);
244:                            String tagName = childElement.getTagName();
245:
246:                            if (TagParserUtility.TAG_OBJECTREF.equals(tagName)) {
247:                                secondPassParse(childElement);
248:                            } else if (GUIInfo.TAG_GUIINFO.equals(tagName)) {
249:                                this .guiInfo = new GUIInfo(childElement);
250:                            }
251:                        }
252:                    }
253:                }
254:            }
255:
256:            /**
257:             * Parses elements which require a second round of parsing to resolve their
258:             * references.
259:             * 
260:             * @param element DOM element containing XML marshalled version of this SQLObject
261:             *        instance
262:             * @throws BaseException if element is null or error occurs during parsing
263:             */
264:            public void secondPassParse(Element element) throws BaseException {
265:                SQLCondition sqlCond = (SQLCondition) this .getParentObject();
266:                SQLDefinition definition = TagParserUtility
267:                        .getAncestralSQLDefinition((SQLObject) sqlCond
268:                                .getParentObject());
269:
270:                SQLObject obj = TagParserUtility.parseXMLObjectRefTag(
271:                        definition, element);
272:
273:                // If obj is null it may not be parsed yet so do a second parse...
274:                // it registers this TargetColumn instance to be parsed a second time
275:                // to resolve the value reference
276:                if (obj == null) {
277:                    definition.addSecondPassSQLObject(this , element);
278:                } else {
279:                    setColumn(obj);
280:                }
281:            }
282:
283:            /**
284:             * Set column
285:             * 
286:             * @param column - column
287:             */
288:            public void setColumn(SQLObject column) {
289:                this .columnRef = (SQLDBColumn) column;
290:            }
291:
292:            /**
293:             * Set display name
294:             * 
295:             * @param dispName - display name
296:             */
297:            public void setDisplayName(String dispName) {
298:            }
299:
300:            /**
301:             * toString
302:             * 
303:             * @return String
304:             */
305:            public String toString() {
306:                if (columnRef != null) {
307:                    String cName = columnRef.getName();
308:                    try {
309:                        GeneratorUtil eval = GeneratorUtil.getInstance();
310:                        eval.setTableAliasUsed(true);
311:                        cName = eval.getEvaluatedString(this );
312:                        eval.setTableAliasUsed(false);
313:
314:                        return cName;
315:                    } catch (BaseException ignore) {
316:                        // ignore - should we log this?
317:                    }
318:                }
319:                return "Undefined";
320:            }
321:
322:            /**
323:             * Gets XML representation of this SQLObject, appending the given String to the
324:             * beginning of each new line.
325:             * 
326:             * @param prefix String to append to each new line of the XML representation
327:             * @return XML representation of this SQLObject instance
328:             */
329:            public String toXMLString(String prefix) {
330:                StringBuilder buf = new StringBuilder(200);
331:
332:                buf.append(prefix).append(getHeader());
333:                buf.append(toXMLAttributeTags(prefix));
334:
335:                if (this .getColumn() != null) {
336:                    try {
337:                        String refXml = TagParserUtility.toXMLObjectRefTag(this 
338:                                .getColumn(), prefix + "\t");
339:                        buf.append(refXml);
340:                    } catch (BaseException e) {
341:                        // @TODO log this exception
342:                    }
343:
344:                    if (guiInfo != null) {
345:                        buf.append(guiInfo.toXMLString(prefix + INDENT));
346:                    }
347:                }
348:
349:                buf.append(prefix).append(getFooter());
350:                return buf.toString();
351:            }
352:
353:            /*
354:             * Performs sql framework initialization functions for constructors which cannot first
355:             * call this().
356:             */
357:            private void init() {
358:                type = SQLConstants.COLUMN_REF;
359:            }
360:        }
w_w_w__._ja_v___a_2___s.__c__o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.