Class ActivationDataFlavor
- java.lang.Object
-
- jakarta.activation.ActivationDataFlavor
-
public class ActivationDataFlavor extends Object
The ActivationDataFlavor class is similar to the JDK'sjava.awt.datatransfer.DataFlavorclass. 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 theequalsmethod. Except for the improved parsing, its semantics are identical to that of the JDK's DataFlavor class.
-
-
Constructor Summary
Constructors Constructor Description ActivationDataFlavor(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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(ActivationDataFlavor dataFlavor)Compares the ActivationDataFlavor passed in with this ActivationDataFlavor; calls theisMimeTypeEqualmethod.booleanequals(Object o)booleanequals(String s)Deprecated.As inconsistent withhashCode()contract, useisMimeTypeEqual(String)instead.StringgetHumanPresentableName()Return the Human Presentable name.StringgetMimeType()Return the MIME type for this ActivationDataFlavor.Class<?>getRepresentationClass()Return the representation class.inthashCode()Returns hash code for thisActivationDataFlavor.booleanisMimeTypeEqual(String mimeType)Is the string representation of the MIME type passed in equivalent to the MIME type of this ActivationDataFlavor.protected StringnormalizeMimeType(String mimeType)Deprecated.protected StringnormalizeMimeTypeParameter(String parameterName, String parameterValue)Deprecated.voidsetHumanPresentableName(String humanPresentableName)Set the human presentable name.
-
-
-
Constructor Detail
-
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
public ActivationDataFlavor(Class<?> representationClass, String humanPresentableName)
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
public ActivationDataFlavor(String mimeType, String humanPresentableName)
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 Detail
-
getMimeType
public String getMimeType()
Return the MIME type for this ActivationDataFlavor.- Returns:
- the MIME type
-
getRepresentationClass
public Class<?> getRepresentationClass()
Return the representation class.- Returns:
- the representation class
-
getHumanPresentableName
public String getHumanPresentableName()
Return the Human Presentable name.- Returns:
- the human presentable name
-
setHumanPresentableName
public void setHumanPresentableName(String humanPresentableName)
Set the human presentable name.- Parameters:
humanPresentableName- the name to set
-
equals
public boolean equals(ActivationDataFlavor dataFlavor)
Compares the ActivationDataFlavor passed in with this ActivationDataFlavor; calls theisMimeTypeEqualmethod.- Parameters:
dataFlavor- the ActivationDataFlavor to compare with- Returns:
- true if the MIME type and representation class are the same
-
equals
public boolean equals(Object o)
-
equals
@Deprecated public boolean equals(String s)
Deprecated.As inconsistent withhashCode()contract, useisMimeTypeEqual(String)instead.Compares only themimeTypeagainst the passed inStringandrepresentationClassis not considered in the comparison. IfrepresentationClassneeds to be compared, thenequals(new DataFlavor(s))may be used.- Parameters:
s- themimeTypeto compare.- Returns:
- true if the String (MimeType) is equal; false otherwise or if
sisnull
-
hashCode
public int hashCode()
Returns hash code for thisActivationDataFlavor. For two equalActivationDataFlavors, hash codes are equal. For theStringthat matchesActivationDataFlavor.equals(String), it is not guaranteed thatActivationDataFlavor's hash code is equal to the hash code of theString.
-
isMimeTypeEqual
public boolean isMimeTypeEqual(String mimeType)
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 protected String normalizeMimeType(String mimeType)
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
-
-