com.sas.taglib.util.validators
Class CoreTagLibraryValidator

com.sas.taglib.util.validators.CoreTagLibraryValidator

public class CoreTagLibraryValidator

Translation-time validator class for a JSP page using the SAS core tag library. Validation is based on information built from the CustomTagDoclet tags which are put inside the tag handler classes. Default validation mainly includes checking the subtags for proper usage. A reference to this class must be set in the tld file to be recognized by the servlet container. For example:


 <validator>
  <validator-class>com.sas.taglib.util.validators.CoreTagLibraryValidator</validator-class>
 </validator>
 

To run custom validation on a tag, you must specify a tag validator class which implements com.sas.taglib.util.ValidationInterface. You must also specify this class in the tag handler using the "tagvalidatorclass" doclet tag. To allow a tag to contain any subtag, you must inlclude the "allowall" doclet tag in the tag handler class.

See Also:
ValidationInterface

Field Summary
protected  java.util.ArrayList messageList
          Array list of type ValidationMessage for return of validate method.
static java.lang.String RB_KEY
          Static key for referencing the Internationalization Strings for this class
protected  org.w3c.dom.Document subtagXML
          The Document class representation of the valid subtags.
protected  java.lang.String subtagXMLFile
          The xml file listing the valid subtags of all tags in this library.
 
Constructor Summary
CoreTagLibraryValidator()
          Default Constructor.
 
Method Summary
 boolean isValidSubtag(org.w3c.dom.Element tag, java.lang.String subtag, java.util.HashSet multipleSet)
          Checks if the subtag is a valid subtag of the tag.
 javax.servlet.jsp.tagext.ValidationMessage[] validate(java.lang.String prefix, java.lang.String uri, javax.servlet.jsp.tagext.PageData pageData)
          Overrides the TagLibraryValidator validate method to validate a JSP page.
 void validateNode(java.lang.String prefix, java.lang.String uri, org.w3c.dom.Node node)
          Validates a single node in the JSP page by calling any custom tag validation classes which implement the ValidationInterface.
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
Static key for referencing the Internationalization Strings for this class

See Also:
Constant Field Values

subtagXML

protected org.w3c.dom.Document subtagXML
The Document class representation of the valid subtags.


subtagXMLFile

protected java.lang.String subtagXMLFile
The xml file listing the valid subtags of all tags in this library. Created in the build process.


messageList

protected java.util.ArrayList messageList
Array list of type ValidationMessage for return of validate method.

Constructor Detail

CoreTagLibraryValidator

public CoreTagLibraryValidator()
Default Constructor.

Method Detail

validate

public javax.servlet.jsp.tagext.ValidationMessage[] validate(java.lang.String prefix,
                                                             java.lang.String uri,
                                                             javax.servlet.jsp.tagext.PageData pageData)
Overrides the TagLibraryValidator validate method to validate a JSP page. This will get invoked once per directive in the JSP page. This method will return null if the page is valid; otherwise the method should return an array of ValidationMessage objects. An array of length zero is also interpreted as no errors.

Overrides:
validate in class javax.servlet.jsp.tagext.TagLibraryValidator
Parameters:
prefix - The tag prefix used for this tag in the current page.
uri - The uri associated with the tag and prefix.
node - The Node object which contains all the xml document information.
Returns:
An array of ValidationMessages. These are the errors which occured on the current JSP page.

validateNode

public void validateNode(java.lang.String prefix,
                         java.lang.String uri,
                         org.w3c.dom.Node node)
Validates a single node in the JSP page by calling any custom tag validation classes which implement the ValidationInterface. Recursively checks the subtags of this Node for validity.

Parameters:
prefix - The tag prefix used for this tag in the current page.
uri - The uri associated with the tag and prefix.
node - The Node object which contains all the xml document information.

isValidSubtag

public boolean isValidSubtag(org.w3c.dom.Element tag,
                             java.lang.String subtag,
                             java.util.HashSet multipleSet)
Checks if the subtag is a valid subtag of the tag.

Parameters:
tag - The Element in the validation xml file.
subtag - The name of the subtag to check against this tag.
multipleSet - The HashSet used to validate subtags that are only allowed once.
Returns:
true if valid



Copyright © 2009 SAS Institute Inc. All Rights Reserved.