|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.domain.DomainObject
com.arsdigita.mimetypes.MimeType
Provides information about a single mime type, such as "image/gif"
or "text/plain". The mime-type itself may be accessed by calling
getMimeType()
; the user-readable label can be accessed by
calling getLabel()
.
This class is a member of each com.arsdigita.cms.Asset
; it is used in
(among other places) com.arsdigita.cms.ui.authoring.TextPageBody
and com.arsdigita.cms.ui.authoring.ArticleImage
in order to properly
handle uploaded files.
Field Summary | |
static String |
ALL_FILE_EXTENSIONS
|
static String |
BASE_DATA_OBJECT_TYPE
|
static String |
FILE_EXTENSION
|
static String |
JAVA_CLASS
|
static String |
LABEL
|
static String |
MIME_TYPE
|
static String |
OBJECT_TYPE
|
Fields inherited from class com.arsdigita.domain.DomainObject |
versionId |
Constructor Summary | |
MimeType(DataObject obj)
Construct a new MimeType from the given DataObject . |
|
MimeType(OID oid)
Load an existing MimeType . |
|
MimeType(String type,
String mimeType)
Construct a new MimeType with a given object type. |
Method Summary | |
protected void |
beforeSave()
Save this mime type and remember the correct java class |
static MimeType |
createMimeType(String mimeTypeName,
String javaClass,
String objectType)
Create a new instance of the specified Java subclass of MimeType. |
MimeTypeExtensionCollection |
getAllFileExtensions()
this returns a collection of Strings representing all of the file extensions associated with this mime type |
static MimeTypeCollection |
getAllMimeTypes()
Get all mime types in the system |
String |
getBaseDataObjectType()
Return the base data object type for this mime-type |
String |
getFileExtension()
Get the canonical file extension for the files of this mime type, f.ex. |
String |
getJavaClass()
Return the name of the proper Java subclass of this mime type |
String |
getLabel()
Get the user-readable label for this mime-type, such as "Plain Text" |
String |
getMimeType()
Get the actual mime-type, such as "text/plain" or "image/gif" |
String |
getPrefix()
Return the prefix of this mime type; the prefix is everything before the "/". |
String |
getSpecificObjectType()
Return the name of the specific object type of this mime type |
static MimeType |
guessMimeType(String fileExtension)
Guess the mime type from a file extension. |
static MimeType |
guessMimeTypeFromFile(String fileName)
Guess the mime type from the given file name. |
boolean |
hasFileExtension(String fileExtension)
this tells you if a particular extension is part of the mime type |
static MimeType |
loadMimeType(String mimeTypeName)
Return an instance of the specified mime type. |
static MimeTypeCollection |
searchMimeTypes(String startsWith)
Search all the mime types that starts with "startsWith". |
void |
setFileExtension(String value)
Set the the canonical file extension for the files of this mime type |
void |
setJavaClass(String javaClassName)
Set the name of the proper Java subclass of this mime type |
void |
setLabel(String value)
Set the user-readable label |
void |
setMimeType(String value)
Set the mime-type |
void |
setSpecificObjectType(String objectType)
Set the name of the specific object type of this mime type |
MimeType |
specialize()
Return a specific Java subclass of this mime type |
Methods inherited from class com.arsdigita.domain.DomainObject |
add, add, addToAssociation, afterDelete, afterSave, beforeDelete, clear, delete, disconnect, equals, get, getObjectType, getOID, getSession, hashCode, initialize, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, set, setAssociation, setAssociation, specializeDataObject, specializeDataObject, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String BASE_DATA_OBJECT_TYPE
public static final String MIME_TYPE
public static final String LABEL
public static final String FILE_EXTENSION
public static final String ALL_FILE_EXTENSIONS
public static final String JAVA_CLASS
public static final String OBJECT_TYPE
Constructor Detail |
public MimeType(OID oid) throws DataObjectNotFoundException
MimeType
.
public MimeType(DataObject obj)
MimeType
from the given DataObject
.
All subclasses must implement this constructor.
public MimeType(String type, String mimeType)
MimeType
with a given object type.
All subclasses must implement this constructor.
Method Detail |
public String getMimeType()
public void setMimeType(String value)
public String getLabel()
public void setLabel(String value)
public String getFileExtension()
public MimeTypeExtensionCollection getAllFileExtensions()
public boolean hasFileExtension(String fileExtension)
public void setFileExtension(String value)
public String getJavaClass()
public void setJavaClass(String javaClassName)
public String getSpecificObjectType()
public void setSpecificObjectType(String objectType)
public MimeType specialize()
public String getBaseDataObjectType()
getBaseDataObjectType
in class DomainObject
public String getPrefix()
public static MimeType loadMimeType(String mimeTypeName)
mimeTypeName
- The name of the mime type to load, such as
"text/html" or "image/jpeg"
public static MimeType createMimeType(String mimeTypeName, String javaClass, String objectType)
mimeTypeName
- The name of the mime type to create, such as
"text/html" or "image/jpeg"javaClass
- The Java class of the new mime typeobjectType
- The PDL object type of the new mime type
public static MimeType guessMimeType(String fileExtension)
fileExtension
- the extension associated with a mime type
public static MimeType guessMimeTypeFromFile(String fileName)
guessMimeType(java.lang.String)
to lookup the corresponding type. If the
file has no extension, this will always return null.
fileName
- the file name
protected void beforeSave()
beforeSave
in class DomainObject
public static MimeTypeCollection getAllMimeTypes()
public static MimeTypeCollection searchMimeTypes(String startsWith)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |