All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.mitre.cvw.mcp.Parser

java.lang.Object
   |
   +----org.mitre.cvw.mcp.Parser

public class Parser
extends Object
A Parser for MOO Client Protocol Version 2.1.

An instance of the Parser class parses MOO Client Protocol messages. Each line of text that starts with '#$#' should be given to the parser. If the line completes the parse of an MCP message, an internal representation of the message is returned. A null is returns when a line does not complete a parse. In this parser, erroneous syntax causes messages to be dropped messages.

This parser supports mulitline value length hints. A key-value pair will be sent using more than one line if the key ends in '*:'. The standard does not specify any use for the value part of this pair. If this parser finds the value parses as a nonnegative number, it uses that number as an estimate of the number of lines that make up the value.

The syntax recognized by the parser follows. The material has been taken from a draft of the MCP 2.1 Definition.

The following is a somewhat extended BNF grammar for the MCP message format; the extensions in this BNF are taken from regular expression syntax. Specifically, we write OBJECT* to mean "0 or more occurrences of OBJECT", for OBJECT any terminal symbol or nonterminal; similarly, OBJECT+ should be taken to mean "one or more occurrences of OBJECT". Terminals in this BNF are quoted (i.e. '#$#'), and nonterminals appear in angle-brackets (i.e. <message>). The terminal strings '*' and '+' are thus distinct from the metacharacters * and +. The special (unquoted) terminal EOL represents an end-of-line, usually a carriage return and newline.

 <message-line> := '#$#' <message> EOL
 <message> := <message-start>
            | <message-continue>
            | <message-end>
 <message-start> := <message-name> <space> [<auth-key> <space>] <keyval>*
 <message-continue> := '*' <space> <datatag> <space> <simple-key> ' ' <line>
 <message-end> := ':' <space> <datatag>
 <message-name> := <ident>
 <auth-key> := <unquote-string>
 <datatag> := <unquoted-string>
 <keyval> := <key> <space> <value>
 <key> := <simple-key> | <multiline-key>
 <simple-key> := <ident> ':'
 <multiline-key> := <ident> '*' ':'
 <value> := <unquoted-string> | <quoted-string>
 <ident> := <alpha> <ident-chars>
 <unquoted-string> := <simple-char>+
 <quoted-string> := '"' <string-chars> '"'
 <line> := any number of characters, but no newlines.
 <ident-chars> := '' | <ident-char> <ident-chars>
 <string-chars> := '' | <string-char> <string-chars>
 <space> := ' '+
 <ident-char> := <alpha> | <digit> | '-' 
 <string-char> := <simple-char> | <space> | '\"' | '\\'
         | ':' | '*'
 <simple-char> := <alpha> | <digit> | <other-simple>
 <other-simple> := '-' | '~' | '`' | '!' | '@' | '#' | '$' | '%' | '^'
         | '&' | '(' | ')' | '=' | '+' | '{' | '}' | '[' | ']' | '|'
         | ''' | ';' | '?' | '/' | '>' | '<' | '.' | ','
 <digit> := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
 <alpha> := 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j'
          | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't'
          | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'
          | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J'
          | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T'
          | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '_'


Constructor Index

 o Parser()

Method Index

 o main(String[])
An entry point for testing the MCP parser.
 o parseMessageLine(String)
Parse a message line.

Constructors

 o Parser
 public Parser()

Methods

 o parseMessageLine
 public synchronized Message parseMessageLine(String str)
Parse a message line.

Parameters:
str - the message line
Returns:
an MCP message if the line completes a parse, otherwise null
 o main
 public static void main(String args[])
An entry point for testing the MCP parser.


All Packages  Class Hierarchy  This Package  Previous  Next  Index