|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mycore.datamodel.ifs.MCRFilesystemNode
org.mycore.datamodel.ifs.MCRFile
public class MCRFile
Represents a stored file with its metadata and content.
| Field Summary | |
|---|---|
protected MCRAudioVideoExtender |
avExtender
The optional extender for streaming audio/video files |
protected String |
contentTypeID
The ID of the content type of this file |
protected boolean |
isNew
Is true if this file is a new MCRFile and not retrieved from store * |
protected String |
md5
The md5 checksum that was built when content was read for this file |
protected String |
storageID
The ID that identifies the place where the store holds the content |
protected String |
storeID
The ID of the store that holds this file's content |
| Fields inherited from class org.mycore.datamodel.ifs.MCRFilesystemNode |
|---|
deleted, formatter, ID, label, lastModified, manager, name, ownerID, parentID, size |
| Constructor Summary | |
|---|---|
MCRFile(String name,
MCRDirectory parent)
Creates a new, empty MCRFile with the given filename in the parent MCRDirectory. |
|
MCRFile(String name,
MCRDirectory parent,
boolean doExistCheck)
Creates a new, empty MCRFile with the given filename in the parent MCRDirectory. |
|
MCRFile(String name,
String ownerID)
Creates a new and empty root MCRFile with the given filename, belonging to the given ownerID. |
|
MCRFile(String ID,
String parentID,
String ownerID,
String name,
String label,
long size,
GregorianCalendar date,
String storeID,
String storageID,
String fctID,
String md5)
Internal constructor, do not use on your own. |
|
| Method Summary | |
|---|---|
Document |
createXML()
Build a XML representation of all technical metadata of this MCRFile and its MCRAudioVideoExtender, if present. |
void |
delete()
Deletes this file and its content stored in the system. |
MCRAudioVideoExtender |
getAudioVideoExtender()
Returns the AudioVideoExtender in case this file is streaming audio/video and stored in a ContentStore that supports this |
byte[] |
getContentAsByteArray()
Gets the content of this file as a byte array |
InputStream |
getContentAsInputStream()
Gets an InputStream to read the content of this file from the underlying store. |
Document |
getContentAsJDOM()
|
String |
getContentAsString()
Gets the content of this file as a string, using the default encoding of the system environment |
String |
getContentAsString(String encoding)
Gets the content of this file as a string, using the given encoding |
protected MCRContentStore |
getContentStore()
Returns the MCRContentStore instance that holds the content of this file |
void |
getContentTo(File target)
Writes the content of this file to a file on the local filesystem |
void |
getContentTo(OutputStream target)
Writes the content of this file to a target output stream. |
MCRFileContentType |
getContentType()
Gets the content type of this file |
String |
getContentTypeID()
Gets the ID of the content type of this file |
String |
getExtension()
Returns the file extension of this file's name |
static MCRFile |
getFile(String ID)
Returns the MCRFile with the given ID. |
String |
getMD5()
Returns the MD5 checksum for this file |
static MCRFile |
getRootFile(String ownerID)
Returns the root MCRFile that has no parent and is logically owned by the object with the given ID. |
String |
getStorageID()
Returns the storage ID that identifies the place where the MCRContentStore has stored the content of this file |
String |
getStoreID()
Returns the ID of the MCRContentStore implementation that holds the content of this file |
boolean |
hasAudioVideoExtender()
Returns true, if this file is stored in a content store that provides an MCRAudioVideoExtender for audio/video streaming and additional metadata |
void |
setContentFrom(byte[] source)
Reads the content of this file from a byte array and stores it in an MCRContentStore. |
void |
setContentFrom(Document xml)
Sets the content of this file from a JDOM xml document. |
void |
setContentFrom(File source)
Reads the content of this file from a source file in the local filesystem and stores it in an MCRContentStore. |
void |
setContentFrom(InputStream source)
Reads the content of this file from the source InputStream and stores it in an MCRContentStore. |
long |
setContentFrom(InputStream source,
boolean storeContentChange)
|
void |
setContentFrom(String source)
Reads the content of this file from a java.lang.String and stores its text as bytes, encoded in the default encoding of the platform where this is running. |
void |
setContentFrom(String source,
String encoding)
Reads the content of this file from a java.lang.String and stores its text as bytes, encoded in the encoding given, in an MCRContentStore. |
void |
storeContentChange(long sizeDiff)
|
String |
toString()
|
| Methods inherited from class org.mycore.datamodel.ifs.MCRFilesystemNode |
|---|
checkName, ensureNotDeleted, getAbsolutePath, getAdditionalData, getAllAdditionalData, getID, getLabel, getLastModified, getName, getNode, getOwnerID, getParent, getParentID, getPath, getRootDirectory, getRootNode, getSize, getSizeFormatted, getSizeFormatted, hasParent, removeAdditionalData, removeAllAdditionalData, setAdditionalData, setLabel, setName, storeNew |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.mycore.datamodel.ifs.MCRFileReader |
|---|
getID, getPath, getSize |
| Field Detail |
|---|
protected String storeID
protected String storageID
protected String contentTypeID
protected String md5
protected MCRAudioVideoExtender avExtender
protected boolean isNew
| Constructor Detail |
|---|
public MCRFile(String name,
String ownerID)
name - the filename of the new MCRFileownerID - any ID String of the logical owner of this file
public MCRFile(String name,
MCRDirectory parent)
name - the filename of the new MCRFileparent - the parent directory that will contain the new child
MCRUsageException - if that directory already contains a child with that name
public MCRFile(String name,
MCRDirectory parent,
boolean doExistCheck)
name - the filename of the new MCRFileparent - the parent directory that will contain the new childdoExistCheck - checks if file with that Name already exists
MCRUsageException - if that directory already contains a child with that name
MCRFile(String ID,
String parentID,
String ownerID,
String name,
String label,
long size,
GregorianCalendar date,
String storeID,
String storageID,
String fctID,
String md5)
| Method Detail |
|---|
public static MCRFile getFile(String ID)
ID - the unique ID of the MCRFile to return
public static MCRFile getRootFile(String ownerID)
ownerID - the ID of the logical owner of that file
public String getExtension()
getExtension in interface MCRFileReaderpublic String getMD5()
public String getStoreID()
getStoreID in interface MCRFileReaderpublic String getStorageID()
getStorageID in interface MCRFileReaderprotected MCRContentStore getContentStore()
public void setContentFrom(String source)
throws MCRPersistenceException
source - the String that is the file's content
MCRPersistenceException
public void setContentFrom(String source,
String encoding)
throws MCRPersistenceException,
UnsupportedEncodingException
source - the String that is the file's contentencoding - the character encoding to use to store the String as bytes
MCRPersistenceException
UnsupportedEncodingException
public void setContentFrom(File source)
throws MCRPersistenceException
source - the file in the local host's filesystem thats content should be imported
MCRPersistenceException
public void setContentFrom(byte[] source)
throws MCRPersistenceException
source - the file's content
MCRPersistenceExceptionpublic void setContentFrom(Document xml)
xml - the JDOM xml document that should be stored as file content
public void setContentFrom(InputStream source)
throws MCRPersistenceException
source - the source for the file's content bytes
MCRPersistenceException
public long setContentFrom(InputStream source,
boolean storeContentChange)
throws MCRPersistenceException
MCRPersistenceExceptionpublic void storeContentChange(long sizeDiff)
public void delete()
throws MCRPersistenceException
delete in class MCRFilesystemNodeMCRPersistenceException
public InputStream getContentAsInputStream()
throws IOException
IOException
public void getContentTo(OutputStream target)
throws MCRPersistenceException
target - the output stream to write the content to
MCRPersistenceException
public void getContentTo(File target)
throws MCRPersistenceException,
IOException
target - the local file to write the content to
MCRPersistenceException
IOException
public byte[] getContentAsByteArray()
throws MCRPersistenceException
MCRPersistenceException
public String getContentAsString()
throws MCRPersistenceException
MCRPersistenceException
public String getContentAsString(String encoding)
throws MCRPersistenceException,
UnsupportedEncodingException
encoding - the character encoding to use
MCRPersistenceException
UnsupportedEncodingException
public Document getContentAsJDOM()
throws MCRPersistenceException,
IOException,
JDOMException
MCRPersistenceException
IOException
JDOMExceptionpublic boolean hasAudioVideoExtender()
public MCRAudioVideoExtender getAudioVideoExtender()
public String getContentTypeID()
getContentTypeID in interface MCRFileReaderpublic MCRFileContentType getContentType()
getContentType in interface MCRFileReaderpublic String toString()
toString in class MCRFilesystemNodepublic Document createXML()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||