Build 1.0_r1(from source)

android.syncml.pim
Class VParser

java.lang.Object
  extended by android.syncml.pim.VParser
Direct Known Subclasses:
VCalParser_V10, VCardParser_V21

public abstract class VParser
extends Object

This interface is used to parse the V format files, such as VCard & VCal


Field Summary
protected  String mBuffer
          The buffer used to store input stream
protected  VBuilder mBuilder
          The builder to build parsed data
protected  String mDefaultEncoding
           
protected  String mEncoding
          The encoding type
protected  int PARSE_ERROR
           
 
Constructor Summary
VParser()
           
 
Method Summary
protected  String getWord(int offset)
          Get a word from current position.
protected  boolean isLetter(char ch)
          If it is a letter.
protected  boolean isLetterOrDigit(char ch)
          If it is a letter or digit.
protected  boolean isPrintable(char ch)
          If it is printable in ASCII
 boolean parse(InputStream is, String encoding, VBuilder builder)
          Parse the given stream
protected  int parse8bit(int offset)
          Refer to RFC 1521, 8bit text
protected  int parseBase64(int offset)
          Refer to RFC 1521, base64 text The end of the text is marked with two CRLF sequences
protected  int parseCharsetVal(int offset)
          Refer to RFC1521, section 7.1
If is: "us-ascii" / "iso-8859-xxx" / "X-" word
protected  int parseCrlf(int offset)
          If offset reach '\r\n' return 2.
protected  int parseLangVal(int offset)
          Refer to RFC 1766
like: XXX(sequence letters)-XXX(sequence letters)
protected  int parseOctet(int offset)
          start with "=" two of (DIGIT / "A" / "B" / "C" / "D" / "E" / "F")
So maybe return 3.
protected  int parsePEncodingVal(int offset)
          If is: "7BIT" / "8BIT" / "QUOTED-PRINTABLE" / "BASE64" / "X-" word and set mEncoding.
protected  int parsePtext(int offset)
          return 1 or 3
protected  int parsePValueVal(int offset)
          If is: "INLINE" / "URL" / "CONTENT-ID" / "CID" / "X-" word
protected  int parseQuotedPrintable(int offset)
          Refer to RFC 1521, quoted printable text ([*(ptext / SPACE / TAB) ptext] ["="] CRLF)
protected  int parseString(int offset, String tar, boolean ignoreCase)
          To determine if the given string equals to the start of the current string.
protected  int parseTag(int offset)
          From first 8 position, is sequence LETTER.
protected  int parseValue(int offset)
          From offset, parse as :mEncoding ?= 7bit / 8bit / quoted-printable / base64
protected abstract  int parseVFile(int offset)
          abstract function, waiting implement.
analyse from offset, return the length of consumed property.
protected  int parseWord(int offset)
          Any printable ASCII sequence except [ ]=:.,;
protected  int parseWsls(int offset)
          From offset, jump ' ', '\t', '\r\n' sequence, return the length of jump.
1 * (SPACE / HTAB / CRLF)
protected  int parseXWord(int offset)
          "X-" word, and its value.
protected  int removeWs(int offset)
          Skip the white space in string.
protected  void setInputStream(InputStream is, String encoding)
          Copy the content of input stream and filter the "folding"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mBuffer

protected String mBuffer
The buffer used to store input stream


mBuilder

protected VBuilder mBuilder
The builder to build parsed data


mEncoding

protected String mEncoding
The encoding type


PARSE_ERROR

protected final int PARSE_ERROR
See Also:
Constant Field Values

mDefaultEncoding

protected final String mDefaultEncoding
See Also:
Constant Field Values
Constructor Detail

VParser

public VParser()
Method Detail

parseCrlf

protected int parseCrlf(int offset)
If offset reach '\r\n' return 2. Else return PARSE_ERROR.


parse

public boolean parse(InputStream is,
                     String encoding,
                     VBuilder builder)
              throws IOException
Parse the given stream

Parameters:
is - The source to parse.
encoding - The encoding type.
builder - The v builder which used to construct data.
Returns:
Return true for success, otherwise false.
Throws:
IOException

setInputStream

protected void setInputStream(InputStream is,
                              String encoding)
                       throws UnsupportedEncodingException
Copy the content of input stream and filter the "folding"

Throws:
UnsupportedEncodingException

parseVFile

protected abstract int parseVFile(int offset)
abstract function, waiting implement.
analyse from offset, return the length of consumed property.


parseWsls

protected int parseWsls(int offset)
From offset, jump ' ', '\t', '\r\n' sequence, return the length of jump.
1 * (SPACE / HTAB / CRLF)


parseString

protected int parseString(int offset,
                          String tar,
                          boolean ignoreCase)
To determine if the given string equals to the start of the current string.

Parameters:
offset - The offset in buffer of current string
tar - The given string.
ignoreCase - To determine case sensitive or not.
Returns:
The consumed characters, otherwise return PARSE_ERROR.

removeWs

protected int removeWs(int offset)
Skip the white space in string.


parseXWord

protected int parseXWord(int offset)
"X-" word, and its value. Return consumed length.


parseValue

protected int parseValue(int offset)
From offset, parse as :mEncoding ?= 7bit / 8bit / quoted-printable / base64


parse8bit

protected int parse8bit(int offset)
Refer to RFC 1521, 8bit text


parseQuotedPrintable

protected int parseQuotedPrintable(int offset)
Refer to RFC 1521, quoted printable text ([*(ptext / SPACE / TAB) ptext] ["="] CRLF)


parsePtext

protected int parsePtext(int offset)
return 1 or 3

parseOctet

protected int parseOctet(int offset)
start with "=" two of (DIGIT / "A" / "B" / "C" / "D" / "E" / "F")
So maybe return 3.


parseBase64

protected int parseBase64(int offset)
Refer to RFC 1521, base64 text The end of the text is marked with two CRLF sequences


parseWord

protected int parseWord(int offset)
Any printable ASCII sequence except [ ]=:.,;


isLetterOrDigit

protected boolean isLetterOrDigit(char ch)
If it is a letter or digit.


isPrintable

protected boolean isPrintable(char ch)
If it is printable in ASCII


isLetter

protected boolean isLetter(char ch)
If it is a letter.


getWord

protected String getWord(int offset)
Get a word from current position.


parsePValueVal

protected int parsePValueVal(int offset)
If is: "INLINE" / "URL" / "CONTENT-ID" / "CID" / "X-" word


parsePEncodingVal

protected int parsePEncodingVal(int offset)
If is: "7BIT" / "8BIT" / "QUOTED-PRINTABLE" / "BASE64" / "X-" word and set mEncoding.


parseCharsetVal

protected int parseCharsetVal(int offset)
Refer to RFC1521, section 7.1
If is: "us-ascii" / "iso-8859-xxx" / "X-" word


parseLangVal

protected int parseLangVal(int offset)
Refer to RFC 1766
like: XXX(sequence letters)-XXX(sequence letters)


parseTag

protected int parseTag(int offset)
From first 8 position, is sequence LETTER.


Build 1.0_r1(from source)

Please submit a feedback, bug or feature