Source Code Cross Referenced for SQLWhenImpl.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.SQLCondition;
045:        import org.netbeans.modules.sql.framework.model.SQLConstants;
046:        import org.netbeans.modules.sql.framework.model.SQLInputObject;
047:        import org.netbeans.modules.sql.framework.model.SQLModelObjectFactory;
048:        import org.netbeans.modules.sql.framework.model.SQLObject;
049:        import org.netbeans.modules.sql.framework.model.SQLPredicate;
050:        import org.netbeans.modules.sql.framework.model.SQLWhen;
051:        import org.netbeans.modules.sql.framework.model.visitors.SQLVisitor;
052:        import org.w3c.dom.Element;
053:        import org.w3c.dom.NodeList;
054:
055:        import com.sun.sql.framework.exception.BaseException;
056:
057:        /**
058:         * This class is part of When. An addendum to SQLCase and always used with SQLCase
059:         * 
060:         * @author Sudhendra Seshachala
061:         * @version $Revision$
062:         */
063:        public class SQLWhenImpl extends SQLConnectableObjectImpl implements 
064:                SQLWhen {
065:
066:            /** Key constant: condition input */
067:            public static final String CONDITION = "condition";
068:
069:            /** Key constant: return output */
070:            public static final String RETURN = "return";
071:
072:            private SQLPredicate oldPredicate;
073:
074:            private SQLCondition whenCondition;
075:
076:            /** Creates a new default instance of SQLWhenImpl. */
077:            public SQLWhenImpl() {
078:                super ();
079:
080:                type = SQLConstants.WHEN;
081:                whenCondition = SQLModelObjectFactory.getInstance()
082:                        .createSQLCondition(WHEN_CONDITION);
083:                whenCondition.setParent(this );
084:                whenCondition.setConditionText("");
085:
086:                SQLInputObject inputObject = new SQLInputObjectImpl(RETURN,
087:                        RETURN, null);
088:                this .inputMap.put(RETURN, inputObject);
089:            }
090:
091:            /**
092:             * Creates a new instance of SQLWhen with the given display name
093:             * 
094:             * @param newDisplayName display name for the new instance
095:             */
096:            public SQLWhenImpl(String newDisplayName) {
097:                this ();
098:                setDisplayName(newDisplayName);
099:            }
100:
101:            /**
102:             * @see org.netbeans.modules.sql.framework.model.SQLConnectableObject#addInput
103:             */
104:            public void addInput(String argName, SQLObject newInput)
105:                    throws BaseException {
106:                if (CONDITION.equals(argName)) {
107:                    oldPredicate = (SQLPredicate) newInput;
108:                } else {
109:                    super .addInput(argName, newInput);
110:                }
111:            }
112:
113:            /**
114:             * @see org.netbeans.modules.sql.framework.model.SQLWhen#getCondition()
115:             */
116:            public SQLCondition getCondition() {
117:                return whenCondition;
118:            }
119:
120:            /*
121:             * (non-Javadoc)
122:             * 
123:             * @see org.netbeans.modules.sql.framework.model.SQLConnectableObject#getInput(java.lang.String)
124:             */
125:            public SQLInputObject getInput(String argName) {
126:                if (CONDITION.equals(argName)) {
127:                    return new SQLInputObjectImpl(CONDITION, CONDITION,
128:                            oldPredicate);
129:                } else {
130:                    return super .getInput(argName);
131:                }
132:            }
133:
134:            /**
135:             * Overrides default implementation to return JDBC type of the associated return
136:             * input, if any.
137:             * 
138:             * @return JDBC type of return input, or default value if no return input is currently
139:             *         linked.
140:             * @see org.netbeans.modules.sql.framework.model.impl.AbstractSQLObject#getJdbcType
141:             */
142:            public int getJdbcType() {
143:                SQLObject value = this .getSQLObject(RETURN);
144:
145:                // Return either the associated return object's type, or the default
146:                // type as defined in AbstractSQLObject.
147:                return (value != null) ? value.getJdbcType() : super 
148:                        .getJdbcType();
149:            }
150:
151:            /**
152:             * @see org.netbeans.modules.sql.framework.model.SQLConnectableObject#isInputValid
153:             */
154:            public boolean isInputValid(String argName, SQLObject input) {
155:                if (input == null || argName == null) {
156:                    return false;
157:                }
158:
159:                switch (input.getObjectType()) {
160:                case SQLConstants.GENERIC_OPERATOR:
161:                case SQLConstants.CUSTOM_OPERATOR:
162:                case SQLConstants.CAST_OPERATOR:
163:                case SQLConstants.DATE_DIFF_OPERATOR:
164:                case SQLConstants.DATE_ADD_OPERATOR:
165:                case SQLConstants.LITERAL:
166:                case SQLConstants.VISIBLE_LITERAL:
167:                case SQLConstants.CASE:
168:                case SQLConstants.SOURCE_COLUMN:
169:                    return RETURN.equals(argName.trim());
170:
171:                default:
172:                    return false;
173:                }
174:            }
175:
176:            /**
177:             * Populates the member variables and collections of this SQLWhen instance, parsing
178:             * the given DOM Element as the source for reconstituting its contents.
179:             * 
180:             * @param xmlElement DOM element containing XML marshaled version of this SQLWhen
181:             *        instance
182:             * @throws BaseException if element is null or error occurs during parsing
183:             */
184:            public void parseXML(Element xmlElement) throws BaseException {
185:                super .parseXML(xmlElement);
186:                this .objectType = xmlElement
187:                        .getAttribute(SQLObject.OBJECT_TYPE);
188:
189:                NodeList conditionNodeList = xmlElement
190:                        .getElementsByTagName(SQLCondition.TAG_CONDITION);
191:                if (conditionNodeList != null
192:                        && conditionNodeList.getLength() != 0) {
193:                    Element elem = (Element) conditionNodeList.item(0);
194:                    whenCondition = SQLModelObjectFactory.getInstance()
195:                            .createSQLCondition(WHEN_CONDITION);
196:                    whenCondition.setParent(this );
197:                    whenCondition.parseXML(elem);
198:                }
199:
200:                NodeList list = xmlElement.getChildNodes();
201:                if (list != null && list.getLength() != 0) {
202:                    TagParserUtility.parseInputChildNodes(this , list);
203:                }
204:            }
205:
206:            /**
207:             * Resolves object reference contained in given DOM element; called in second pass of
208:             * SQLDefinition parsing process.
209:             * 
210:             * @param element to be parsed
211:             * @exception BaseException thrown while parsing
212:             */
213:            public void secondPassParse(Element element) throws BaseException {
214:                TagParserUtility.parseInputTag(this , element);
215:            }
216:
217:            /*
218:             * (non-Javadoc)
219:             * 
220:             * @see org.netbeans.modules.sql.framework.model.SQLWhen#setCondition(org.netbeans.modules.sql.framework.model.SQLCondition)
221:             */
222:            public void setCondition(SQLCondition cond) {
223:                whenCondition = cond;
224:            }
225:
226:            /**
227:             * Overrides parent implementation to append when condition information.
228:             * 
229:             * @param prefix String to append to each new line of the XML representation
230:             * @return XML representation of this SQLObject instance
231:             * @throws BaseException if error occurs during XML creation
232:             */
233:            public String toXMLString(String prefix) throws BaseException {
234:                StringBuilder buffer = new StringBuilder();
235:                if (prefix == null) {
236:                    prefix = "";
237:                }
238:
239:                buffer.append(prefix).append(getHeader());
240:                buffer.append(toXMLAttributeTags(prefix));
241:
242:                if (whenCondition != null) {
243:                    buffer.append(whenCondition.toXMLString(prefix + "\t"));
244:                }
245:
246:                buffer.append(TagParserUtility.toXMLInputTag(prefix + "\t",
247:                        inputMap));
248:                buffer.append(prefix).append(getFooter());
249:
250:                return buffer.toString();
251:            }
252:
253:            public void visit(SQLVisitor visitor) {
254:                visitor.visit(this);
255:            }
256:        }
w__ww_.__j___a__va2__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.