Project Wonder 5.0

er.attachment.utils
Class ERMimeType

java.lang.Object
  extended by er.attachment.utils.ERMimeType
Direct Known Subclasses:
ERGlobMimeType

public class ERMimeType
extends java.lang.Object

ERMimeType stores the metadata about a particular mime type.

Author:
mschrag

Constructor Summary
ERMimeType(java.lang.String name, java.lang.String mimeType, java.lang.String uti, com.webobjects.foundation.NSArray<java.lang.String> extensions)
          Constructs an ERMimeType.
 
Method Summary
 com.webobjects.foundation.NSArray<java.lang.String> extensions()
          Returns the list of extensions that map to this mime type.
 ERGlobMimeType globMimeType()
          Returns the glob type of this mime type (image/pdf=>image/*).
 boolean isAudio()
          Returns true for audio/ mime types.
 boolean isImage()
          Returns true for image/ mime types.
 boolean isRepresentedByExtension(java.lang.String extension)
          Returns true if this mime type represents a file of the given extension.
 boolean isVideo()
          Returns true for video/ mime types.
 boolean matches(ERMimeType otherMimeType)
          Supports glob mime types for comparison, so image/* matches image/jpeg.
 boolean matchesExactly(ERMimeType mimeType)
          Returns true if this mime type exactly matches the other, meaning, the underlying mime type strings are identical.
 java.lang.String mimeType()
          Returns the mime type string representation.
 java.lang.String name()
          Returns the name of this mime type.
 java.lang.String primaryExtension()
          Returns the "primary" extension for this mime type.
 java.lang.String subtype()
          Returns the part of the mime type after the "/".
 java.lang.String toString()
           
 java.lang.String type()
          Returns the part of the mime type before the "/".
 java.lang.String uti()
          Returns the universal type identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ERMimeType

public ERMimeType(java.lang.String name,
                  java.lang.String mimeType,
                  java.lang.String uti,
                  com.webobjects.foundation.NSArray<java.lang.String> extensions)
Constructs an ERMimeType.

Parameters:
name - the display name of the mime type ("Portable Network Graphics")
mimeType - the mime type string ("image/jpg")
uti - the universal type identifier that corresponds to this mime type ("public.jpeg")
extensions - the array of file extensions for this mime type ("jpg", "jpeg", etc)
Method Detail

globMimeType

public ERGlobMimeType globMimeType()
Returns the glob type of this mime type (image/pdf=>image/*).

Returns:
the glob type of this mime type

matchesExactly

public boolean matchesExactly(ERMimeType mimeType)
Returns true if this mime type exactly matches the other, meaning, the underlying mime type strings are identical.

Parameters:
mimeType - the other mime type to compare
Returns:
true if the mime type strings are identical

matches

public boolean matches(ERMimeType otherMimeType)
Supports glob mime types for comparison, so image/* matches image/jpeg.

Parameters:
otherMimeType - the other mime type to compare against
Returns:
true if the mime types are compatible

name

public java.lang.String name()
Returns the name of this mime type.

Returns:
the name of this mime type

mimeType

public java.lang.String mimeType()
Returns the mime type string representation.

Returns:
the mime type string representation

uti

public java.lang.String uti()
Returns the universal type identifier.

Returns:
the universal type identifier

extensions

public com.webobjects.foundation.NSArray<java.lang.String> extensions()
Returns the list of extensions that map to this mime type.

Returns:
the list of extensions that map to this mime type

isRepresentedByExtension

public boolean isRepresentedByExtension(java.lang.String extension)
Returns true if this mime type represents a file of the given extension.

Parameters:
extension - the extension to lookup
Returns:
true if the extension matches one of the extensions in this mime type

primaryExtension

public java.lang.String primaryExtension()
Returns the "primary" extension for this mime type. The primary extension is the first extension in the list, and generally should be considered the most common extension to use for the type.

Returns:
the primary extension (or "" if there are no extensions)

type

public java.lang.String type()
Returns the part of the mime type before the "/".

Returns:
the type of the mime type

subtype

public java.lang.String subtype()
Returns the part of the mime type after the "/".

Returns:
the subtype of the mime type

isImage

public boolean isImage()
Returns true for image/ mime types.

Returns:
true for image/ mime types

isVideo

public boolean isVideo()
Returns true for video/ mime types.

Returns:
true for video/ mime types

isAudio

public boolean isAudio()
Returns true for audio/ mime types.

Returns:
true for audio/ mime types

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.