Methods Summary |
---|
private java.lang.String | encodeString(java.lang.String originalString, java.lang.String targetEncoding)
Charset charset = Charset.forName(mCharset);
ByteBuffer byteBuffer = charset.encode(originalString);
// byteBuffer.array() "may" return byte array which is larger than
// byteBuffer.remaining(). Here, we keep on the safe side.
byte[] bytes = new byte[byteBuffer.remaining()];
byteBuffer.get(bytes);
try {
return new String(bytes, targetEncoding);
} catch (UnsupportedEncodingException e) {
return null;
}
|
public void | end()
|
public void | endProperty()
// System.out.println("- endProperty. ");
|
public void | endRecord()
VNode endNode = vNodeList.get(mNodeListPos);
endNode.parseStatus = 0;
while(mNodeListPos > 0){
mNodeListPos--;
if((vNodeList.get(mNodeListPos)).parseStatus == 1)
break;
}
mCurrentVNode = vNodeList.get(mNodeListPos);
|
public java.lang.String | getResult()
return null;
|
private java.lang.String | listToString(java.util.Collection list)
StringBuilder typeListB = new StringBuilder();
for (String type : list) {
typeListB.append(type).append(";");
}
int len = typeListB.length();
if (len > 0 && typeListB.charAt(len - 1) == ';") {
return typeListB.substring(0, len - 1);
}
return typeListB.toString();
|
public void | propertyGroup(java.lang.String group)
mCurrentPropNode.propGroupSet.add(group);
|
public void | propertyName(java.lang.String name)
mCurrentPropNode = new PropertyNode();
mCurrentPropNode.propName = name;
|
public void | propertyParamType(java.lang.String type)
mCurrentParamType = type;
|
public void | propertyParamValue(java.lang.String value)
if (mCurrentParamType == null ||
mCurrentParamType.equalsIgnoreCase("TYPE")) {
mCurrentPropNode.paramMap_TYPE.add(value);
} else {
mCurrentPropNode.paramMap.put(mCurrentParamType, value);
}
mCurrentParamType = null;
|
public void | propertyValues(java.util.List values)
ContentValues paramMap = mCurrentPropNode.paramMap;
String charsetString = paramMap.getAsString("CHARSET");
boolean setupParamValues = false;
//decode value string to propValue_bytes
if (paramMap.containsKey("ENCODING")) {
String encoding = paramMap.getAsString("ENCODING");
if (encoding.equalsIgnoreCase("BASE64") ||
encoding.equalsIgnoreCase("B")) {
if (values.size() > 1) {
Log.e(LOG_TAG,
("BASE64 encoding is used while " +
"there are multiple values (" + values.size()));
}
mCurrentPropNode.propValue_bytes =
Base64.decodeBase64(values.get(0).
replaceAll(" ","").replaceAll("\t","").
replaceAll("\r\n","").
getBytes());
}
if(encoding.equalsIgnoreCase("QUOTED-PRINTABLE")){
// if CHARSET is defined, we translate each String into the Charset.
List<String> tmpValues = new ArrayList<String>();
Vector<byte[]> byteVector = new Vector<byte[]>();
int size = 0;
try{
for (String value : values) {
String quotedPrintable = value
.replaceAll("= ", " ").replaceAll("=\t", "\t");
String[] lines;
if (mStrictLineBreakParsing) {
lines = quotedPrintable.split("\r\n");
} else {
lines = quotedPrintable
.replace("\r\n", "\n").replace("\r", "\n").split("\n");
}
StringBuilder builder = new StringBuilder();
for (String line : lines) {
if (line.endsWith("=")) {
line = line.substring(0, line.length() - 1);
}
builder.append(line);
}
byte[] bytes = QuotedPrintableCodec.decodeQuotedPrintable(
builder.toString().getBytes());
if (charsetString != null) {
try {
tmpValues.add(new String(bytes, charsetString));
} catch (UnsupportedEncodingException e) {
Log.e(LOG_TAG, "Failed to encode: charset=" + charsetString);
tmpValues.add(new String(bytes));
}
} else {
tmpValues.add(new String(bytes));
}
byteVector.add(bytes);
size += bytes.length;
} // for (String value : values) {
mCurrentPropNode.propValue_vector = tmpValues;
mCurrentPropNode.propValue = listToString(tmpValues);
mCurrentPropNode.propValue_bytes = new byte[size];
{
byte[] tmpBytes = mCurrentPropNode.propValue_bytes;
int index = 0;
for (byte[] bytes : byteVector) {
int length = bytes.length;
for (int i = 0; i < length; i++, index++) {
tmpBytes[index] = bytes[i];
}
}
}
setupParamValues = true;
} catch(Exception e) {
Log.e(LOG_TAG, "Failed to decode quoted-printable: " + e);
}
} // QUOTED-PRINTABLE
} // ENCODING
if (!setupParamValues) {
// if CHARSET is defined, we translate each String into the Charset.
if (charsetString != null) {
List<String> tmpValues = new ArrayList<String>();
for (String value : values) {
String result = encodeString(value, charsetString);
if (result != null) {
tmpValues.add(result);
} else {
Log.e(LOG_TAG, "Failed to encode: charset=" + charsetString);
tmpValues.add(value);
}
}
values = tmpValues;
}
mCurrentPropNode.propValue_vector = values;
mCurrentPropNode.propValue = listToString(values);
}
mCurrentVNode.propList.add(mCurrentPropNode);
|
public void | start()
|
public void | startProperty()
// System.out.println("+ startProperty. ");
|
public void | startRecord(java.lang.String type)
VNode vnode = new VNode();
vnode.parseStatus = 1;
vnode.VName = type;
vNodeList.add(vnode);
mNodeListPos = vNodeList.size()-1;
mCurrentVNode = vNodeList.get(mNodeListPos);
|