org.jvoicexml.interpreter.grammar.identifier
Class SrgsAbnfGrammarIdentifier

java.lang.Object
  extended by org.jvoicexml.interpreter.grammar.identifier.SrgsAbnfGrammarIdentifier
All Implemented Interfaces:
GrammarIdentifier

public final class SrgsAbnfGrammarIdentifier
extends Object
implements GrammarIdentifier

This class implements the GrammarIdentifier interface. An instance of this class is able to identify a SRGS grammar with ABNF format. The mime type of the accepted grammar is application/srgs.

Version:
$Revision: 216 $

Copyright © 2005-2007 JVoiceXML group - http://jvoicexml.sourceforge.net/

Author:
Christoph Buente, Dirk Schnelle

Constructor Summary
SrgsAbnfGrammarIdentifier()
           
 
Method Summary
 GrammarType getSupportedType()
          Returns the supported media type.
 GrammarType identify(GrammarDocument grammar)
          Identifies the grammar specified by grammar. These are the rules for a valid ABDF Header: The ABNF self-identifying header must be present in any legal stand-alone ABNF Form grammar document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SrgsAbnfGrammarIdentifier

public SrgsAbnfGrammarIdentifier()
Method Detail

identify

public GrammarType identify(GrammarDocument grammar)
Identifies the grammar specified by grammar. If grammar could be identified a type is returned, otherwise null. These are the rules for a valid ABDF Header:

The ABNF self-identifying header must be present in any legal stand-alone ABNF Form grammar document.

The first character of an ABNF document must be the "#" symbol (x23) unless preceded by an optional XML 1.0 byte order mark [XML Paragraph 4.3.3]. The ABNF byte order mark follows the XML definition and requirements. For example, documents encoded in UTF-16 must begin with the byte order mark.

The optional byte order mark and required "#" symbol must be followed immediately by the exact string "ABNF" (x41 x42 x4d x46) or the appropriate equivalent for the document's encoding (e.g. for UTF-16 little-endian: x23 x00 x41 x00 x42 x00 x4d x00 x46 x00). If the byte order mark is absent on a grammar encoded in UTF-16 then the grammar processor should perform auto-detection of character encoding in a manner analogous to auto-detection of character encoding in XML [XML Appendix F].

Next follows a single space character (x20) and the required version number which is "1.0" for this specification (x31 x2e x30).

Next follows an optional character encoding. Section 4.4 defines character encodings in more detail. If present, there must be a single space character (x20) between the version number and the character encoding.

The self-identifying header is finalized with a semicolon (x3b) followed immediately by a newline. The semicolon must be the first character following the version number or the character encoding if is present.

Specified by:
identify in interface GrammarIdentifier
Parameters:
grammar - The grammar to be identified.
Returns:
String the type of the grammar. If grammar could not be identified, null is returned.

getSupportedType

public GrammarType getSupportedType()
Returns the supported media type.

Specified by:
getSupportedType in interface GrammarIdentifier
Returns:
the supported media type.


Copyright © 2005-2007 JVoiceXML group.