Class ActivationDataFlavor

java.lang.Object
jakarta.activation.ActivationDataFlavor

public class ActivationDataFlavor extends Object
The ActivationDataFlavor class is similar to the JDK's 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 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 ActivationDataFlavor
      mimeType - the MIME type of the data represented by this class
      humanPresentableName - 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 ActivationDataFlavor
      humanPresentableName - 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 class
      humanPresentableName - the human presentable name of the flavor
  • Method Details

    • 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 the isMimeTypeEqual method.
      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)
      Overrides:
      equals in class Object
      Parameters:
      o - the Object to compare with
      Returns:
      true if the object is also an ActivationDataFlavor and is equal to this
    • equals

      @Deprecated public boolean equals(String s)
      Deprecated.
      As inconsistent with hashCode() contract, use isMimeTypeEqual(String) instead.
      Compares only the mimeType against the passed in String and representationClass is not considered in the comparison. If representationClass needs to be compared, then equals(new DataFlavor(s)) may be used.
      Parameters:
      s - the mimeType to compare.
      Returns:
      true if the String (MimeType) is equal; false otherwise or if s is null
    • hashCode

      public int hashCode()
      Returns hash code for this ActivationDataFlavor. For two equal ActivationDataFlavors, hash codes are equal. For the String that matches ActivationDataFlavor.equals(String), it is not guaranteed that ActivationDataFlavor's hash code is equal to the hash code of the String.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code for this ActivationDataFlavor
    • 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 name
      parameterValue - 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