FileDocCategorySizeDatePackage
ActivationDataFlavor.javaAPI DocGlassfish v2 API9567Fri Aug 17 15:55:08 BST 2007javax.activation

ActivationDataFlavor

public class ActivationDataFlavor extends DataFlavor
The ActivationDataFlavor class is a special subclass of java.awt.datatransfer.DataFlavor. It allows the JAF to set all three values stored by the DataFlavor class via a new constructor. It also contains improved MIME parsing in the equals method. Except for the improved parsing, its semantics are identical to that of the JDK's DataFlavor class.

Fields Summary
private String
mimeType
private MimeType
mimeObject
private String
humanPresentableName
private Class
representationClass
Constructors Summary
public ActivationDataFlavor(Class representationClass, String mimeType, String humanPresentableName)
Construct a DataFlavor that represents an arbitrary Java object. This constructor is an extension of the JDK's DataFlavor in that it allows the explicit setting of all three DataFlavor attributes.

The returned DataFlavor will have the following characteristics:

representationClass = representationClass
mimeType = mimeType
humanName = humanName

param
representationClass the class used in this DataFlavor
param
mimeType the MIME type of the data represented by this class
param
humanPresentableName the human presentable name of the flavor


                                                                                                             
      
		          
	super(mimeType, humanPresentableName); // need to call super

	// init private variables:
	this.mimeType = mimeType;
	this.humanPresentableName = humanPresentableName;
	this.representationClass = representationClass;
    
public ActivationDataFlavor(Class representationClass, String humanPresentableName)
Construct a DataFlavor that represents a MimeType.

The returned DataFlavor will have the following characteristics:

If the mimeType is "application/x-java-serialized-object; class=", the result is the same as calling new DataFlavor(Class.forName()) as above.

otherwise:

representationClass = InputStream

mimeType = mimeType

param
representationClass the class used in this DataFlavor
param
humanPresentableName the human presentable name of the flavor

	super(representationClass, humanPresentableName);
	this.mimeType = super.getMimeType();
	this.representationClass = representationClass;
      	this.humanPresentableName = humanPresentableName;
    
public ActivationDataFlavor(String mimeType, String humanPresentableName)
Construct a DataFlavor that represents a MimeType.

The returned DataFlavor will have the following characteristics:

If the mimeType is "application/x-java-serialized-object; class=", the result is the same as calling new DataFlavor(Class.forName()) as above, otherwise:

representationClass = InputStream

mimeType = mimeType

param
mimeType the MIME type of the data represented by this class
param
humanPresentableName the human presentable name of the flavor

	super(mimeType, humanPresentableName);
	this.mimeType = mimeType;
	try {
	    this.representationClass = Class.forName("java.io.InputStream");
	} catch (ClassNotFoundException ex) {
	    // XXX - should never happen, ignore it
	}
      	this.humanPresentableName = humanPresentableName;
    
Methods Summary
public booleanequals(java.awt.datatransfer.DataFlavor dataFlavor)
Compares the DataFlavor passed in with this DataFlavor; calls the isMimeTypeEqual method.

param
dataFlavor the DataFlavor to compare with
return
true if the MIME type and representation class are the same

	return (isMimeTypeEqual(dataFlavor) &&
	 	dataFlavor.getRepresentationClass() == representationClass);
    
public java.lang.StringgetHumanPresentableName()
Return the Human Presentable name.

return
the human presentable name

	return humanPresentableName;
    
public java.lang.StringgetMimeType()
Return the MIME type for this DataFlavor.

return
the MIME type

	return mimeType;
    
public java.lang.ClassgetRepresentationClass()
Return the representation class.

return
the representation class

	return representationClass;
    
public booleanisMimeTypeEqual(java.lang.String mimeType)
Is the string representation of the MIME type passed in equivalent to the MIME type of this DataFlavor.

ActivationDataFlavor delegates the comparison of MIME types to the MimeType class included as part of the JavaBeans Activation Framework. This provides a more robust comparison than is normally available in the DataFlavor class.

param
mimeType the MIME type
return
true if the same MIME type

	MimeType mt = null;
	try {
	    if (mimeObject == null)
		mimeObject = new MimeType(this.mimeType);
	    mt = new MimeType(mimeType);
	} catch (MimeTypeParseException e) {
	    // something didn't parse, do a crude comparison
	    return this.mimeType.equalsIgnoreCase(mimeType);
	}

	return mimeObject.match(mt);
    
protected java.lang.StringnormalizeMimeType(java.lang.String mimeType)
Called for each MIME type string to give DataFlavor subtypes the opportunity to change how the normalization of MIME types is accomplished. One possible use would be to add default parameter/value pairs in cases where none are present in the MIME type string passed in. This method is never invoked by this implementation.

param
mimeType the MIME type
return
the normalized MIME type
deprecated

	return mimeType;
    
protected java.lang.StringnormalizeMimeTypeParameter(java.lang.String parameterName, java.lang.String parameterValue)
Called on DataFlavor for every MIME Type parameter to allow DataFlavor subclasses to handle special parameters like the text/plain charset parameters, whose values are case insensitive. (MIME type parameter values are supposed to be case sensitive).

This method is called for each parameter name/value pair and should return the normalized representation of the parameterValue. This method is never invoked by this implementation.

param
parameterName the parameter name
param
parameterValue the parameter value
return
the normalized parameter value
deprecated

	return parameterValue;
    
public voidsetHumanPresentableName(java.lang.String humanPresentableName)
Set the human presentable name.

param
humanPresentableName the name to set

	this.humanPresentableName = humanPresentableName;