Overview | Package | Class | Tree | Deprecated | Index | Help
| oNVDL-20070517 API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.thaiopensource.validate
Class ValidationDriver

    java.lang.Object
      com.thaiopensource.validate.ValidationDriver

Direct Known Subclasses:
  ValidationEngine

public class ValidationDriver
extends java.lang.Object

Provides a simplified API for validating XML documents against schemas. This class is neither reentrant nor safe for access from multiple threads.

Constructor Summary
`ValidationDriver()` Equivalent to ValidationDriver(PropertyMap.EMPTY, PropertyMap.EMPTY, null).
`ValidationDriver(PropertyMap properties)` Equivalent to ValidationDriver(properties, properties, null).
`ValidationDriver(PropertyMap schemaProperties, PropertyMap instanceProperties)` Equivalent to ValidationDriver(schemaProperties, instanceProperties, null).
`ValidationDriver(PropertyMap schemaProperties, PropertyMap instanceProperties, SchemaReader schemaReader)` Creates and initializes a ValidationDriver.
`ValidationDriver(PropertyMap properties, SchemaReader sr)` Equivalent to ValidationDriver(properties, properties, sr).
`ValidationDriver(SchemaReader sr)` Equivalent to ValidationDriver(PropertyMap.EMPTY, PropertyMap.EMPTY, null).

Method Summary
`static org.xml.sax.InputSource` | `fileInputSource(java.io.File file)` Returns an `InputSource` for a `File`.
`static org.xml.sax.InputSource` | `fileInputSource(java.lang.String filename)` Returns an `InputSource` for a filename.
`boolean` | `loadSchema(org.xml.sax.InputSource in)` Loads a schema.
`static org.xml.sax.InputSource` | `uriOrFileInputSource(java.lang.String uriOrFile)` Returns an `InputSource` for a string that represents either a file or an absolute URI.
`boolean` | `validate(org.xml.sax.InputSource in)` Validates a document against the currently loaded schema.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ValidationDriver

    public ValidationDriver(PropertyMap schemaProperties,
                            PropertyMap instanceProperties,
                            SchemaReader schemaReader)

  Creates and initializes a ValidationDriver.

Parameters:
  `schemaProperties` - a PropertyMap specifying properties controlling schema creation; must not be `null`
  `instanceProperties` - a PropertyMap specifying properties controlling validation; must not be `null`
  `schemaReader` - the SchemaReader to use; if this is `null`, then the schema must be in XML, and the namespace URI of the root element will be used to determine what the schema language is

### ValidationDriver

    public ValidationDriver(PropertyMap schemaProperties,
                            PropertyMap instanceProperties)

  Equivalent to ValidationDriver(schemaProperties, instanceProperties, null).

See Also:
  `ValidationDriver(PropertyMap,PropertyMap,SchemaReader)`

### ValidationDriver

    public ValidationDriver(PropertyMap properties,
                            SchemaReader sr)

  Equivalent to ValidationDriver(properties, properties, sr).

See Also:
  `ValidationDriver(PropertyMap,PropertyMap,SchemaReader)`

### ValidationDriver

    public ValidationDriver(PropertyMap properties)

  Equivalent to ValidationDriver(properties, properties, null).

See Also:
  `ValidationDriver(PropertyMap,PropertyMap,SchemaReader)`

### ValidationDriver

    public ValidationDriver(SchemaReader sr)

  Equivalent to ValidationDriver(PropertyMap.EMPTY, PropertyMap.EMPTY, null).

See Also:
  `ValidationDriver(PropertyMap,PropertyMap,SchemaReader)`

### ValidationDriver

    public ValidationDriver()

  Equivalent to ValidationDriver(PropertyMap.EMPTY, PropertyMap.EMPTY, null).

See Also:
  `ValidationDriver(PropertyMap,PropertyMap,SchemaReader)`

Method Detail

### loadSchema

    public boolean loadSchema(org.xml.sax.InputSource in)
                       throws org.xml.sax.SAXException,
                              java.io.IOException

  Loads a schema. Subsequent calls to `validate` will validate with respect the loaded schema. This can be called more than once to allow multiple documents to be validated against different schemas.

  Parameters:
    `in` - the InputSource for the schema
  Returns:
    `true` if the schema was loaded successfully; `false` otherwise
  Throws:
    `java.io.IOException` - if an I/O error occurred
    `org.xml.sax.SAXException` - if an XMLReader or ErrorHandler threw a SAXException

### validate

    public boolean validate(org.xml.sax.InputSource in)
                     throws org.xml.sax.SAXException,
                            java.io.IOException

  Validates a document against the currently loaded schema. This can be called multiple times in order to validate multiple documents.

  Parameters:
    `in` - the InputSource for the document to be validated
  Returns:
    `true` if the document is valid; `false` otherwise
  Throws:
    `java.lang.IllegalStateException` - if there is no currently loaded schema
    `java.io.IOException` - if an I/O error occurred
    `org.xml.sax.SAXException` - if an XMLReader or ErrorHandler threw a SAXException

### fileInputSource

    public static org.xml.sax.InputSource fileInputSource(java.lang.String filename)
                                                   throws java.net.MalformedURLException

  Returns an `InputSource` for a filename.

  Parameters:
    `filename` - a String specifying the filename
  Returns:
    an `InputSource` for the filename
  Throws:
    `java.net.MalformedURLException`

### fileInputSource

    public static org.xml.sax.InputSource fileInputSource(java.io.File file)
                                                   throws java.net.MalformedURLException

  Returns an `InputSource` for a `File`.

  Parameters:
    `file` - the `File`
  Returns:
    an `InputSource` for the filename
  Throws:
    `java.net.MalformedURLException`

### uriOrFileInputSource

    public static org.xml.sax.InputSource uriOrFileInputSource(java.lang.String uriOrFile)
                                                        throws java.net.MalformedURLException

  Returns an `InputSource` for a string that represents either a file or an absolute URI. If the string looks like an absolute URI, it will be treated as an absolute URI, otherwise it will be treated as a filename.

  Parameters:
    `uriOrFile` - a `String` representing either a file or an absolute URI
  Returns:
    an `InputSource` for the file or absolute URI
  Throws:
    `java.net.MalformedURLException`

Overview | Package | Class | Tree | Deprecated | Index | Help
| oNVDL-20070517 API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

© Copyright SyncRO Soft SRL 2006-2007.