FileDocCategorySizeDatePackage
DrmSupportInfo.javaAPI DocAndroid 5.1 API6333Thu Mar 12 22:22:30 GMT 2015android.drm

DrmSupportInfo

public class DrmSupportInfo extends Object
An entity class that wraps the capability of each DRM plug-in (agent), such as the MIME type and file suffix the DRM plug-in can handle.

Plug-in developers can expose the capability of their plug-in by passing an instance of this class to an application.

Fields Summary
private final ArrayList
mFileSuffixList
private final ArrayList
mMimeTypeList
private String
mDescription
Constructors Summary
Methods Summary
public voidaddFileSuffix(java.lang.String fileSuffix)
Adds the specified file suffix to the list of file suffixes this DRM plug-in supports.

param
fileSuffix File suffix that can be handled by this DRM plug-in. it could be null but not an empty string. When it is null, it indicates that some DRM content comes with no file suffix.

        if (fileSuffix == "") {
            throw new IllegalArgumentException("fileSuffix is an empty string");
        }

        mFileSuffixList.add(fileSuffix);
    
public voidaddMimeType(java.lang.String mimeType)
Adds the specified MIME type to the list of MIME types this DRM plug-in supports.

param
mimeType MIME type that can be handles by this DRM plug-in. Must not be null or an empty string.


                                            
        
        if (mimeType == null) {
            throw new IllegalArgumentException("mimeType is null");
        }
        if (mimeType == "") {
            throw new IllegalArgumentException("mimeType is an empty string");
        }

        mMimeTypeList.add(mimeType);
    
public booleanequals(java.lang.Object object)
Overridden equals implementation. Two DrmSupportInfo objects are considered being equal if they support exactly the same set of mime types, file suffixes, and has exactly the same description.

param
object The object to be compared.
return
True if equal; false if not equal.

        if (object instanceof DrmSupportInfo) {
            DrmSupportInfo info = (DrmSupportInfo) object;
            return mFileSuffixList.equals(info.mFileSuffixList) &&
                   mMimeTypeList.equals(info.mMimeTypeList) &&
                   mDescription.equals(info.mDescription);
        }
        return false;
    
public java.lang.StringgetDescriprition()
Retrieves the DRM plug-in (agent) description.

return
The plug-in description.
deprecated
The method name is mis-spelled, and it is replaced by {@link #getDescription()}.

        return mDescription;
    
public java.lang.StringgetDescription()
Retrieves the DRM plug-in (agent) description. Even if null or an empty string is not allowed in {@link #setDescription(String)}, if {@link #setDescription(String)} is not called, description returned from this method is an empty string.

return
The plug-in description.

        return mDescription;
    
public java.util.IteratorgetFileSuffixIterator()
Retrieves an iterator object that you can use to iterate over the file suffixes that this DRM plug-in supports.

return
The iterator object.

        return mFileSuffixList.iterator();
    
public java.util.IteratorgetMimeTypeIterator()
Retrieves an iterator object that you can use to iterate over the MIME types that this DRM plug-in supports.

return
The iterator object

        return mMimeTypeList.iterator();
    
public inthashCode()
Overridden hash code implementation.

return
The hash code value.

        return mFileSuffixList.hashCode() + mMimeTypeList.hashCode() + mDescription.hashCode();
    
booleanisSupportedFileSuffix(java.lang.String fileSuffix)
Determines whether a given file suffix is supported.

param
fileSuffix File suffix.
return
True if file suffix is supported; false if file suffix is not supported.

        return mFileSuffixList.contains(fileSuffix);
    
booleanisSupportedMimeType(java.lang.String mimeType)
Determines whether a given MIME type is supported.

param
mimeType MIME type.
return
True if Mime type is supported; false if MIME type is not supported. Null or empty string is not a supported mimeType.

        if (null != mimeType && !mimeType.equals("")) {
            for (int i = 0; i < mMimeTypeList.size(); i++) {
                String completeMimeType = mMimeTypeList.get(i);

                // The reason that equals() is not used is that sometimes,
                // content distributor might just append something to
                // the basic MIME type. startsWith() is used to avoid
                // frequent update of DRM agent.
                if (completeMimeType.startsWith(mimeType)) {
                    return true;
                }
            }
        }
        return false;
    
public voidsetDescription(java.lang.String description)
Sets a description for the DRM plug-in (agent).

param
description Unique description of plug-in. Must not be null or an empty string.

        if (description == null) {
            throw new IllegalArgumentException("description is null");
        }
        if (description == "") {
            throw new IllegalArgumentException("description is an empty string");
        }

        mDescription = description;