FileDocCategorySizeDatePackage
PduBody.javaAPI DocAndroid 1.5 API5356Wed May 06 22:41:56 BST 2009com.google.android.mms.pdu

PduBody

public class PduBody extends Object

Fields Summary
private Vector
mParts
private Map
mPartMapByContentId
private Map
mPartMapByContentLocation
private Map
mPartMapByName
private Map
mPartMapByFileName
Constructors Summary
public PduBody()
Constructor.


          
      
        mParts = new Vector<PduPart>();

        mPartMapByContentId = new HashMap<String, PduPart>();
        mPartMapByContentLocation  = new HashMap<String, PduPart>();
        mPartMapByName = new HashMap<String, PduPart>();
        mPartMapByFileName = new HashMap<String, PduPart>();
    
Methods Summary
public booleanaddPart(PduPart part)
Appends the specified part to the end of this body.

param
part part to be appended
return
true when success, false when fail
throws
NullPointerException when part is null

        if(null == part) {
            throw new NullPointerException();
        }

        putPartToMaps(part);
        return mParts.add(part);
    
public voidaddPart(int index, PduPart part)
Inserts the specified part at the specified position.

param
index index at which the specified part is to be inserted
param
part part to be inserted
throws
NullPointerException when part is null

        if(null == part) {
            throw new NullPointerException();
        }

        putPartToMaps(part);
        mParts.add(index, part);
    
public PduPartgetPart(int index)
Get the part at the specified position.

param
index index of the part to return
return
part at the specified index

        return mParts.get(index);
    
public PduPartgetPartByContentId(java.lang.String cid)
Get pdu part by content id.

param
cid the value of content id.
return
the pdu part.

        return mPartMapByContentId.get(cid);
    
public PduPartgetPartByContentLocation(java.lang.String contentLocation)
Get pdu part by Content-Location. Content-Location of part is the same as filename and name(param of content-type).

param
fileName the value of filename.
return
the pdu part.

        return mPartMapByContentLocation.get(contentLocation);
    
public PduPartgetPartByFileName(java.lang.String filename)
Get pdu part by filename.

param
fileName the value of filename.
return
the pdu part.

        return mPartMapByFileName.get(filename);
    
public PduPartgetPartByName(java.lang.String name)
Get pdu part by name.

param
fileName the value of filename.
return
the pdu part.

        return mPartMapByName.get(name);
    
public intgetPartIndex(PduPart part)
Get the index of the specified part.

param
part the part object
return
index the index of the first occurrence of the part in this body

        return mParts.indexOf(part);
    
public intgetPartsNum()
Get the number of parts.

return
the number of parts

        return mParts.size();
    
private voidputPartToMaps(PduPart part)

        // Put part to mPartMapByContentId.
        byte[] contentId = part.getContentId();
        if(null != contentId) {
            mPartMapByContentId.put(new String(contentId), part);
        }

        // Put part to mPartMapByContentLocation.
        byte[] contentLocation = part.getContentLocation();
        if(null != contentLocation) {
            String clc = new String(contentLocation);
            mPartMapByContentLocation.put(clc, part);
        }

        // Put part to mPartMapByName.
        byte[] name = part.getName();
        if(null != name) {
            String clc = new String(name);
            mPartMapByName.put(clc, part);
        }

        // Put part to mPartMapByFileName.
        byte[] fileName = part.getFilename();
        if(null != fileName) {
            String clc = new String(fileName);
            mPartMapByFileName.put(clc, part);
        }
    
public voidremoveAll()
Remove all of the parts.

        mParts.clear();
    
public PduPartremovePart(int index)
Removes the part at the specified position.

param
index index of the part to return
return
part at the specified index

        return mParts.remove(index);