# Class Driver

java.lang.Object
nu.validator.htmlparser.io.Driver

All Implemented Interfaces:
  `EncodingDeclarationHandler`

public class Driver extends Object implements EncodingDeclarationHandler

## Constructor Summary

Constructors
Constructor
Description
`Driver(Tokenizer tokenizer)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addCharacterHandler(CharacterHandler characterHandler)`
`void`
`dontSwallowBom()`
`protected Encoding`
`encodingFromExternalDeclaration(String encoding)`
Initializes a decoder from external decl.
`protected void`
`errorWithoutLocation(String message)`
Reports a warning without line/col
`String`
`getCharacterEncoding()`
Queries the environment for the encoding in use (for error reporting).
`Locator`
`getDocumentLocator()`
`boolean`
`internalEncodingDeclaration(String internalCharset)`
Indicates that the parser has found an internal encoding declaration with the charset value `charset`.
`boolean`
`isAllowRewinding()`
Returns the allowRewinding.
`boolean`
`isCheckingNormalization()`
Query if checking normalization.
`void`
`setAllowRewinding(boolean allowRewinding)`
Sets the allowRewinding.
`void`
`setCheckingNormalization(boolean enable)`
Turns NFC checking on or off.
`void`
`setCommentPolicy(XmlViolationPolicy commentPolicy)`
`void`
`setContentNonXmlCharPolicy(XmlViolationPolicy contentNonXmlCharPolicy)`
`void`
`setContentSpacePolicy(XmlViolationPolicy contentSpacePolicy)`
`void`
`setEncoding(Encoding encoding, Confidence confidence)`
`void`
`setErrorHandler(ErrorHandler eh)`
`void`
`setHeuristics(Heuristics heuristics)`
Sets the encoding sniffing heuristics.
`void`
`setMappingLangToXmlLang(boolean mappingLangToXmlLang)`
`void`
`setNamePolicy(XmlViolationPolicy namePolicy)`
`void`
`setTransitionHandler(TransitionHandler transitionHandler)`
`void`
`setXmlnsPolicy(XmlViolationPolicy xmlnsPolicy)`
`void`
`tokenize(InputSource is)`
Runs the tokenization.
`void`
`tokenize(InputSource is, int bufferSize)`
Runs the tokenization.
`protected Encoding`
`whineAboutEncodingAndReturnActual(String encoding, Encoding cs)`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Driver

public Driver(Tokenizer tokenizer)

## Method Details

### isAllowRewinding

public boolean isAllowRewinding()
Returns the allowRewinding.

Returns:
  the allowRewinding

### setAllowRewinding

public void setAllowRewinding(boolean allowRewinding)
Sets the allowRewinding.

Parameters:
  `allowRewinding` - the allowRewinding to set

### setCheckingNormalization

public void setCheckingNormalization(boolean enable)
Turns NFC checking on or off.

Parameters:
  `enable` - `true` if checking on

### addCharacterHandler

public void addCharacterHandler(CharacterHandler characterHandler)

### isCheckingNormalization

public boolean isCheckingNormalization()
Query if checking normalization.

Returns:
  `true` if checking on

### tokenize

public void tokenize(InputSource is) throws SAXException, IOException
Runs the tokenization. This is the main entry point.

Parameters:
  `is` - the input source
Throws:
  `SAXException` - on fatal error (if configured to treat XML violations as fatal) or if the token handler threw
  `IOException` - if the stream threw

### tokenize

public void tokenize(InputSource is, int bufferSize) throws SAXException, IOException
Runs the tokenization. This is the main entry point.

Parameters:
  `is` - the input source
  `bufferSize` - the size of the buffer to feed to the tokenizer
Throws:
  `SAXException` - on fatal error (if configured to treat XML violations as fatal) or if the token handler threw
  `IOException` - if the stream threw

### dontSwallowBom

public void dontSwallowBom()

### setEncoding

public void setEncoding(Encoding encoding, Confidence confidence)

### internalEncodingDeclaration

public boolean internalEncodingDeclaration(String internalCharset) throws SAXException
Description copied from interface: `EncodingDeclarationHandler`
Indicates that the parser has found an internal encoding declaration with the charset value `charset`.

Specified by:
  `internalEncodingDeclaration` in interface `EncodingDeclarationHandler`
Parameters:
  `internalCharset` - the charset name found.
Returns:
  `true` if the value of `charset` was an encoding name for a supported ASCII-superset encoding.
Throws:
  `SAXException` - if something went wrong

### setHeuristics

public void setHeuristics(Heuristics heuristics)
Sets the encoding sniffing heuristics.

Parameters:
  `heuristics` - the heuristics to set

### errorWithoutLocation

protected void errorWithoutLocation(String message) throws SAXException
Reports a warning without line/col

Parameters:
  `message` - the message
Throws:
  `SAXException`

### encodingFromExternalDeclaration

protected Encoding encodingFromExternalDeclaration(String encoding) throws SAXException
Initializes a decoder from external decl.

Throws:
  `SAXException`

### whineAboutEncodingAndReturnActual

protected Encoding whineAboutEncodingAndReturnActual(String encoding, Encoding cs) throws SAXException

Parameters:
  `encoding` -
  `cs` -
Returns:
Throws:
  `SAXException`

### setCommentPolicy

public void setCommentPolicy(XmlViolationPolicy commentPolicy)

Parameters:
  `commentPolicy` -
See Also:
  - `Tokenizer.setCommentPolicy(nu.validator.htmlparser.common.XmlViolationPolicy)`

### setContentNonXmlCharPolicy

public void setContentNonXmlCharPolicy(XmlViolationPolicy contentNonXmlCharPolicy)

Parameters:
  `contentNonXmlCharPolicy` -
See Also:
  - `Tokenizer.setContentNonXmlCharPolicy(nu.validator.htmlparser.common.XmlViolationPolicy)`

### setContentSpacePolicy

public void setContentSpacePolicy(XmlViolationPolicy contentSpacePolicy)

Parameters:
  `contentSpacePolicy` -
See Also:
  - `Tokenizer.setContentSpacePolicy(nu.validator.htmlparser.common.XmlViolationPolicy)`

### setErrorHandler

public void setErrorHandler(ErrorHandler eh)

Parameters:
  `eh` -
See Also:
  - `Tokenizer.setErrorHandler(org.xml.sax.ErrorHandler)`

### setTransitionHandler

public void setTransitionHandler(TransitionHandler transitionHandler)

### setMappingLangToXmlLang

public void setMappingLangToXmlLang(boolean mappingLangToXmlLang)

Parameters:
  `mappingLangToXmlLang` -
See Also:
  - `Tokenizer.setMappingLangToXmlLang(boolean)`

### setNamePolicy

public void setNamePolicy(XmlViolationPolicy namePolicy)

Parameters:
  `namePolicy` -
See Also:
  - `Tokenizer.setNamePolicy(nu.validator.htmlparser.common.XmlViolationPolicy)`

### setXmlnsPolicy

public void setXmlnsPolicy(XmlViolationPolicy xmlnsPolicy)

Parameters:
  `xmlnsPolicy` -
See Also:
  - `Tokenizer.setXmlnsPolicy(nu.validator.htmlparser.common.XmlViolationPolicy)`

### getCharacterEncoding

public String getCharacterEncoding() throws SAXException
Description copied from interface: `EncodingDeclarationHandler`
Queries the environment for the encoding in use (for error reporting).

Specified by:
  `getCharacterEncoding` in interface `EncodingDeclarationHandler`
Returns:
  the encoding in use
Throws:
  `SAXException` - if something went wrong

### getDocumentLocator

public Locator getDocumentLocator()