Source Code Cross Referenced for SQLNationalVarchar.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.SQLNationalVarchar
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:        import org.apache.derby.iapi.util.StringUtil;
036:
037:        import org.apache.derby.iapi.services.i18n.LocaleFinder;
038:
039:        import java.sql.Date;
040:        import java.sql.Time;
041:        import java.sql.Timestamp;
042:
043:        import java.util.Calendar;
044:
045:        /**
046:         * SQLNationalVarchar satisfies the DataValueDescriptor
047:         * interfaces (i.e., OrderableDataType). It implements a String holder, 
048:         * e.g. for storing a column value; it can be specified
049:         * when constructed to not allow nulls. Nullability cannot be changed
050:         * after construction.
051:         * <p>
052:         * Because OrderableDataType is a subclass of DataType,
053:         * SQLNationalVarchar can play a role in either a DataType/ValueRow
054:         * or a OrderableDataType/KeyRow, interchangeably.
055:         *
056:         * SQLNationalVarchar is mostly the same as SQLVarchar, so it is implemented as a
057:         * subclass of SQLVarchar.  Only those methods with different behavior are
058:         * implemented here.
059:         */
060:        public class SQLNationalVarchar extends SQLVarchar {
061:
062:            public String getTypeName() {
063:                return TypeId.NATIONAL_VARCHAR_NAME;
064:            }
065:
066:            /** 
067:             * Compare two SQLChars.  This method will be overriden in the
068:             * National char wrappers so that the appropriate comparison
069:             * is done.
070:             *
071:             * @exception StandardException		Thrown on error
072:             */
073:            protected int stringCompare(SQLChar char1, SQLChar char2)
074:                    throws StandardException {
075:                return char1.stringCollatorCompare(char2);
076:            }
077:
078:            /*
079:             * DataValueDescriptor interface
080:             */
081:
082:            /** @see DataValueDescriptor#getClone */
083:            public DataValueDescriptor getClone() {
084:                try {
085:                    /* NOTE: We pass instance variables for locale info 
086:                     * because we only call methods when we know that we
087:                     * will need locale info.
088:                     */
089:                    return new SQLNationalVarchar(getString(),
090:                            getLocaleFinder());
091:                } catch (StandardException se) {
092:                    if (SanityManager.DEBUG)
093:                        SanityManager.THROWASSERT("Unexpected exception " + se);
094:                    return null;
095:                }
096:            }
097:
098:            /**
099:             * @see DataValueDescriptor#getNewNull
100:             *
101:             */
102:            public DataValueDescriptor getNewNull() {
103:                /* NOTE: We pass instance variables for locale info 
104:                 * because we only call methods when we know that we
105:                 * will need locale info.
106:                 */
107:                SQLNationalVarchar result = new SQLNationalVarchar();
108:                result.setLocaleFinder(getLocaleFinder());
109:                return result;
110:            }
111:
112:            /*
113:             * Storable interface, implies Externalizable, TypedFormat
114:             */
115:
116:            /**
117:            	Return my format identifier.
118:
119:            	@see org.apache.derby.iapi.services.io.TypedFormat#getTypeFormatId
120:             */
121:            public int getTypeFormatId() {
122:                return StoredFormatIds.SQL_NATIONAL_VARCHAR_ID;
123:            }
124:
125:            /*
126:             * constructors
127:             */
128:
129:            public SQLNationalVarchar() {
130:            }
131:
132:            public SQLNationalVarchar(String val, LocaleFinder localeFinder) {
133:                super (val);
134:                setLocaleFinder(localeFinder);
135:            }
136:
137:            /**
138:             * @see DataValueDescriptor#getDate
139:             * @exception StandardException thrown on failure to convert
140:             */
141:            public Date getDate(Calendar cal) throws StandardException {
142:                return nationalGetDate(cal);
143:            }
144:
145:            /**
146:             * @see DataValueDescriptor#getTime
147:             * @exception StandardException thrown on failure to convert
148:             */
149:            public Time getTime(Calendar cal) throws StandardException {
150:                return nationalGetTime(cal);
151:            }
152:
153:            /**
154:             * @see DataValueDescriptor#getTimestamp
155:             * @exception StandardException thrown on failure to convert
156:             */
157:            public Timestamp getTimestamp(Calendar cal)
158:                    throws StandardException {
159:                return nationalGetTimestamp(cal);
160:            }
161:
162:            /*
163:             * DataValueDescriptor interface
164:             */
165:
166:            /* @see DataValueDescriptor#typePrecedence */
167:            public int typePrecedence() {
168:                return TypeId.NATIONAL_VARCHAR_PRECEDENCE;
169:            }
170:
171:            /**
172:             * Get a SQLVarchar for a built-in string function.  
173:             * (Could be either a SQLVarchar or SQLNationalVarchar.)
174:             *
175:             * @return a SQLVarchar or SQLNationalVarchar.
176:             */
177:            protected StringDataValue getNewVarchar() {
178:                return new SQLNationalVarchar();
179:            }
180:
181:            /** 
182:             * Return whether or not this is a national character datatype.
183:             */
184:            protected boolean isNationalString() {
185:                return true;
186:            }
187:
188:            /**
189:             * @see DataValueDescriptor#setValue
190:             *
191:             * @exception StandardException		Thrown on error
192:             */
193:            public void setValue(Date theValue, Calendar cal)
194:                    throws StandardException {
195:                setValue(getDateFormat(cal).format(theValue));
196:            }
197:
198:            /**
199:             *  @see DataValueDescriptor#setValue
200:             *
201:             * @exception StandardException		Thrown on error
202:             */
203:            public void setValue(Time theValue, Calendar cal)
204:                    throws StandardException {
205:                setValue(getTimeFormat(cal).format(theValue));
206:            }
207:
208:            /**
209:             *  @see DataValueDescriptor#setValue
210:             *
211:             * @exception StandardException		Thrown on error
212:             */
213:            public void setValue(Timestamp theValue, Calendar cal)
214:                    throws StandardException {
215:                setValue(getTimestampFormat(cal).format(theValue));
216:            }
217:
218:            public void normalize(DataTypeDescriptor desiredType,
219:                    DataValueDescriptor source) throws StandardException {
220:                normalize(desiredType, ((DataType) source)
221:                        .getNationalString(getLocaleFinder()));
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:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.