Merge "Don't send null/empty values in SimpleIcsWriter"

This commit is contained in:
Marc Blank 2010-03-20 20:29:55 -07:00 committed by Android (Google) Code Review
commit fe82454847
1 changed files with 15 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import android.text.TextUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
/**
* Class to generate iCalender object (*.ics) per RFC 5545.
@ -61,9 +62,9 @@ public class SimpleIcsWriter {
* Write a tag with a value.
*/
public void writeTag(String name, String value) {
// Belt and suspenders here; don't crash on null value. Use something innocuous
// Belt and suspenders here; don't crash on null value; just return
if (TextUtils.isEmpty(value)) {
value = "0";
return;
}
// The following properties take a TEXT value, which need to be escaped.
@ -98,6 +99,18 @@ public class SimpleIcsWriter {
writeLine(name + ":" + value);
}
/**
* For debugging
*/
@Override
public String toString() {
try {
return new String(getBytes(), "UTF-8");
} catch (UnsupportedEncodingException wonthappen) {
}
return null;
}
/**
* @return the entire iCalendar invitation object.
*/