当前位置: 首页>>代码示例>>Java>>正文


Java FunctionReplacer类代码示例

本文整理汇总了Java中org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer的典型用法代码示例。如果您正苦于以下问题:Java FunctionReplacer类的具体用法?Java FunctionReplacer怎么用?Java FunctionReplacer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FunctionReplacer类属于org.tuckey.web.filters.urlrewrite.substitution包,在下文中一共展示了FunctionReplacer类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDefaultEscape

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testDefaultEscape() throws UnsupportedEncodingException {
    assertEquals("a%20b%20c%20:%20other%20%2f%20path",
            FunctionReplacer.replace("${escapePath:UTF-8:a b c : other / path}"));
    assertEquals("a+b+c+%3A+other+%2F+path",
            FunctionReplacer.replace("${escape:UTF-8:a b c : other / path}"));
    assertEquals("a+b c/",
            FunctionReplacer.replace("${unescapePath:UTF-8:a+b c%2F}"));
    assertEquals("a b c/",
            FunctionReplacer.replace("${unescape:UTF-8:a+b c%2F}"));
    assertEquals("a+b+c%FE%FF%00%3Aotherstr",
            FunctionReplacer.replace("${escape:UTF-16:a b c:otherstr}"));
    assertEquals("a+b+c%3Aotherstr",
            FunctionReplacer.replace("${escape:utf8:a b c:otherstr}"));
    assertEquals("a+b+c",
            FunctionReplacer.replace("${escape:UTF-16:a b c}"));
    assertEquals("a b c",
            FunctionReplacer.replace("${unescape:UTF-16:a+b+c}"));
    assertEquals(java.net.URLEncoder.encode(UNICODE_VALUE, "UTF-8"),
            FunctionReplacer.replace("${escape:unknown:" + UNICODE_VALUE + "}"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:21,代码来源:FunctionReplacerTest.java

示例2: initialise

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public boolean initialise() {
    initialised = true;

    if (value != null) {
        if (BackReferenceReplacer.containsBackRef(value)) {
            valueContainsBackRef = true;
        }
        if (VariableReplacer.containsVariable(value)) {
            valueContainsVariable = true;
        }
        if (FunctionReplacer.containsFunction(value)) {
            valueContainsFunction = true;
        }
    }

    if (type == SET_TYPE_STAUS) {
        initNumericValue();
    } else if (type == SET_TYPE_LOCALE) {
        // value might be zh-CN-abcdef or zh-CN or zh
        locale = null;
        if (value == null) {
            setError("Locale is not valid because value is null");
        } else if (value.matches("[a-zA-Z][a-zA-Z]")) {
            locale = new Locale(value);
        } else if (value.matches("[a-zA-Z][a-zA-Z]-[a-zA-Z][a-zA-Z]")) {
            locale = new Locale(value.substring(1, 2), value.substring(2, 4));
        } else if (value.matches("[a-zA-Z][a-zA-Z]-[a-zA-Z][a-zA-Z]-.*")) {
            locale = new Locale(value.substring(1, 2), value.substring(4, 5), value.substring(6, value.length()));
        } else {
            setError("Locale " + value + " is not valid (valid locales are, zh, zh-CN, zh-CN-rural)");
        }

    } else if (type == SET_TYPE_COOKIE) {
        // VAL[:domain[:lifetime[:path]]]
        if (value != null && name != null) {
            getCookie(name, value);
        } else {
            setError("cookie must have a name and a value");
        }

    } else if (type == SET_TYPE_EXPIRES) {
        // "access plus 1 month"
        if (value != null ) {
            expiresValueAdd = parseTimeValue(value);
        } else {
            setError("expires must have a value");
        }
    }

    if (error == null) {
        valid = true;
    }
    return valid;
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:55,代码来源:SetAttribute.java

示例3: testEncodingEscape

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testEncodingEscape() {
    assertEquals(UTF16ESCAPED_UNICODE_VALUE,
            FunctionReplacer.replace("${escape:UTF-16:" + UNICODE_VALUE + "}"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java

示例4: testDefaultUnescape

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testDefaultUnescape() throws java.io.UnsupportedEncodingException {
    String testString = "unknown:" + UNICODE_VALUE;
    assertEquals(testString, FunctionReplacer.replace(
            "${unescape:" + java.net.URLEncoder.encode(testString, "UTF-8") + "}"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:6,代码来源:FunctionReplacerTest.java

示例5: testEncodingUnescape

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testEncodingUnescape() {
    assertEquals(UNICODE_VALUE, FunctionReplacer.replace(
            "${unescape:UTF-16:" + UTF16ESCAPED_UNICODE_VALUE + "}"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java

示例6: testSimple1

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testSimple1() throws InvocationTargetException, IOException, ServletException {
    assertTrue(FunctionReplacer.containsFunction("a${lower:HEllo}b"));
    assertEquals("ahellob", FunctionReplacer.replace("a${lower:HElLO}b"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java

示例7: testSimple2

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testSimple2() throws InvocationTargetException, IOException, ServletException {
    assertTrue(FunctionReplacer.containsFunction("a${upper:HEllo}b"));
    assertEquals("aHELLOb", FunctionReplacer.replace("a${upper:hellO}b"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java

示例8: testSimple3

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testSimple3() throws InvocationTargetException, IOException, ServletException {
    assertTrue(FunctionReplacer.containsFunction("a${replace:a b c: :_}b"));
    assertEquals("aa_b_cb", FunctionReplacer.replace("a${replace:a b c: :_}b"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java

示例9: testSimple4

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testSimple4() throws InvocationTargetException, IOException, ServletException {
    assertTrue(FunctionReplacer.containsFunction("a${replaceFirst:a b c: :_}b"));
    assertEquals("aa_b cb", FunctionReplacer.replace("a${replaceFirst:a b c: :_}b"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java

示例10: testSimple5

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testSimple5() throws InvocationTargetException, IOException, ServletException {
    assertTrue(FunctionReplacer.containsFunction("a${escape:a b c} b"));
    assertEquals("aa+b+c b", FunctionReplacer.replace("a${escape:a b c} b"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java

示例11: testSimple6

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testSimple6() throws InvocationTargetException, IOException, ServletException {
    assertTrue(FunctionReplacer.containsFunction("a${trim: b } b"));
    assertEquals("ab b", FunctionReplacer.replace("a${trim: b } b"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java

示例12: testSimple7

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testSimple7() throws InvocationTargetException, IOException, ServletException {
    assertTrue(FunctionReplacer.containsFunction("a${length:asdf} b"));
    assertEquals("a4 b", FunctionReplacer.replace("a${length:asdf} b"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java

示例13: testRecursive

import org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer; //导入依赖的package包/类
public void testRecursive() throws InvocationTargetException, IOException, ServletException {
    assertTrue(FunctionReplacer.containsFunction("a${upper:${lower:fOObAR}} b"));
    assertEquals("aFOOBAR b", FunctionReplacer.replace("a${upper:${lower:fOObAR}} b"));
}
 
开发者ID:paultuckey,项目名称:urlrewritefilter,代码行数:5,代码来源:FunctionReplacerTest.java


注:本文中的org.tuckey.web.filters.urlrewrite.substitution.FunctionReplacer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。