Constructors Summary |
---|
public EncodedStringValue(int charset, byte[] data)Constructor.
// TODO: CharSet needs to be validated against MIBEnum.
if(null == data) {
throw new NullPointerException("EncodedStringValue: Text-string is null.");
}
mCharacterSet = charset;
mData = new byte[data.length];
System.arraycopy(data, 0, mData, 0, data.length);
|
public EncodedStringValue(byte[] data)Constructor.
this(CharacterSets.DEFAULT_CHARSET, data);
|
public EncodedStringValue(String data)
try {
mData = data.getBytes(CharacterSets.DEFAULT_CHARSET_NAME);
mCharacterSet = CharacterSets.DEFAULT_CHARSET;
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "Default encoding must be supported.", e);
}
|
Methods Summary |
---|
public void | appendTextString(byte[] textString)Append to Text-string.
if(null == textString) {
throw new NullPointerException("Text-string is null.");
}
if(null == mData) {
mData = new byte[textString.length];
System.arraycopy(textString, 0, mData, 0, textString.length);
} else {
ByteArrayOutputStream newTextString = new ByteArrayOutputStream();
try {
newTextString.write(mData);
newTextString.write(textString);
} catch (IOException e) {
e.printStackTrace();
throw new NullPointerException(
"appendTextString: failed when write a new Text-string");
}
mData = newTextString.toByteArray();
}
|
public java.lang.Object | clone()
super.clone();
int len = mData.length;
byte[] dstBytes = new byte[len];
System.arraycopy(mData, 0, dstBytes, 0, len);
try {
return new EncodedStringValue(mCharacterSet, dstBytes);
} catch (Exception e) {
Log.e(TAG, "failed to clone an EncodedStringValue: " + this);
e.printStackTrace();
throw new CloneNotSupportedException(e.getMessage());
}
|
public static java.lang.String | concat(com.google.android.mms.pdu.EncodedStringValue[] addr)Concatenate an EncodedStringValue[] into a single String.
StringBuilder sb = new StringBuilder();
int maxIndex = addr.length - 1;
for (int i = 0; i <= maxIndex; i++) {
sb.append(addr[i].getString());
if (i < maxIndex) {
sb.append(";");
}
}
return sb.toString();
|
public static com.google.android.mms.pdu.EncodedStringValue | copy(com.google.android.mms.pdu.EncodedStringValue value)
if (value == null) {
return null;
}
return new EncodedStringValue(value.mCharacterSet, value.mData);
|
public static com.google.android.mms.pdu.EncodedStringValue[] | encodeStrings(java.lang.String[] array)
int count = array.length;
if (count > 0) {
EncodedStringValue[] encodedArray = new EncodedStringValue[count];
for (int i = 0; i < count; i++) {
encodedArray[i] = new EncodedStringValue(array[i]);
}
return encodedArray;
}
return null;
|
public static com.google.android.mms.pdu.EncodedStringValue[] | extract(java.lang.String src)Extract an EncodedStringValue[] from a given String.
String[] values = src.split(";");
ArrayList<EncodedStringValue> list = new ArrayList<EncodedStringValue>();
for (int i = 0; i < values.length; i++) {
if (values[i].length() > 0) {
list.add(new EncodedStringValue(values[i]));
}
}
int len = list.size();
if (len > 0) {
return list.toArray(new EncodedStringValue[len]);
} else {
return null;
}
|
public int | getCharacterSet()Get Char-set value.
return mCharacterSet;
|
public java.lang.String | getString()Convert this object to a {@link java.lang.String}. If the encoding of
the EncodedStringValue is null or unsupported, it will be
treated as iso-8859-1 encoding.
if (CharacterSets.ANY_CHARSET == mCharacterSet) {
return new String(mData); // system default encoding.
} else {
try {
String name = CharacterSets.getMimeName(mCharacterSet);
return new String(mData, name);
} catch (UnsupportedEncodingException e) {
if (LOCAL_LOGV) {
Log.v(TAG, e.getMessage(), e);
}
try {
return new String(mData, CharacterSets.MIMENAME_ISO_8859_1);
} catch (UnsupportedEncodingException _) {
return new String(mData); // system default encoding.
}
}
}
|
public byte[] | getTextString()Get Text-string value.
byte[] byteArray = new byte[mData.length];
System.arraycopy(mData, 0, byteArray, 0, mData.length);
return byteArray;
|
public void | setCharacterSet(int charset)Set Char-set value.
// TODO: CharSet needs to be validated against MIBEnum.
mCharacterSet = charset;
|
public void | setTextString(byte[] textString)Set Text-string value.
if(null == textString) {
throw new NullPointerException("EncodedStringValue: Text-string is null.");
}
mData = new byte[textString.length];
System.arraycopy(textString, 0, mData, 0, textString.length);
|
public com.google.android.mms.pdu.EncodedStringValue[] | split(java.lang.String pattern)Split this encoded string around matches of the given pattern.
String[] temp = getString().split(pattern);
EncodedStringValue[] ret = new EncodedStringValue[temp.length];
for (int i = 0; i < ret.length; ++i) {
try {
ret[i] = new EncodedStringValue(mCharacterSet,
temp[i].getBytes());
} catch (NullPointerException _) {
// Can't arrive here
return null;
}
}
return ret;
|