1 /**
2  *  ServingXML
3  *
4  *  Copyright (C) 2006  Daniel Parker
5  *    daniel.parker@servingxml.com
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  **/
20 
21 package com.servingxml.expr.substitution;
22 
23 import java.nio.charset.Charset;
24 
25 import com.servingxml.util.CharsetHelper;
26 import com.servingxml.util.ServingXmlException;
27 
28 /**
29  *
30  * @author  Daniel A. Parker
31  */
32 
33 public interface EscapeSubstitutionVariables {
34   public static final EscapeSubstitutionVariables DO_NOT_ESCAPE = new DoNotEscapeSubstitutionVariables();
35 
doEscape()36   boolean doEscape();
37 
getCharacter()38   char getCharacter();
39 
getEscapeSequence()40   String getEscapeSequence();
41 
mustEscape(char ch)42   boolean mustEscape(char ch);
43 
escape(String s)44   String escape(String s);
45 
escape(String input, StringBuilder output)46   void escape(String input, StringBuilder output);
47 
48   public final static class DoNotEscapeSubstitutionVariables implements EscapeSubstitutionVariables {
49     private final char character = '\\';
50     private final String escapeSequence = "\\";
51 
DoNotEscapeSubstitutionVariables()52     public DoNotEscapeSubstitutionVariables() {
53     }
54 
doEscape()55     public boolean doEscape() {
56       return false;
57     }
58 
getCharacter()59     public final char getCharacter() {
60       return character;
61     }
62 
getEscapeSequence()63     public final String getEscapeSequence() {
64       return escapeSequence;
65     }
66 
mustEscape(char ch)67     public final boolean mustEscape(char ch) {
68       return false;
69     }
70 
escape(String s)71     public final String escape(String s) {
72       return s;
73     }
74 
escape(String input, StringBuilder output)75     public final void escape(String input, StringBuilder output) {
76     }
77 
escape(String input, int pos, StringBuilder output)78     private final void escape(String input, int pos, StringBuilder output) {
79     }
80   }
81 }
82 
83