Source Code Cross Referenced for Interval.java in  » Parser » JFlex » JFlex » 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 » Parser » JFlex » JFlex 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
002:         * JFlex 1.4.1                                                             *
003:         * Copyright (C) 1998-2004  Gerwin Klein <lsf@jflex.de>                    *
004:         * All rights reserved.                                                    *
005:         *                                                                         *
006:         * This program is free software; you can redistribute it and/or modify    *
007:         * it under the terms of the GNU General Public License. See the file      *
008:         * COPYRIGHT for more information.                                         *
009:         *                                                                         *
010:         * This program is distributed in the hope that it will be useful,         *
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
013:         * GNU General Public License for more details.                            *
014:         *                                                                         *
015:         * You should have received a copy of the GNU General Public License along *
016:         * with this program; if not, write to the Free Software Foundation, Inc., *
017:         * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                 *
018:         *                                                                         *
019:         * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
020:
021:        package JFlex;
022:
023:        /**
024:         * An intervall of characters with basic operations.
025:         *
026:         * @author Gerwin Klein
027:         * @version JFlex 1.4.1, $Revision: 2.4 $, $Date: 2004/11/06 23:03:30 $
028:         */
029:        public final class Interval {
030:
031:            /* start and end of the intervall */
032:            public char start, end;
033:
034:            /**
035:             * Constuct a new intervall from <code>start</code> to <code>end</code>.
036:             *
037:             * @param start  first character the intervall should contain
038:             * @param end    last  character the intervall should contain
039:             */
040:            public Interval(char start, char end) {
041:                this .start = start;
042:                this .end = end;
043:            }
044:
045:            /**
046:             * Copy constructor
047:             */
048:            public Interval(Interval other) {
049:                this .start = other.start;
050:                this .end = other.end;
051:            }
052:
053:            /**
054:             * Return <code>true</code> iff <code>point</code> is contained in this intervall.
055:             *
056:             * @param point  the character to check
057:             */
058:            public boolean contains(char point) {
059:                return start <= point && end >= point;
060:            }
061:
062:            /**
063:             * Return <code>true</code> iff this intervall completely contains the 
064:             * other one.
065:             *
066:             * @param other    the other intervall 
067:             */
068:            public boolean contains(Interval other) {
069:                return this .start <= other.start && this .end >= other.end;
070:            }
071:
072:            /**
073:             * Return <code>true</code> if <code>o</code> is an intervall
074:             * with the same borders.
075:             *
076:             * @param o  the object to check equality with
077:             */
078:            public boolean equals(Object o) {
079:                if (o == this )
080:                    return true;
081:                if (!(o instanceof  Interval))
082:                    return false;
083:
084:                Interval other = (Interval) o;
085:                return other.start == this .start && other.end == this .end;
086:            }
087:
088:            /**
089:             * Set a new last character
090:             *
091:             * @param end  the new last character of this intervall
092:             */
093:            public void setEnd(char end) {
094:                this .end = end;
095:            }
096:
097:            /** 
098:             * Set a new first character
099:             *
100:             * @param start the new first character of this intervall
101:             */
102:            public void setStart(char start) {
103:                this .start = start;
104:            }
105:
106:            /**
107:             * Check wether a character is printable.
108:             *
109:             * @param c the character to check
110:             */
111:            private static boolean isPrintable(char c) {
112:                // fixme: should make unicode test here
113:                return c > 31 && c < 127;
114:            }
115:
116:            /**
117:             * Get a String representation of this intervall.
118:             *
119:             * @return a string <code>"[start-end]"</code> or
120:             *         <code>"[start]"</code> (if there is only one character in
121:             *         the intervall) where <code>start</code> and
122:             *         <code>end</code> are either a number (the character code)
123:             *         or something of the from <code>'a'</code>.  
124:             */
125:            public String toString() {
126:                StringBuffer result = new StringBuffer("[");
127:
128:                if (isPrintable(start))
129:                    result.append("'" + start + "'");
130:                else
131:                    result.append((int) start);
132:
133:                if (start != end) {
134:                    result.append("-");
135:
136:                    if (isPrintable(end))
137:                        result.append("'" + end + "'");
138:                    else
139:                        result.append((int) end);
140:                }
141:
142:                result.append("]");
143:                return result.toString();
144:            }
145:
146:            /**
147:             * Make a copy of this interval.
148:             * 
149:             * @return the copy
150:             */
151:            public Interval copy() {
152:                return new Interval(start, end);
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.