merge of localization branch into HEAD. mh and zap
[mir.git] / source / mir / util / GeneratorHTMLFunctions.java
1 package mir.util;
2
3 import java.util.*;
4 import java.net.*;
5
6 import mir.misc.*;
7 import mir.generator.*;
8
9 /**
10  * <p>Title: </p>
11  * <p>Description: </p>
12  * <p>Copyright: Copyright (c) 2002</p>
13  * <p>Company: </p>
14  * @author unascribed
15  * @version 1.0
16  */
17
18 public class GeneratorHTMLFunctions {
19   private GeneratorHTMLFunctions() {}
20
21   public static class encodeURIGeneratorFunction implements Generator.GeneratorFunction {
22     public Object perform(List aParameters) throws GeneratorExc {
23       if (aParameters.size()!=1)
24         throw new GeneratorExc("encodeHTMLGeneratorFunction: only 1 parameter expected");
25       if (!(aParameters.get(0) instanceof String))
26         throw new GeneratorExc("encodeHTMLGeneratorFunction: parameter must be a string");
27
28       return URLEncoder.encode((String) aParameters.get(0));
29     };
30   }
31
32   public static class encodeHTMLGeneratorFunction implements Generator.GeneratorFunction {
33     public Object perform(List aParameters) throws GeneratorExc {
34       if (aParameters.size()!=1)
35         throw new GeneratorExc("encodeHTMLGeneratorFunction: only 1 parameter expected");
36       if (!(aParameters.get(0) instanceof String))
37         throw new GeneratorExc("encodeHTMLGeneratorFunction: parameter must be a string");
38
39       // YUCK! -mh
40       //return StringUtil.encodeHtml((String) aParameters.get(0));
41       return (String) aParameters.get(0);
42     };
43   }
44 }