nu.validator.servlet
Class VerifierServletTransaction

java.lang.Object
  extended by nu.validator.servlet.VerifierServletTransaction
All Implemented Interfaces:
DocumentModeHandler
Direct Known Subclasses:
Html5ConformanceCheckerTransaction

 class VerifierServletTransaction
extends Object
implements DocumentModeHandler

Version:
$Id: VerifierServletTransaction.java,v 1.10 2005/07/24 07:32:48 hsivonen Exp $
Author:
hsivonen

Nested Class Summary
private static class VerifierServletTransaction.OutputFormat
           
 
Field Summary
private static String[] ALL_CHECKERS
           
private static String[] ALL_CHECKERS_HTML4
           
private  AttributesImpl attrs
           
private  BufferingRootNamespaceSniffer bufferingRootNamespaceSniffer
           
private  boolean checkNormalization
           
protected  ContentHandler contentHandler
           
private  String contentType
           
protected  ContentTypeParser contentTypeParser
           
protected  String document
           
protected  TypedInputSource documentInput
           
protected  XhtmlSaxEmitter emitter
           
protected  LocalCacheEntityResolver entityResolver
           
protected  MessageEmitterAdapter errorHandler
           
private static char[] FOR
           
protected static int HTML5_SCHEMA
           
protected  HtmlParser htmlParser
           
protected  PrudentHttpEntityResolver httpRes
           
private  com.hp.hpl.jena.iri.IRIFactory iriFactory
           
private  PropertyMap jingPropertyMap
           
private static Pattern JS_IDENTIFIER
           
private static String[] JS_RESERVED_WORDS
           
private static String[] KNOWN_CONTENT_TYPES
           
private static long lastModified
           
private  boolean laxType
           
private  Set<String> loadedValidatorUrls
           
private static org.apache.log4j.Logger log4j
           
private  boolean methodIsGet
           
private static String[] NAMESPACES_FOR_KNOWN_CONTENT_TYPES
           
private  OutputStream out
           
private  VerifierServletTransaction.OutputFormat outputFormat
           
private  ParserMode parser
           
private static Map pathMap
           
private  String postContentType
           
private static Schema[] preloadedSchemas
           
private static String[] preloadedSchemaUrls
           
private static int[] presetDoctypes
           
private static String[] presetLabels
           
private static String[] presetNamespaces
           
private static String[] presetUrls
           
protected  XMLReader reader
           
private  HttpServletRequest request
           
private  HttpServletResponse response
           
private static char[] RESULTS_TITLE
           
private  boolean rootNamespaceSeen
           
private  String schemaUrls
           
private static char[] SERVICE_TITLE
           
private  boolean showSource
           
private  SourceCode sourceCode
           
private static Pattern SPACE
           
private  long start
           
private static char[] TWO_POINT_OH_BETA
           
protected  Validator validator
           
protected static int XHTML1STRICT_SCHEMA
           
protected static int XHTML1TRANSITIONAL_SCHEMA
           
protected static int XHTML5_SCHEMA
           
protected  SAXDriver xmlParser
           
 
Constructor Summary
VerifierServletTransaction(HttpServletRequest request, HttpServletResponse response)
           
 
Method Summary
private  Validator combineValidatorByUrl(Validator validator, String url)
           
 void documentMode(DocumentMode mode, String publicIdentifier, String systemIdentifier, boolean html4SpecificAdditionalErrorChecks)
           
(package private)  void emitDocDuration()
           
(package private)  void emitDocField()
           
(package private)  void emitForm()
           
protected  void emitFormContent()
           
(package private)  void emitLaxTypeField()
           
(package private)  void emitParserOptions()
           
(package private)  void emitPresetOptions()
           
(package private)  void emitSchemaDuration()
           
(package private)  void emitSchemaField()
           
(package private)  void emitShowSourceField()
           
(package private)  void emitTitle(boolean markupAllowed)
           
(package private)  void emitTotalDuration()
           
protected  String failureMessage()
           
private static boolean isCheckerUrl(String url)
           
private  boolean isHtmlUnsafePreset()
           
protected  void loadDocAndSetupParser()
           
protected  void loadDocumentInput()
           
protected  void newHtmlParser()
           
(package private)  void rootNamespace(String namespace, Locator locator)
           
private  Schema schemaByUrl(String url)
           
private static Schema schemaByUrl(String url, EntityResolver resolver, PropertyMap pMap)
           
protected static String scrub(String s)
           
private  String scrubUrl(String urlStr)
           
(package private)  void service()
           
protected  void setAcceptAllKnownXmlTypes(boolean acceptAllKnownXmlTypes)
           
protected  void setAllowGenericXml(boolean allowGenericXml)
           
protected  void setAllowHtml(boolean allowHtml)
           
protected  void setAllowRnc(boolean allowRnc)
           
protected  void setAllowXhtml(boolean allowXhtml)
           
protected  void setup()
           
protected  void setupXmlParser()
           
protected  String successMessage()
           
protected  void tryToSetupValidator()
           
(package private)  void validate()
           
protected  Validator validatorByDoctype(int schemaId)
           
private  Validator validatorByUrl(String url)
           
private  Validator validatorByUrls(String schemaList)
           
protected  boolean willValidate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log4j

private static final org.apache.log4j.Logger log4j

SPACE

private static final Pattern SPACE

JS_IDENTIFIER

private static final Pattern JS_IDENTIFIER

JS_RESERVED_WORDS

private static final String[] JS_RESERVED_WORDS

HTML5_SCHEMA

protected static final int HTML5_SCHEMA
See Also:
Constant Field Values

XHTML1STRICT_SCHEMA

protected static final int XHTML1STRICT_SCHEMA
See Also:
Constant Field Values

XHTML1TRANSITIONAL_SCHEMA

protected static final int XHTML1TRANSITIONAL_SCHEMA
See Also:
Constant Field Values

XHTML5_SCHEMA

protected static final int XHTML5_SCHEMA
See Also:
Constant Field Values

SERVICE_TITLE

private static final char[] SERVICE_TITLE

TWO_POINT_OH_BETA

private static final char[] TWO_POINT_OH_BETA

RESULTS_TITLE

private static final char[] RESULTS_TITLE

FOR

private static final char[] FOR

pathMap

private static final Map pathMap

presetDoctypes

private static int[] presetDoctypes

presetLabels

private static String[] presetLabels

presetUrls

private static String[] presetUrls

presetNamespaces

private static String[] presetNamespaces

KNOWN_CONTENT_TYPES

private static final String[] KNOWN_CONTENT_TYPES

NAMESPACES_FOR_KNOWN_CONTENT_TYPES

private static final String[] NAMESPACES_FOR_KNOWN_CONTENT_TYPES

ALL_CHECKERS

private static final String[] ALL_CHECKERS

ALL_CHECKERS_HTML4

private static final String[] ALL_CHECKERS_HTML4

start

private long start

request

private final HttpServletRequest request

response

private final HttpServletResponse response

iriFactory

private com.hp.hpl.jena.iri.IRIFactory iriFactory

document

protected String document

parser

private ParserMode parser

laxType

private boolean laxType

contentHandler

protected ContentHandler contentHandler

emitter

protected XhtmlSaxEmitter emitter

errorHandler

protected MessageEmitterAdapter errorHandler

attrs

private AttributesImpl attrs

out

private OutputStream out

jingPropertyMap

private PropertyMap jingPropertyMap

entityResolver

protected LocalCacheEntityResolver entityResolver

lastModified

private static long lastModified

preloadedSchemaUrls

private static String[] preloadedSchemaUrls

preloadedSchemas

private static Schema[] preloadedSchemas

schemaUrls

private String schemaUrls

validator

protected Validator validator

bufferingRootNamespaceSniffer

private BufferingRootNamespaceSniffer bufferingRootNamespaceSniffer

contentType

private String contentType

htmlParser

protected HtmlParser htmlParser

xmlParser

protected SAXDriver xmlParser

reader

protected XMLReader reader

documentInput

protected TypedInputSource documentInput

httpRes

protected PrudentHttpEntityResolver httpRes

contentTypeParser

protected ContentTypeParser contentTypeParser

loadedValidatorUrls

private Set<String> loadedValidatorUrls

checkNormalization

private boolean checkNormalization

rootNamespaceSeen

private boolean rootNamespaceSeen

outputFormat

private VerifierServletTransaction.OutputFormat outputFormat

postContentType

private String postContentType

methodIsGet

private boolean methodIsGet

sourceCode

private SourceCode sourceCode

showSource

private boolean showSource
Constructor Detail

VerifierServletTransaction

VerifierServletTransaction(HttpServletRequest request,
                           HttpServletResponse response)
Parameters:
request -
response -
Method Detail

scrub

protected static String scrub(String s)

isCheckerUrl

private static boolean isCheckerUrl(String url)

willValidate

protected boolean willValidate()

service

void service()
       throws ServletException,
              IOException
Throws:
ServletException
IOException

setup

protected void setup()
              throws ServletException
Throws:
ServletException

isHtmlUnsafePreset

private boolean isHtmlUnsafePreset()

validate

void validate()
        throws SAXException
Throws:
SAXException

successMessage

protected String successMessage()
                         throws SAXException
Returns:
Throws:
SAXException

failureMessage

protected String failureMessage()
                         throws SAXException
Throws:
SAXException

tryToSetupValidator

protected void tryToSetupValidator()
                            throws SAXException,
                                   IOException,
                                   IncorrectSchemaException
Throws:
SAXException
IOException
IncorrectSchemaException

loadDocAndSetupParser

protected void loadDocAndSetupParser()
                              throws SAXException,
                                     IOException,
                                     IncorrectSchemaException,
                                     SAXNotRecognizedException,
                                     SAXNotSupportedException
Throws:
SAXException
IOException
IncorrectSchemaException
SAXNotRecognizedException
SAXNotSupportedException

newHtmlParser

protected void newHtmlParser()

validatorByDoctype

protected Validator validatorByDoctype(int schemaId)
                                throws SAXException,
                                       IOException,
                                       IncorrectSchemaException
Throws:
SAXException
IOException
IncorrectSchemaException

setupXmlParser

protected void setupXmlParser()
                       throws SAXNotRecognizedException,
                              SAXNotSupportedException
Parameters:
entityResolver2 -
Throws:
SAXNotRecognizedException
SAXNotSupportedException

validatorByUrls

private Validator validatorByUrls(String schemaList)
                           throws SAXException,
                                  IOException,
                                  IncorrectSchemaException
Parameters:
validator -
Returns:
Throws:
SAXException
IOException
IncorrectSchemaException

combineValidatorByUrl

private Validator combineValidatorByUrl(Validator validator,
                                        String url)
                                 throws SAXException,
                                        IOException,
                                        IncorrectSchemaException
Parameters:
validator -
url -
Returns:
Throws:
SAXException
IOException
IncorrectSchemaException

validatorByUrl

private Validator validatorByUrl(String url)
                          throws SAXException,
                                 IOException,
                                 IncorrectSchemaException
Parameters:
url -
Returns:
Throws:
SAXException
IOException
IncorrectSchemaException

schemaByUrl

private Schema schemaByUrl(String url)
                    throws SAXException,
                           IOException,
                           IncorrectSchemaException
Parameters:
url -
Returns:
Throws:
SAXException
IOException
IncorrectSchemaException

schemaByUrl

private static Schema schemaByUrl(String url,
                                  EntityResolver resolver,
                                  PropertyMap pMap)
                           throws SAXException,
                                  IOException,
                                  IncorrectSchemaException
Parameters:
url -
Returns:
Throws:
SAXException
IOException
IncorrectSchemaException

emitTitle

void emitTitle(boolean markupAllowed)
         throws SAXException
Throws:
SAXException

emitForm

void emitForm()
        throws SAXException
Throws:
SAXException

emitFormContent

protected void emitFormContent()
                        throws SAXException
Throws:
SAXException

emitSchemaField

void emitSchemaField()
               throws SAXException
Throws:
SAXException

emitDocField

void emitDocField()
            throws SAXException
Throws:
SAXException

scrubUrl

private String scrubUrl(String urlStr)

emitSchemaDuration

void emitSchemaDuration()
                  throws SAXException
Throws:
SAXException

emitDocDuration

void emitDocDuration()
               throws SAXException
Throws:
SAXException

emitTotalDuration

void emitTotalDuration()
                 throws SAXException
Throws:
SAXException

emitPresetOptions

void emitPresetOptions()
                 throws SAXException
Throws:
SAXException

emitParserOptions

void emitParserOptions()
                 throws SAXException
Throws:
SAXException

emitLaxTypeField

void emitLaxTypeField()
                throws SAXException
Throws:
SAXException

emitShowSourceField

void emitShowSourceField()
                   throws SAXException
Throws:
SAXException

rootNamespace

void rootNamespace(String namespace,
                   Locator locator)
             throws SAXException
Throws:
SAXException

documentMode

public void documentMode(DocumentMode mode,
                         String publicIdentifier,
                         String systemIdentifier,
                         boolean html4SpecificAdditionalErrorChecks)
                  throws SAXException
Specified by:
documentMode in interface DocumentModeHandler
Throws:
SAXException

setAcceptAllKnownXmlTypes

protected void setAcceptAllKnownXmlTypes(boolean acceptAllKnownXmlTypes)
Parameters:
acceptAllKnownXmlTypes -
See Also:
ContentTypeParser.setAcceptAllKnownXmlTypes(boolean)

setAllowGenericXml

protected void setAllowGenericXml(boolean allowGenericXml)
Parameters:
allowGenericXml -
See Also:
ContentTypeParser.setAllowGenericXml(boolean)

setAllowHtml

protected void setAllowHtml(boolean allowHtml)
Parameters:
allowHtml -
See Also:
ContentTypeParser.setAllowHtml(boolean)

setAllowRnc

protected void setAllowRnc(boolean allowRnc)
Parameters:
allowRnc -
See Also:
ContentTypeParser.setAllowRnc(boolean)

setAllowXhtml

protected void setAllowXhtml(boolean allowXhtml)
Parameters:
allowXhtml -
See Also:
ContentTypeParser.setAllowXhtml(boolean)

loadDocumentInput

protected void loadDocumentInput()
                          throws SAXException,
                                 IOException
Throws:
SAXException
IOException