Source Code Cross Referenced for RegularExpression.java in  » Build » ANT » org » apache » tools » ant » 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 » Build » ANT » org.apache.tools.ant.types 
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:        package org.apache.tools.ant.types;
019:
020:        import org.apache.tools.ant.Project;
021:        import org.apache.tools.ant.util.regexp.Regexp;
022:        import org.apache.tools.ant.util.regexp.RegexpFactory;
023:
024:        /***
025:         * A regular expression datatype.  Keeps an instance of the
026:         * compiled expression for speed purposes.  This compiled
027:         * expression is lazily evaluated (it is compiled the first
028:         * time it is needed).  The syntax is the dependent on which
029:         * regular expression type you are using.  The system property
030:         * "ant.regexp.regexpimpl" will be the classname of the implementation
031:         * that will be used.
032:         *
033:         * <pre>
034:         * For jdk  &lt;= 1.3, there are two available implementations:
035:         *   org.apache.tools.ant.util.regexp.JakartaOroRegexp (the default)
036:         *        Based on the jakarta-oro package
037:         *
038:         *   org.apache.tools.ant.util.regexp.JakartaRegexpRegexp
039:         *        Based on the jakarta-regexp package
040:         *
041:         * For jdk &gt;= 1.4 an additional implementation is available:
042:         *   org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp
043:         *        Based on the jdk 1.4 built in regular expression package.
044:         * </pre>
045:         *
046:         * <pre>
047:         *   &lt;regexp [ [id="id"] pattern="expression" | refid="id" ]
048:         *   /&gt;
049:         * </pre>
050:         *
051:         * @see org.apache.oro.text.regex.Perl5Compiler
052:         * @see org.apache.regexp.RE
053:         * @see java.util.regex.Pattern
054:         *
055:         * @see org.apache.tools.ant.util.regexp.Regexp
056:         *
057:         * @ant.datatype name="regexp"
058:         */
059:        public class RegularExpression extends DataType {
060:            /** Name of this data type */
061:            public static final String DATA_TYPE_NAME = "regexp";
062:            private boolean alreadyInit = false;
063:
064:            // The regular expression factory
065:            private static final RegexpFactory FACTORY = new RegexpFactory();
066:
067:            private Regexp regexp = null;
068:            // temporary variable
069:            private String myPattern;
070:            private boolean setPatternPending = false;
071:
072:            /**
073:             * default constructor
074:             */
075:            public RegularExpression() {
076:            }
077:
078:            private void init(Project p) {
079:                if (!alreadyInit) {
080:                    this .regexp = FACTORY.newRegexp(p);
081:                    alreadyInit = true;
082:                }
083:            }
084:
085:            private void setPattern() {
086:                if (setPatternPending) {
087:                    regexp.setPattern(myPattern);
088:                    setPatternPending = false;
089:                }
090:            }
091:
092:            /**
093:             * sets the regular expression pattern
094:             * @param pattern regular expression pattern
095:             */
096:            public void setPattern(String pattern) {
097:                if (regexp == null) {
098:                    myPattern = pattern;
099:                    setPatternPending = true;
100:                } else {
101:                    regexp.setPattern(pattern);
102:                }
103:            }
104:
105:            /***
106:             * Gets the pattern string for this RegularExpression in the
107:             * given project.
108:             * @param p project
109:             * @return pattern
110:             */
111:            public String getPattern(Project p) {
112:                init(p);
113:                if (isReference()) {
114:                    return getRef(p).getPattern(p);
115:                }
116:                setPattern();
117:                return regexp.getPattern();
118:            }
119:
120:            /**
121:             * provides a reference to the Regexp contained in this
122:             * @param p  project
123:             * @return   Regexp instance associated with this RegularExpression instance
124:             */
125:            public Regexp getRegexp(Project p) {
126:                init(p);
127:                if (isReference()) {
128:                    return getRef(p).getRegexp(p);
129:                }
130:                setPattern();
131:                return this .regexp;
132:            }
133:
134:            /***
135:             * Get the RegularExpression this reference refers to in
136:             * the given project.  Check for circular references too
137:             * @param p project
138:             * @return resolved RegularExpression instance
139:             */
140:            public RegularExpression getRef(Project p) {
141:                return (RegularExpression) getCheckedRef(p);
142:            }
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.