Source Code Cross Referenced for SQLNationalLongvarchar.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » types » 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 » Database DBMS » db derby 10.2 » org.apache.derby.iapi.types 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.iapi.types.SQLNationalLongvarchar
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.iapi.types;
023:
024:        import org.apache.derby.iapi.types.DataTypeDescriptor;
025:        import org.apache.derby.iapi.types.DataValueDescriptor;
026:        import org.apache.derby.iapi.types.TypeId;
027:        import org.apache.derby.iapi.types.StringDataValue;
028:        import org.apache.derby.iapi.reference.SQLState;
029:        import org.apache.derby.iapi.error.StandardException;
030:
031:        import org.apache.derby.iapi.services.io.FormatIdUtil;
032:        import org.apache.derby.iapi.services.io.StoredFormatIds;
033:
034:        import org.apache.derby.iapi.services.sanity.SanityManager;
035:
036:        import org.apache.derby.iapi.services.i18n.LocaleFinder;
037:
038:        import java.util.Locale;
039:        import java.util.Calendar;
040:
041:        import java.sql.Date;
042:        import java.sql.Time;
043:        import java.sql.Timestamp;
044:
045:        /**
046:         * SQLNationalLongvarchar satisfies the DataValueDescriptor interfaces (i.e., OrderableDataType). It implements a String
047:         * holder, e.g. for storing a column value; it can be specified
048:         * when constructed to not allow nulls. Nullability cannot be changed
049:         * after construction.
050:         * <p>
051:         * Because OrderableDataType is a subclass of DataType,
052:         * SQLNationalLongvarchar can play a role in either a DataType/ValueRow
053:         * or a OrderableDataType/KeyRow, interchangeably.
054:         *
055:         * SQLNationalLongvarchar is mostly the same as SQLLongvarchar, so it is implemented as a
056:         * subclass of SQLLongvarchar.  Only those methods with different behavior are
057:         * implemented here.
058:         */
059:        public class SQLNationalLongvarchar extends SQLLongvarchar {
060:            /*
061:             * DataValueDescriptor interface.
062:             *
063:             * These are actually all implemented in the super-class, but we need
064:             * to duplicate some of them here so they can be called by byte-code
065:             * generation, which needs to know the class the method appears in.
066:             */
067:
068:            public String getTypeName() {
069:                return TypeId.NATIONAL_LONGVARCHAR_NAME;
070:            }
071:
072:            /*
073:             * DataValueDescriptor interface
074:             */
075:
076:            /** @see DataValueDescriptor#getClone */
077:            public DataValueDescriptor getClone() {
078:                try {
079:                    /* NOTE: We pass instance variables for locale info 
080:                     * because we only call methods when we know that we
081:                     * will need locale info.
082:                     */
083:                    return new SQLNationalLongvarchar(getString(),
084:                            getLocaleFinder());
085:                } catch (StandardException se) {
086:                    if (SanityManager.DEBUG)
087:                        SanityManager.THROWASSERT("Unexpected exception " + se);
088:                    return null;
089:                }
090:            }
091:
092:            /**
093:             * @see DataValueDescriptor#getNewNull
094:             *
095:             */
096:            public DataValueDescriptor getNewNull() {
097:                /* NOTE: We pass instance variables for locale info 
098:                 * because we only call methods when we know that we
099:                 * will need locale info.
100:                 */
101:                SQLNationalLongvarchar result = new SQLNationalLongvarchar();
102:                result.setLocaleFinder(getLocaleFinder());
103:                return result;
104:            }
105:
106:            /*
107:             * Storable interface, implies Externalizable, TypedFormat
108:             */
109:
110:            /**
111:            	Return my format identifier.
112:
113:            	@see org.apache.derby.iapi.services.io.TypedFormat#getTypeFormatId
114:             */
115:            public int getTypeFormatId() {
116:                return StoredFormatIds.SQL_NATIONAL_LONGVARCHAR_ID;
117:            }
118:
119:            /*
120:             * constructors
121:             */
122:
123:            public SQLNationalLongvarchar() {
124:            }
125:
126:            public SQLNationalLongvarchar(String val, LocaleFinder localeFinder) {
127:                super (val);
128:                setLocaleFinder(localeFinder);
129:            }
130:
131:            /**
132:             * @see DataValueDescriptor#getDate
133:             * @exception StandardException thrown on failure to convert
134:             */
135:            public Date getDate(Calendar cal) throws StandardException {
136:                return nationalGetDate(cal);
137:            }
138:
139:            /**
140:             * @see DataValueDescriptor#getTime
141:             * @exception StandardException thrown on failure to convert
142:             */
143:            public Time getTime(Calendar cal) throws StandardException {
144:                return nationalGetTime(cal);
145:            }
146:
147:            /**
148:             * @see DataValueDescriptor#getTimestamp
149:             * @exception StandardException thrown on failure to convert
150:             */
151:            public Timestamp getTimestamp(Calendar cal)
152:                    throws StandardException {
153:                return nationalGetTimestamp(cal);
154:            }
155:
156:            /*
157:             * DataValueDescriptor interface
158:             */
159:
160:            /* @see DataValueDescriptor#typePrecedence */
161:            public int typePrecedence() {
162:                return TypeId.NATIONAL_LONGVARCHAR_PRECEDENCE;
163:            }
164:
165:            /** 
166:             * Compare two SQLChars.  This method will be overriden in the
167:             * National char wrappers so that the appropriate comparison
168:             * is done.
169:             *
170:             * @exception StandardException		Thrown on error
171:             */
172:            protected int stringCompare(SQLChar char1, SQLChar char2)
173:                    throws StandardException {
174:                return char1.stringCollatorCompare(char2);
175:            }
176:
177:            /**
178:             * Get a SQLVarchar for a built-in string function.  
179:             * (Could be either a SQLVarchar or SQLNationalVarchar.)
180:             *
181:             * @return a SQLVarchar or SQLNationalVarchar.
182:             */
183:            protected StringDataValue getNewVarchar() {
184:                return new SQLNationalVarchar();
185:            }
186:
187:            /** 
188:             * Return whether or not this is a national character datatype.
189:             */
190:            protected boolean isNationalString() {
191:                return true;
192:            }
193:
194:            /**
195:             * @see DataValueDescriptor#setValue
196:             *
197:             * @exception StandardException		Thrown on error
198:             */
199:            public void setValue(Date theValue, Calendar cal)
200:                    throws StandardException {
201:                setValue(getDateFormat(cal).format(theValue));
202:            }
203:
204:            /**
205:             *  @see DataValueDescriptor#setValue
206:             *
207:             * @exception StandardException		Thrown on error
208:             */
209:            public void setValue(Time theValue, Calendar cal)
210:                    throws StandardException {
211:                setValue(getTimeFormat(cal).format(theValue));
212:            }
213:
214:            /**
215:             *  @see DataValueDescriptor#setValue
216:             *
217:             * @exception StandardException		Thrown on error
218:             */
219:            public void setValue(Timestamp theValue, Calendar cal)
220:                    throws StandardException {
221:                setValue(getTimestampFormat(cal).format(theValue));
222:            }
223:
224:            protected void setFrom(DataValueDescriptor theValue)
225:                    throws StandardException {
226:
227:                setValue(((DataType) theValue)
228:                        .getNationalString(getLocaleFinder()));
229:            }
230:
231:            /** @see java.lang.Object#hashCode */
232:            public int hashCode() {
233:                return nationalHashCode();
234:            }
235:
236:            public void normalize(DataTypeDescriptor desiredType,
237:                    DataValueDescriptor source) throws StandardException {
238:                normalize(desiredType, ((DataType) source)
239:                        .getNationalString(getLocaleFinder()));
240:            }
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.