Fields Summary |
---|
private final String | EXP_ATT_PARAM |
protected static final String | VAR |
protected static final String | SCOPE |
protected static final String | PAGE_SCOPE |
protected static final String | REQUEST_SCOPE |
protected static final String | SESSION_SCOPE |
protected static final String | APPLICATION_SCOPE |
protected final String | JSP |
private static final int | TYPE_UNDEFINED |
protected static final int | TYPE_CORE |
protected static final int | TYPE_FMT |
protected static final int | TYPE_SQL |
protected static final int | TYPE_XML |
private int | tlvType |
protected String | uri |
protected String | prefix |
protected Vector | messageVector |
protected Map | config |
protected boolean | failed |
protected String | lastElementId |
Methods Summary |
---|
private void | configure(java.lang.String info)
// construct our configuration map
config = new HashMap();
// leave the map empty if we have nothing to configure
if (info == null)
return;
// separate parameter into space-separated tokens and store them
StringTokenizer st = new StringTokenizer(info);
while (st.hasMoreTokens()) {
String pair = st.nextToken();
StringTokenizer pairTokens = new StringTokenizer(pair, ":");
String element = pairTokens.nextToken();
String attribute = pairTokens.nextToken();
Object atts = config.get(element);
if (atts == null) {
atts = new HashSet();
config.put(element, atts);
}
((Set) atts).add(attribute);
}
|
protected void | fail(java.lang.String message)
failed = true;
messageVector.add(new ValidationMessage(lastElementId, message));
|
protected abstract org.xml.sax.helpers.DefaultHandler | getHandler()
|
protected java.lang.String | getLocalPart(java.lang.String qname)
int colon = qname.indexOf(":");
if (colon == -1)
return qname;
else
return qname.substring(colon + 1);
|
protected boolean | hasAttribute(org.xml.sax.Attributes a, java.lang.String att)
return (a.getValue(att) != null);
|
protected boolean | hasDanglingScope(org.xml.sax.Attributes a)
return (a.getValue(SCOPE) != null && a.getValue(VAR) == null);
|
protected boolean | hasEmptyVar(org.xml.sax.Attributes a)
if ("".equals(a.getValue(VAR)))
return true;
return false;
|
protected boolean | hasNoInvalidScope(org.xml.sax.Attributes a)
String scope = a.getValue(SCOPE);
if ((scope != null)
&& !scope.equals(PAGE_SCOPE)
&& !scope.equals(REQUEST_SCOPE)
&& !scope.equals(SESSION_SCOPE)
&& !scope.equals(APPLICATION_SCOPE))
return false;
return true;
|
private void | init()
messageVector = null;
prefix = null;
config = null;
|
protected boolean | isCoreTag(java.lang.String tagUri, java.lang.String tagLn, java.lang.String target)
return isTag( TYPE_CORE, tagUri, tagLn, target );
|
protected boolean | isFmtTag(java.lang.String tagUri, java.lang.String tagLn, java.lang.String target)
return isTag( TYPE_FMT, tagUri, tagLn, target );
|
protected boolean | isJspTag(java.lang.String tagUri, java.lang.String tagLn, java.lang.String target)
return isTag(tagUri, tagLn, JSP, target);
|
protected boolean | isSpecified(javax.servlet.jsp.tagext.TagData data, java.lang.String attributeName)
return (data.getAttribute(attributeName) != null);
|
protected boolean | isSqlTag(java.lang.String tagUri, java.lang.String tagLn, java.lang.String target)
return isTag( TYPE_SQL, tagUri, tagLn, target );
|
protected boolean | isTag(java.lang.String tagUri, java.lang.String tagLn, java.lang.String matchUri, java.lang.String matchLn)
if (tagUri == null
|| tagUri.length() == 0
|| tagLn == null
|| matchUri == null
|| matchLn == null)
return false;
// match beginning of URI since some suffix *_rt tags can
// be nested in EL enabled tags as defined by the spec
if (tagUri.length() > matchUri.length()) {
return (tagUri.startsWith(matchUri) && tagLn.equals(matchLn));
} else {
return (matchUri.startsWith(tagUri) && tagLn.equals(matchLn));
}
|
private boolean | isTag(int type, java.lang.String tagUri, java.lang.String tagLn, java.lang.String target)
return ( this.tlvType == type && isTag(tagUri, tagLn, this.uri, target) );
|
protected boolean | isXmlTag(java.lang.String tagUri, java.lang.String tagLn, java.lang.String target)
return isTag( TYPE_XML, tagUri, tagLn, target );
|
public void | release()
super.release();
init();
|
public synchronized javax.servlet.jsp.tagext.ValidationMessage[] | validate(int type, java.lang.String prefix, java.lang.String uri, javax.servlet.jsp.tagext.PageData page)
try {
this.tlvType = type;
this.uri = uri;
// initialize
messageVector = new Vector();
// save the prefix
this.prefix = prefix;
// parse parameters if necessary
try {
if (config == null)
configure((String) getInitParameters().get(EXP_ATT_PARAM));
} catch (NoSuchElementException ex) {
// parsing error
return vmFromString(
Resources.getMessage("TLV_PARAMETER_ERROR",
EXP_ATT_PARAM));
}
// get a handler
DefaultHandler h = getHandler();
// parse the page
SAXParserFactory f = SAXParserFactory.newInstance();
f.setValidating(false);
f.setNamespaceAware(true);
SAXParser p = f.newSAXParser();
p.parse(page.getInputStream(), h);
if (messageVector.size() == 0)
return null;
else
return vmFromVector(messageVector);
} catch (SAXException ex) {
return vmFromString(ex.toString());
} catch (ParserConfigurationException ex) {
return vmFromString(ex.toString());
} catch (IOException ex) {
return vmFromString(ex.toString());
}
|
protected java.lang.String | validateExpression(java.lang.String elem, java.lang.String att, java.lang.String expr)
// let's just use the cache kept by the ExpressionEvaluatorManager
ExpressionEvaluator current;
try {
current =
ExpressionEvaluatorManager.getEvaluatorByName(
ExpressionEvaluatorManager.EVALUATOR_CLASS);
} catch (JspException ex) {
// (using JspException here feels ugly, but it's what EEM uses)
return ex.getMessage();
}
String response = current.validate(att, expr);
if (response == null)
return response;
else
return "tag = '" + elem + "' / attribute = '" + att + "': "
+ response;
|
static javax.servlet.jsp.tagext.ValidationMessage[] | vmFromString(java.lang.String message)
return new ValidationMessage[] {
new ValidationMessage(null, message)
};
|
static javax.servlet.jsp.tagext.ValidationMessage[] | vmFromVector(java.util.Vector v)
ValidationMessage[] vm = new ValidationMessage[v.size()];
for (int i = 0; i < vm.length; i++)
vm[i] = (ValidationMessage) v.get(i);
return vm;
|