Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/acmsl/regexpplugin/jakartaregexp/PatternRegexpAdapter.java


1   /*
2                   Java Regular Expressions Plugin API
3   
4       Copyright (C) 2002  Jose San Leandro Armendáriz
5                           jsanleandro@yahoo.es
6                           chousz@yahoo.com
7   
8       This library is free software; you can redistribute it and/or
9       modify it under the terms of the GNU Lesser General Public
10      License as published by the Free Software Foundation; either
11      version 2.1 of the License, or (at your option) any later version.
12  
13      This library is distributed in the hope that it will be useful,
14      but WITHOUT ANY WARRANTY; without even the implied warranty of
15      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16      Lesser General Public License for more details.
17  
18      You should have received a copy of the GNU Lesser General Public
19      License along with this library; if not, write to the Free Software
20      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  
22      Thanks to ACM S.L. for distributing this library under the LGPL license.
23      Contact info: jsr000@terra.es
24      Postal Address: c/Playa de Lagoa, 1
25                      Urb. Valdecabañas
26                      Boadilla del monte
27                      28660 Madrid
28                      Spain
29  
30      This library uses some external APIs. So far I haven't released such
31      APIs as projects themselves, but you should be able
32      to download them from the web page where you got this source code.
33  
34   ******************************************************************************
35   *
36   * Filename: $RCSfile: PatternRegexpAdapter.java,v $
37   *
38   * Author: Jose San Leandro Armendáriz
39   *
40   * Description: Adapts Jakarta Regexp REProgram objects to follow the
41   *              generic Pattern interface defined in this API.
42   *
43   * Last modified by: $Author: dev $ at $Date: 2002/09/27 08:27:18 $
44   *
45   * File version: $Revision: 1.4 $
46   *
47   * Project version: $Name:  $
48   *                  ("Name" means no concrete version has been checked out)
49   *
50   * $Id: PatternRegexpAdapter.java,v 1.4 2002/09/27 08:27:18 dev Exp $
51   *
52   */
53  package org.acmsl.regexpplugin.jakartaregexp;
54  
55  /*
56   * Importing some project-specific classes.
57   */
58  import org.acmsl.regexpplugin.Pattern;
59  
60  /*
61   * Importing some ACM classes.
62   */
63  import org.acmsl.version.Version;
64  import org.acmsl.version.VersionFactory;
65  
66  /*
67   * Importing some Jakarta Regexp classes.
68   */
69  import org.apache.regexp.RE;
70  import org.apache.regexp.REProgram;
71  
72  /**
73   * Adapts Jakarta Regexp REProgram objects to follow the generic
74   * Pattern interface defined in this API.
75   * @author <a href="mailto:jsanleandro@yahoo.es"
76             >Jose San Leandro Armendáriz</a>
77   * @version $Revision: 1.4 $
78   */
79  public class PatternRegexpAdapter
80      implements  Pattern
81  {
82      /**
83       * Delegated instance.
84       */
85      private REProgram m__Instance;
86  
87      /**
88       * RE reference needed to pass compiler configuration to the
89       * mather.
90       */
91      private RE m__RE;
92  
93      /**
94       * Constructs a PatternRegexpAdapter for given object.
95       * @param adaptee the instance to be adapted.
96       */
97      public PatternRegexpAdapter(REProgram adaptee, RE re)
98      {
99          setAdaptee(adaptee);
100 
101         setRE(re);
102     }
103 
104     /**
105      * Sets the instance to adapt.
106      * @param adaptee the REProgram to be adapted.
107      */
108     protected void setAdaptee(REProgram adaptee)
109     {
110         m__Instance = adaptee;
111     }
112 
113     /**
114      * Retrieves an instance of a REProgram class.
115      * @return such instance.
116      */
117     protected REProgram getDelegatedInstance()
118     {
119         return m__Instance;
120     }
121 
122     /**
123      * Sets the RE reference.
124      * @param re such reference.
125      */
126     void setRE(RE re)
127     {
128         m__RE = re;
129     }
130 
131     /**
132      * Retrieves the associated RE reference.
133      * Note: Other classes in this package can access this method.
134      * @return the RE with compiler configuration.
135      */
136     RE getRE()
137     {
138         return m__RE;
139     }
140 
141     /**
142      * Concrete version object updated everytime it's checked-in in a CVS
143      * repository.
144      */
145     public static final Version VERSION =
146         VersionFactory.createVersion("$Revision: 1.4 $");
147 
148     /**
149      * Retrieves the current version of this object.
150      * @return the version object with such information.
151      */
152     public Version getVersion()
153     {
154         return VERSION;
155     }
156 
157     /**
158      * Retrieves the current version of this class.
159      * @return the object with class version information.
160      */
161     public static Version getClassVersion()
162     {
163         return VERSION;
164     }
165 }