FileDocCategorySizeDatePackage
PduPart.javaAPI DocAndroid 5.1 API12746Thu Mar 12 22:22:54 GMT 2015com.google.android.mms.pdu

PduPart

public class PduPart extends Object
The pdu part.

Fields Summary
public static final int
P_Q
Well-Known Parameters.
public static final int
P_CHARSET
public static final int
P_LEVEL
public static final int
P_TYPE
public static final int
P_DEP_NAME
public static final int
P_DEP_FILENAME
public static final int
P_DIFFERENCES
public static final int
P_PADDING
public static final int
P_CT_MR_TYPE
public static final int
P_DEP_START
public static final int
P_DEP_START_INFO
public static final int
P_DEP_COMMENT
public static final int
P_DEP_DOMAIN
public static final int
P_MAX_AGE
public static final int
P_DEP_PATH
public static final int
P_SECURE
public static final int
P_SEC
public static final int
P_MAC
public static final int
P_CREATION_DATE
public static final int
P_MODIFICATION_DATE
public static final int
P_READ_DATE
public static final int
P_SIZE
public static final int
P_NAME
public static final int
P_FILENAME
public static final int
P_START
public static final int
P_START_INFO
public static final int
P_COMMENT
public static final int
P_DOMAIN
public static final int
P_PATH
public static final int
P_CONTENT_TYPE
Header field names.
public static final int
P_CONTENT_LOCATION
public static final int
P_CONTENT_ID
public static final int
P_DEP_CONTENT_DISPOSITION
public static final int
P_CONTENT_DISPOSITION
public static final int
P_CONTENT_TRANSFER_ENCODING
public static final String
CONTENT_TRANSFER_ENCODING
Content=Transfer-Encoding string.
public static final String
P_BINARY
Value of Content-Transfer-Encoding.
public static final String
P_7BIT
public static final String
P_8BIT
public static final String
P_BASE64
public static final String
P_QUOTED_PRINTABLE
static final byte[]
DISPOSITION_FROM_DATA
Value of disposition can be set to PduPart when the value is octet in the PDU. "from-data" instead of Form-data. "attachment" instead of Attachment. "inline" instead of Inline.
static final byte[]
DISPOSITION_ATTACHMENT
static final byte[]
DISPOSITION_INLINE
public static final int
P_DISPOSITION_FROM_DATA
Content-Disposition value.
public static final int
P_DISPOSITION_ATTACHMENT
public static final int
P_DISPOSITION_INLINE
private Map
mPartHeader
Header of part.
private android.net.Uri
mUri
Data uri.
private byte[]
mPartData
Part data.
private static final String
TAG
Constructors Summary
public PduPart()
Empty Constructor.


             
       
         mPartHeader = new HashMap<Integer, Object>();
     
Methods Summary
public java.lang.StringgenerateLocation()

        // Assumption: At least one of the content-location / name / filename
        // or content-id should be set. This is guaranteed by the PduParser
        // for incoming messages and by MM composer for outgoing messages.
        byte[] location = (byte[]) mPartHeader.get(P_NAME);
        if(null == location) {
            location = (byte[]) mPartHeader.get(P_FILENAME);

            if (null == location) {
                location = (byte[]) mPartHeader.get(P_CONTENT_LOCATION);
            }
        }

        if (null == location) {
            byte[] contentId = (byte[]) mPartHeader.get(P_CONTENT_ID);
            return "cid:" + new String(contentId);
        } else {
            return new String(location);
        }
    
public intgetCharset()
Get Char-set value

return
the charset value. Return 0 if charset was not set.

         Integer charset = (Integer) mPartHeader.get(P_CHARSET);
         if(charset == null) {
             return 0;
         } else {
             return charset.intValue();
         }
     
public byte[]getContentDisposition()
Get Content-Disposition value.

return
the value

         return (byte[]) mPartHeader.get(P_CONTENT_DISPOSITION);
     
public byte[]getContentId()
Get Content-id value.

return
the value

         return (byte[]) mPartHeader.get(P_CONTENT_ID);
     
public byte[]getContentLocation()
Get Content-Location value.

return
the value return PduPart.disposition[0] instead of (Form-data). return PduPart.disposition[1] instead of (Attachment). return PduPart.disposition[2] instead of (Inline).

         return (byte[]) mPartHeader.get(P_CONTENT_LOCATION);
     
public byte[]getContentTransferEncoding()
Get Content-Transfer-Encoding value.

return
the value

         return (byte[]) mPartHeader.get(P_CONTENT_TRANSFER_ENCODING);
     
public byte[]getContentType()
Get Content-Type value of part.

return
the value

         return (byte[]) mPartHeader.get(P_CONTENT_TYPE);
     
public byte[]getData()

return
A copy of the part data or null if the data wasn't set or the data is stored as Uri.
see
#getDataUri

         if(mPartData == null) {
            return null;
         }

         byte[] byteArray = new byte[mPartData.length];
         System.arraycopy(mPartData, 0, byteArray, 0, mPartData.length);
         return byteArray;
     
public intgetDataLength()

return
The length of the data, if this object have data, else 0.

         if(mPartData != null){
             return mPartData.length;
         } else {
             return 0;
         }
     
public android.net.UrigetDataUri()

return
The Uri of the part data or null if the data wasn't set or the data is stored as byte array.
see
#getData

         return mUri;
     
public byte[]getFilename()
Set Content-disposition parameter: filename

return
the filename

         return (byte[]) mPartHeader.get(P_FILENAME);
     
public byte[]getName()
Get content-type parameter: name.

return
the name

         return (byte[]) mPartHeader.get(P_NAME);
     
public voidsetCharset(int charset)
Set Char-set value.

param
charset the value

         mPartHeader.put(P_CHARSET, charset);
     
public voidsetContentDisposition(byte[] contentDisposition)
Set Content-Disposition value. Use PduPart.disposition[0] instead of (Form-data). Use PduPart.disposition[1] instead of (Attachment). Use PduPart.disposition[2] instead of (Inline).

param
contentDisposition the value
throws
NullPointerException if the value is null.

         if(contentDisposition == null) {
             throw new NullPointerException("null content-disposition");
         }

         mPartHeader.put(P_CONTENT_DISPOSITION, contentDisposition);
     
public voidsetContentId(byte[] contentId)
Set Content-id value

param
contentId the content-id value
throws
NullPointerException if the value is null.

         if((contentId == null) || (contentId.length == 0)) {
             throw new IllegalArgumentException(
                     "Content-Id may not be null or empty.");
         }

         if ((contentId.length > 1)
                 && ((char) contentId[0] == '<")
                 && ((char) contentId[contentId.length - 1] == '>")) {
             mPartHeader.put(P_CONTENT_ID, contentId);
             return;
         }

         // Insert beginning '<' and trailing '>' for Content-Id.
         byte[] buffer = new byte[contentId.length + 2];
         buffer[0] = (byte) (0xff & '<");
         buffer[buffer.length - 1] = (byte) (0xff & '>");
         System.arraycopy(contentId, 0, buffer, 1, contentId.length);
         mPartHeader.put(P_CONTENT_ID, buffer);
     
public voidsetContentLocation(byte[] contentLocation)
Set Content-Location value.

param
contentLocation the value
throws
NullPointerException if the value is null.

         if(contentLocation == null) {
             throw new NullPointerException("null content-location");
         }

         mPartHeader.put(P_CONTENT_LOCATION, contentLocation);
     
public voidsetContentTransferEncoding(byte[] contentTransferEncoding)
Set Content-Transfer-Encoding value

param
contentId the content-id value
throws
NullPointerException if the value is null.

         if(contentTransferEncoding == null) {
             throw new NullPointerException("null content-transfer-encoding");
         }

         mPartHeader.put(P_CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
     
public voidsetContentType(byte[] contentType)
Set Content-Type value.

param
value the value
throws
NullPointerException if the value is null.

         if(contentType == null) {
             throw new NullPointerException("null content-type");
         }

         mPartHeader.put(P_CONTENT_TYPE, contentType);
     
public voidsetData(byte[] data)
Set part data. The data are stored as byte array.

param
data the data

         if(data == null) {
            return;
        }

         mPartData = new byte[data.length];
         System.arraycopy(data, 0, mPartData, 0, data.length);
     
public voidsetDataUri(android.net.Uri uri)
Set data uri. The data are stored as Uri.

param
uri the uri

         mUri = uri;
     
public voidsetFilename(byte[] fileName)
Get Content-disposition parameter: filename

param
fileName the filename value
throws
NullPointerException if the value is null.

         if(null == fileName) {
             throw new NullPointerException("null content-id");
         }

         mPartHeader.put(P_FILENAME, fileName);
     
public voidsetName(byte[] name)
Set Content-type parameter: name.

param
name the name value
throws
NullPointerException if the value is null.

         if(null == name) {
             throw new NullPointerException("null content-id");
         }

         mPartHeader.put(P_NAME, name);