org.patterncoder.source
Class PatternFileValidator

java.lang.Object
  extended by org.patterncoder.source.PatternFileValidator

public class PatternFileValidator
extends java.lang.Object

The PatternFileValidator class is used to validate each of the xml source files against a xmlSchema. If a source file does not get validated, it will not be included.


Constructor Summary
PatternFileValidator()
          Creates a new instance of PatternFileValidator, and compiles the validating schema.
 
Method Summary
static javax.xml.validation.Schema compileSchema(java.io.File schemaFile)
          Compiles the schema file specified.
static javax.xml.validation.Schema compileSchema(java.lang.String schema)
          Compiles the schema file specified.
 void validateFile(java.io.File sourceFile)
          Validates a source file against the compiled schema.Exceptions are thrown if the validation is Unsuccessful.
 void validateFile(java.lang.String sourceFileName)
          Validates a source file against the compiled schema.Exceptions are thrown if the validation is Unsuccessful.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatternFileValidator

public PatternFileValidator()
                     throws org.xml.sax.SAXException
Creates a new instance of PatternFileValidator, and compiles the validating schema.

Throws:
org.xml.sax.SAXException - A SAXException is thrown if the schema file cannot be found, or there is aproblem during comilation of the schema.
Method Detail

compileSchema

public static javax.xml.validation.Schema compileSchema(java.lang.String schema)
                                                 throws org.xml.sax.SAXException
Compiles the schema file specified.

Parameters:
schema - The schema file to be comiled.
Returns:
A compiled schema, which can be used in validating.
Throws:
org.xml.sax.SAXException - Throws a SAXException if compilation of the schema fails.

compileSchema

public static javax.xml.validation.Schema compileSchema(java.io.File schemaFile)
                                                 throws org.xml.sax.SAXException
Compiles the schema file specified.

Parameters:
schemaFile - The schema file to be comiled.
Returns:
A compiled schema, which can be used in validating.
Throws:
org.xml.sax.SAXException - Throws a SAXException if compilation of the schema fails.

validateFile

public void validateFile(java.lang.String sourceFileName)
                  throws org.xml.sax.SAXException,
                         java.io.IOException
Validates a source file against the compiled schema.Exceptions are thrown if the validation is Unsuccessful.

Parameters:
sourceFileName - The source file to be validated.
Throws:
org.xml.sax.SAXException - Thrown if the source file cannot be validated against the schema.
java.io.IOException - Thrown if the source file cannot be read or found for any reason.

validateFile

public void validateFile(java.io.File sourceFile)
                  throws org.xml.sax.SAXException,
                         java.io.IOException
Validates a source file against the compiled schema.Exceptions are thrown if the validation is Unsuccessful.

Parameters:
sourceFile - The source file to be validated.
Throws:
org.xml.sax.SAXException - Thrown if the source file cannot be validated against the schema.
java.io.IOException - Thrown if the source file cannot be read or found for any reason.