com.google.clearsilver.jsilver.functions.html
Class BaseUrlValidateFunction
java.lang.Object
com.google.clearsilver.jsilver.functions.html.BaseUrlValidateFunction
- All Implemented Interfaces:
- TextFilter
- Direct Known Subclasses:
- CssUrlValidateFunction, HtmlUrlValidateFunction
public abstract class BaseUrlValidateFunction
- extends Object
- implements TextFilter
Validates that a given string is either something that looks like a relative URI, or looks like
an absolute URI using one of a set of allowed schemes (http, https, ftp, mailto). If the string
is valid according to these criteria, the string is escaped with an appropriate escaping
function. Otherwise, the string "#" is returned.
Subclasses will apply the necessary escaping function to the string by overriding applyEscaping
.
Note: this function does not validate that the URI is well-formed beyond the scheme part
(and if the URI appears to be relative, not even then). Note in particular that this function
considers strings of the form "www.google.com:80" to be invalid.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BaseUrlValidateFunction
public BaseUrlValidateFunction()
filter
public void filter(String in,
Appendable out)
throws IOException
- Specified by:
filter
in interface TextFilter
- Throws:
IOException
applyEscaping
protected abstract void applyEscaping(String in,
Appendable out)
throws IOException
- Called by
filter
after verifying that the input is a valid URI. Should apply any
appropriate escaping to the input string.
- Throws:
IOException
isValidUri
protected boolean isValidUri(String in)
- Returns:
- true if a given string either looks like a relative URI, or like an absolute URI with
an allowed scheme.
Copyright © 2010-2012 Google. All Rights Reserved.