Source Code Cross Referenced for SelectableRange.java in  » Database-DBMS » mckoi » com » mckoi » database » 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 » mckoi » com.mckoi.database 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * com.mckoi.database.SelectableRange  12 Aug 2001
003:         *
004:         * Mckoi SQL Database ( http://www.mckoi.com/database )
005:         * Copyright (C) 2000, 2001, 2002  Diehl and Associates, Inc.
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * Version 2 as published by the Free Software Foundation.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License Version 2 for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * Version 2 along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         * Change Log:
021:         * 
022:         * 
023:         */package com.mckoi.database;
024:
025:        /**
026:         * An object that represents a range of values to select from a list.  A range
027:         * has a start value, an end value, and whether we should pick inclusive or
028:         * exclusive of the end value.  The start value may be a concrete value from
029:         * the set or it may be a flag that represents the start or end of the list.
030:         * <p>
031:         * For example, to select the first item from a set the range would be;
032:         * <pre>
033:         * RANGE:
034:         *   start = FIRST_VALUE, first
035:         *   end   = LAST_VALUE, first
036:         * </pre>
037:         * To select the last item from a set the range would be;
038:         * <pre>
039:         * RANGE:
040:         *   start = FIRST_VALUE, last
041:         *   end   = LAST_VALUE, last
042:         * </pre>
043:         * To select the range of values between '10' and '15' then range would be;
044:         * <pre>
045:         * RANGE:
046:         *   start = FIRST_VALUE, '10'
047:         *   end   = LAST_VALUE, '15'
048:         * </pre>
049:         * Note that the the start value may not compare less than the end value.  For
050:         * example, start can not be 'last' and end can not be 'first'.
051:         *
052:         * @author Tobias Downer
053:         */
054:
055:        public final class SelectableRange {
056:
057:            // ---------- Statics ----------
058:
059:            /**
060:             * An object that represents the first value in the set.
061:             * <p>
062:             * Note that these objects have no (NULL) type.
063:             */
064:            public static final TObject FIRST_IN_SET = new TObject(
065:                    TType.NULL_TYPE, "[FIRST_IN_SET]");
066:
067:            /**
068:             * An object that represents the last value in the set.
069:             * <p>
070:             * Note that these objects have no (NULL) type.
071:             */
072:            public static final TObject LAST_IN_SET = new TObject(
073:                    TType.NULL_TYPE, "[LAST_IN_SET]");
074:
075:            /**
076:             * Represents the various points in the set on the value to represent the
077:             * set range.
078:             */
079:            public static final byte FIRST_VALUE = 1, LAST_VALUE = 2,
080:                    BEFORE_FIRST_VALUE = 3, AFTER_LAST_VALUE = 4;
081:
082:            // ---------- Members ----------
083:
084:            /**
085:             * The start of the range to select from the set.
086:             */
087:            private TObject start;
088:
089:            /**
090:             * The end of the range to select from the set.
091:             */
092:            private TObject end;
093:
094:            /**
095:             * Denotes the place for the range to start with respect to the start value.
096:             * Either FIRST_VALUE or AFTER_LAST_VALUE.
097:             */
098:            private byte set_start_flag;
099:
100:            /**
101:             * Denotes the place for the range to end with respect to the end value.
102:             * Either BEFORE_FIRST_VALUE or LAST_VALUE.
103:             */
104:            private byte set_end_flag;
105:
106:            /**
107:             * Constructs the range.
108:             */
109:            public SelectableRange(byte set_start_flag, TObject start,
110:                    byte set_end_flag, TObject end) {
111:                this .start = start;
112:                this .end = end;
113:                this .set_start_flag = set_start_flag;
114:                this .set_end_flag = set_end_flag;
115:            }
116:
117:            /**
118:             * Returns the start of the range.
119:             * NOTE: This may return FIRST_IN_SET or LAST_IN_SET.
120:             */
121:            public TObject getStart() {
122:                return start;
123:            }
124:
125:            /**
126:             * Returns the end of the range.
127:             * NOTE: This may return FIRST_IN_SET or LAST_IN_SET.
128:             */
129:            public TObject getEnd() {
130:                return end;
131:            }
132:
133:            /**
134:             * Returns the place for the range to start (either FIRST_VALUE or
135:             * AFTER_LAST_VALUE)
136:             */
137:            public byte getStartFlag() {
138:                return set_start_flag;
139:            }
140:
141:            /**
142:             * Returns the place for the range to end (either BEFORE_FIRST_VALUE or
143:             * LAST VALUE).
144:             */
145:            public byte getEndFlag() {
146:                return set_end_flag;
147:            }
148:
149:            /**
150:             * Outputs this range as a string.
151:             */
152:            public String toString() {
153:                StringBuffer buf = new StringBuffer();
154:                if (getStartFlag() == FIRST_VALUE) {
155:                    buf.append("FIRST_VALUE ");
156:                } else if (getStartFlag() == AFTER_LAST_VALUE) {
157:                    buf.append("AFTER_LAST_VALUE ");
158:                }
159:                buf.append(getStart());
160:                buf.append(" -> ");
161:                if (getEndFlag() == LAST_VALUE) {
162:                    buf.append("LAST_VALUE ");
163:                } else if (getEndFlag() == BEFORE_FIRST_VALUE) {
164:                    buf.append("BEFORE_FIRST_VALUE ");
165:                }
166:                buf.append(getEnd());
167:                return new String(buf);
168:            }
169:
170:            /**
171:             * Returns true if this range is equal to the given range.
172:             */
173:            public boolean equals(Object ob) {
174:                if (super .equals(ob)) {
175:                    return true;
176:                }
177:
178:                SelectableRange dest_range = (SelectableRange) ob;
179:                return (getStart().valuesEqual(dest_range.getStart())
180:                        && getEnd().valuesEqual(dest_range.getEnd())
181:                        && getStartFlag() == dest_range.getStartFlag() && getEndFlag() == dest_range
182:                        .getEndFlag());
183:            }
184:
185:            // ---------- Statics ----------
186:
187:            /**
188:             * The range that represents the entire range (including null).
189:             */
190:            public static final SelectableRange FULL_RANGE = new SelectableRange(
191:                    FIRST_VALUE, FIRST_IN_SET, LAST_VALUE, LAST_IN_SET);
192:
193:            /**
194:             * The range that represents the entire range (not including null).
195:             */
196:            public static final SelectableRange FULL_RANGE_NO_NULLS = new SelectableRange(
197:                    AFTER_LAST_VALUE, TObject.nullVal(), LAST_VALUE,
198:                    LAST_IN_SET);
199:
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.