View Javadoc
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: HelperGNUAdapter.java,v $ 37 * 38 * Author: Jose San Leandro Armend?riz 39 * 40 * Description: GNU Regexp 1.1.4-specific helper adapter. 41 * 42 * Last modified by: $Author: chous $ at $Date: 2003/06/21 11:56:06 $ 43 * 44 * File version: $Revision: 1.1 $ 45 * 46 * Project version: $Name: $ 47 * ("Name" means no concrete version has been checked out) 48 * 49 * $Id: HelperGNUAdapter.java,v 1.1 2003/06/21 11:56:06 chous Exp $ 50 * 51 */ 52 package org.acmsl.regexpplugin.gnuregexp; 53 54 /* 55 * Importing project-specific classes. 56 */ 57 import org.acmsl.regexpplugin.gnuregexp.MalformedPatternExceptionGNUAdapter; 58 import org.acmsl.regexpplugin.Helper; 59 import org.acmsl.regexpplugin.MalformedPatternException; 60 61 /* 62 * Importing some ACM classes. 63 */ 64 import org.acmsl.version.Version; 65 import org.acmsl.version.VersionFactory; 66 67 /* 68 * Importing GNU Regexp 1.1.4 classes. 69 */ 70 import gnu.regexp.RE; 71 import gnu.regexp.REException; 72 73 /*** 74 * GNU Regexp 1.1.4-specific helper adapter. 75 * @author <a href="mailto:jsanleandro@yahoo.es" 76 >Jose San Leandro Armend?riz</a> 77 * @version $Revision: 1.1 $ 78 */ 79 public class HelperGNUAdapter 80 implements Helper 81 { 82 /*** 83 * Finds all occurrences of a specified pattern in given input contents, 84 * and replaces them with passed String. 85 * @param input the input text to process. 86 * @param pattern the pattern to replace. 87 * @param replacement the replacement text. 88 * @return the updated input. 89 * @throws MalformedPatternException if given regexp is malformed. 90 */ 91 public String replaceAll(String input, String pattern, String replacement) 92 throws MalformedPatternException 93 { 94 String result = input; 95 96 if ( (input != null) 97 && (pattern != null) 98 && (replacement != null)) 99 { 100 try 101 { 102 RE t_RE = new RE(pattern); 103 104 result = t_RE.substituteAll(input, replacement); 105 } 106 catch (REException reException) 107 { 108 throw 109 new MalformedPatternExceptionGNUAdapter( 110 reException); 111 } 112 } 113 114 return result; 115 } 116 117 /*** 118 * Concrete version object updated everytime it's checked-in in a CVS 119 * repository. 120 */ 121 public static final Version VERSION = 122 VersionFactory.createVersion("$Revision: 1.1 $"); 123 124 /*** 125 * Retrieves the current version of this object. 126 * @return the version object with such information. 127 */ 128 public Version getVersion() 129 { 130 return VERSION; 131 } 132 133 /*** 134 * Retrieves the current version of this class. 135 * @return the object with class version information. 136 */ 137 public static Version getClassVersion() 138 { 139 return VERSION; 140 } 141 }

This page was automatically generated by Maven