Source Code Cross Referenced for SupplRangeSet.java in  » Apache-Harmony-Java-SE » java-package » java » util » regex » 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 » Apache Harmony Java SE » java package » java.util.regex 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /*
019:         *
020:         *  Portions, Copyright © 1991-2005 Unicode, Inc. The following applies to Unicode. 
021:         *
022:         *  COPYRIGHT AND PERMISSION NOTICE
023:         *
024:         *  Copyright © 1991-2005 Unicode, Inc. All rights reserved. Distributed under 
025:         *  the Terms of Use in http://www.unicode.org/copyright.html. Permission is
026:         *  hereby granted, free of charge, to any person obtaining a copy of the
027:         *  Unicode data files and any associated documentation (the "Data Files")
028:         *  or Unicode software and any associated documentation (the "Software") 
029:         *  to deal in the Data Files or Software without restriction, including without
030:         *  limitation the rights to use, copy, modify, merge, publish, distribute,
031:         *  and/or sell copies of the Data Files or Software, and to permit persons
032:         *  to whom the Data Files or Software are furnished to do so, provided that 
033:         *  (a) the above copyright notice(s) and this permission notice appear with
034:         *  all copies of the Data Files or Software, (b) both the above copyright
035:         *  notice(s) and this permission notice appear in associated documentation,
036:         *  and (c) there is clear notice in each modified Data File or in the Software
037:         *  as well as in the documentation associated with the Data File(s) or Software
038:         *  that the data or software has been modified.
039:
040:         *  THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
041:         *  KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
042:         *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 
043:         *  OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
044:         *  INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
045:         *  OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
046:         *  OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
047:         *  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
048:         *  PERFORMANCE OF THE DATA FILES OR SOFTWARE.
049:         *
050:         *  Except as contained in this notice, the name of a copyright holder shall
051:         *  not be used in advertising or otherwise to promote the sale, use or other
052:         *  dealings in these Data Files or Software without prior written
053:         *  authorization of the copyright holder.
054:         *
055:         *  2. Additional terms from the Database:
056:         *
057:         *  Copyright © 1995-1999 Unicode, Inc. All Rights reserved.
058:         *
059:         *  Disclaimer 
060:         *
061:         *  The Unicode Character Database is provided as is by Unicode, Inc.
062:         *  No claims are made as to fitness for any particular purpose. No warranties
063:         *  of any kind are expressed or implied. The recipient agrees to determine
064:         *  applicability of information provided. If this file has been purchased
065:         *  on magnetic or optical media from Unicode, Inc., the sole remedy for any claim
066:         *  will be exchange of defective media within 90 days of receipt. This disclaimer
067:         *  is applicable for all other data files accompanying the Unicode Character Database,
068:         *  some of which have been compiled by the Unicode Consortium, and some of which
069:         *  have been supplied by other sources.
070:         *
071:         *  Limitations on Rights to Redistribute This Data
072:         *
073:         *  Recipient is granted the right to make copies in any form for internal
074:         *  distribution and to freely use the information supplied in the creation of
075:         *  products supporting the UnicodeTM Standard. The files in 
076:         *  the Unicode Character Database can be redistributed to third parties or other
077:         *  organizations (whether for profit or not) as long as this notice and the disclaimer
078:         *  notice are retained. Information can be extracted from these files and used
079:         *  in documentation or programs, as long as there is an accompanying notice
080:         *  indicating the source. 
081:         */
082:
083:        package java.util.regex;
084:
085:        /**
086:         * Represents node accepting single character from the given char class.
087:         * This character can be supplementary (2 chars needed to represent) or from 
088:         * basic multilingual pane (1 needed char to represent it).
089:         */
090:        class SupplRangeSet extends JointSet {
091:
092:            protected AbstractCharClass chars;
093:
094:            protected boolean alt = false;
095:
096:            public SupplRangeSet(AbstractCharClass cs, AbstractSet next) {
097:                this .chars = cs.getInstance();
098:                this .alt = cs.alt;
099:                this .next = next;
100:            }
101:
102:            public SupplRangeSet(AbstractCharClass cc) {
103:                this .chars = cc.getInstance();
104:                this .alt = cc.alt;
105:            }
106:
107:            public int matches(int stringIndex, CharSequence testString,
108:                    MatchResultImpl matchResult) {
109:                int strLength = matchResult.getRightBound();
110:                int offset = -1;
111:
112:                if (stringIndex < strLength) {
113:                    char high = testString.charAt(stringIndex++);
114:
115:                    if (contains(high)
116:                            && (offset = next.matches(stringIndex, testString,
117:                                    matchResult)) > 0) {
118:                        return offset;
119:                    }
120:
121:                    if (stringIndex < strLength) {
122:                        char low = testString.charAt(stringIndex++);
123:
124:                        if (Character.isSurrogatePair(high, low)
125:                                && contains(Character.toCodePoint(high, low))) {
126:                            return next.matches(stringIndex, testString,
127:                                    matchResult);
128:                        }
129:                    }
130:                }
131:
132:                return -1;
133:            }
134:
135:            protected String getName() {
136:                return "range:" + (alt ? "^ " : " ") + chars.toString();
137:            }
138:
139:            public boolean contains(int ch) {
140:                return chars.contains(ch);
141:            }
142:
143:            public boolean first(AbstractSet set) {
144:                if (set instanceof  SupplCharSet) {
145:                    return AbstractCharClass.intersects(chars,
146:                            ((SupplCharSet) set).getCodePoint());
147:                } else if (set instanceof  CharSet) {
148:                    return AbstractCharClass.intersects(chars, ((CharSet) set)
149:                            .getChar());
150:                } else if (set instanceof  SupplRangeSet) {
151:                    return AbstractCharClass.intersects(chars,
152:                            ((SupplRangeSet) set).chars);
153:                } else if (set instanceof  RangeSet) {
154:                    return AbstractCharClass.intersects(chars, ((RangeSet) set)
155:                            .getChars());
156:                }
157:
158:                return true;
159:            }
160:
161:            protected AbstractCharClass getChars() {
162:                return chars;
163:            }
164:
165:            public AbstractSet getNext() {
166:                return next;
167:            }
168:
169:            public void setNext(AbstractSet next) {
170:                this .next = next;
171:            }
172:
173:            public boolean hasConsumed(MatchResultImpl mr) {
174:                return true;
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.