java.awt.datatransfer.DataFlavor
class. It allows
Jakarta Activation 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.-
Constructor Summary
ConstructorDescriptionActivationDataFlavor
(Class<?> representationClass, String humanPresentableName) Construct an ActivationDataFlavor that represents a MimeType.ActivationDataFlavor
(Class<?> representationClass, String mimeType, String humanPresentableName) Construct an ActivationDataFlavor that represents an arbitrary Java object.ActivationDataFlavor
(String mimeType, String humanPresentableName) Construct an ActivationDataFlavor that represents a MimeType. -
Method Summary
Modifier and TypeMethodDescriptionboolean
equals
(ActivationDataFlavor dataFlavor) Compares the ActivationDataFlavor passed in with this ActivationDataFlavor; calls theisMimeTypeEqual
method.boolean
boolean
Deprecated.Return the Human Presentable name.Return the MIME type for this ActivationDataFlavor.Class<?>
Return the representation class.int
hashCode()
Returns hash code for thisActivationDataFlavor
.boolean
isMimeTypeEqual
(String mimeType) Is the string representation of the MIME type passed in equivalent to the MIME type of this ActivationDataFlavor.protected String
normalizeMimeType
(String mimeType) Deprecated.protected String
normalizeMimeTypeParameter
(String parameterName, String parameterValue) Deprecated.void
setHumanPresentableName
(String humanPresentableName) Set the human presentable name.
-
Constructor Details
-
ActivationDataFlavor
public ActivationDataFlavor(Class<?> representationClass, String mimeType, String humanPresentableName) Construct an ActivationDataFlavor that represents an arbitrary Java object.The returned ActivationDataFlavor will have the following characteristics:
representationClass = representationClass
mimeType = mimeType
humanName = humanName- Parameters:
representationClass
- the class used in this ActivationDataFlavormimeType
- the MIME type of the data represented by this classhumanPresentableName
- the human presentable name of the flavor
-
ActivationDataFlavor
Construct an ActivationDataFlavor that represents a MimeType.The returned ActivationDataFlavor will have the following characteristics:
If the mimeType is "application/x-java-serialized-object; class=", the result is the same as calling new ActivationDataFlavor(Class.forName()) as above.
otherwise:
representationClass = InputStream
mimeType = mimeType
- Parameters:
representationClass
- the class used in this ActivationDataFlavorhumanPresentableName
- the human presentable name of the flavor
-
ActivationDataFlavor
Construct an ActivationDataFlavor that represents a MimeType.The returned ActivationDataFlavor will have the following characteristics:
If the mimeType is "application/x-java-serialized-object; class=", the result is the same as calling new ActivationDataFlavor(Class.forName()) as above, otherwise:
representationClass = InputStream
mimeType = mimeType- Parameters:
mimeType
- the MIME type of the data represented by this classhumanPresentableName
- the human presentable name of the flavor
-
-
Method Details
-
getMimeType
Return the MIME type for this ActivationDataFlavor.- Returns:
- the MIME type
-
getRepresentationClass
Return the representation class.- Returns:
- the representation class
-
getHumanPresentableName
Return the Human Presentable name.- Returns:
- the human presentable name
-
setHumanPresentableName
Set the human presentable name.- Parameters:
humanPresentableName
- the name to set
-
equals
Compares the ActivationDataFlavor passed in with this ActivationDataFlavor; calls theisMimeTypeEqual
method.- Parameters:
dataFlavor
- the ActivationDataFlavor to compare with- Returns:
- true if the MIME type and representation class are the same
-
equals
-
equals
Deprecated.As inconsistent withhashCode()
contract, useisMimeTypeEqual(String)
instead.Compares only themimeType
against the passed inString
andrepresentationClass
is not considered in the comparison. IfrepresentationClass
needs to be compared, thenequals(new DataFlavor(s))
may be used.- Parameters:
s
- themimeType
to compare.- Returns:
- true if the String (MimeType) is equal; false otherwise or if
s
isnull
-
hashCode
public int hashCode()Returns hash code for thisActivationDataFlavor
. For two equalActivationDataFlavor
s, hash codes are equal. For theString
that matchesActivationDataFlavor.equals(String)
, it is not guaranteed thatActivationDataFlavor
's hash code is equal to the hash code of theString
. -
isMimeTypeEqual
Is the string representation of the MIME type passed in equivalent to the MIME type of this ActivationDataFlavor.ActivationDataFlavor delegates the comparison of MIME types to the MimeType class included as part of Jakarta Activation.
- Parameters:
mimeType
- the MIME type- Returns:
- true if the same MIME type
-
normalizeMimeTypeParameter
@Deprecated protected String normalizeMimeTypeParameter(String parameterName, String parameterValue) Deprecated.Called on ActivationDataFlavor for every MIME Type parameter to allow ActivationDataFlavor 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.
- Parameters:
parameterName
- the parameter nameparameterValue
- the parameter value- Returns:
- the normalized parameter value
-
normalizeMimeType
Deprecated.Called for each MIME type string to give ActivationDataFlavor 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.- Parameters:
mimeType
- the MIME type- Returns:
- the normalized MIME type
-
hashCode()
contract, useisMimeTypeEqual(String)
instead.