reg exp replace now available in templates
[mir.git] / source / mircoders / localizer / basic / MirBasicProducerAssistantLocalizer.java
index 0f9144e..00d5131 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001, 2002  The Mir-coders group
+ * Copyright (C) 2001, 2002 The Mir-coders group
  *
  * This file is part of Mir.
  *
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with the com.oreilly.servlet library, any library
- * licensed under the Apache Software License, The Sun (tm) Java Advanced
- * Imaging library (JAI), The Sun JIMI library (or with modified versions of
- * the above that use the same license as the above), and distribute linked
- * combinations including the two.  You must obey the GNU General Public
- * License in all respects for all of the code used other than the above
- * mentioned libraries.  If you modify this file, you may extend this exception
- * to your version of the file, but you are not obligated to do so.  If you do
- * not wish to do so, delete this exception statement from your version.
+ * the code of this program with  any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two.  You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries.  If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
  */
-
 package mircoders.localizer.basic;
 
-import java.util.GregorianCalendar;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.Map;\r
-\r
-import mir.config.MirPropertiesConfiguration;\r
-import mir.entity.adapter.EntityAdapter;\r
-import mir.entity.adapter.EntityIteratorAdapter;\r
-import mir.log.LoggerWrapper;\r
-import mir.misc.StringUtil;\r
-import mir.util.DateToMapAdapter;\r
-import mir.util.GeneratorExpressionFunctions;\r
-import mir.util.GeneratorHTMLFunctions;\r
-import mir.util.GeneratorIntegerFunctions;\r
-import mir.util.GeneratorListFunctions;\r
-import mir.util.GeneratorStringFunctions;\r
-import mircoders.global.MirGlobal;\r
-import mircoders.localizer.MirProducerAssistantLocalizer;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import mir.config.MirPropertiesConfiguration;
+import mir.entity.adapter.EntityAdapter;
+import mir.entity.adapter.EntityIteratorAdapter;
+import mir.log.LoggerWrapper;
+import mir.misc.StringUtil;
+import mir.util.DateToMapAdapter;
+import mir.util.GeneratorExpressionFunctions;
+import mir.util.*;
+import mir.util.GeneratorIntegerFunctions;
+import mir.util.GeneratorListFunctions;
+import mir.util.GeneratorStringFunctions;
+import mircoders.global.MirGlobal;
+import mircoders.localizer.*;
 
 public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantLocalizer {
   protected LoggerWrapper logger;
 
-  public void initializeGenerationValueSet(Map aValueSet) {
+  public void initializeGenerationValueSet(Map aValueSet) throws MirLocalizerExc, MirLocalizerFailure  {
     try {
       Iterator i;
 
@@ -89,6 +87,9 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL
       utilityMap.put("isOdd", new GeneratorIntegerFunctions.isOddFunction());
       utilityMap.put("increment", new GeneratorIntegerFunctions.incrementFunction());
       utilityMap.put("evaluate", new GeneratorExpressionFunctions.evaluateExpressionFunction());
+      utilityMap.put("constructString", new GeneratorStringFunctions.constructStructuredStringFunction());
+      utilityMap.put("escapeJDBCString", new GeneratorStringFunctions.jdbcStringEscapeFunction());
+      utilityMap.put("regexpreplace", new GeneratorRegularExpressionFunctions.regularExpressionReplaceFunction());
 
       aValueSet.put("config", configMap);
       aValueSet.put("utility", utilityMap);
@@ -130,13 +131,17 @@ public class MirBasicProducerAssistantLocalizer implements MirProducerAssistantL
 
   };
 
-  public String filterText(String aText) {
+  public String filterNonHTMLText(String aText) {
     return StringUtil.createHTML(
-        StringUtil.deleteForbiddenTags(aText),
+        StringUtil.removeHTMLTags(aText),
         MirGlobal.config().getString("Producer.ImageRoot"),
         MirGlobal.config().getString("Producer.MailLinkName"),
         MirGlobal.config().getString("Producer.ExtLinkName"),
         MirGlobal.config().getString("Producer.IntLinkName")
     );
   }
+
+  public String filterHTMLText(String aText) {
+    return StringUtil.deleteForbiddenTags(aText);
+  }
 }