Package org.opencms.file
Class CmsFile
- java.lang.Object
-
- org.opencms.file.CmsResource
-
- org.opencms.file.CmsFile
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<I_CmsResource>
,I_CmsResource
- Direct Known Subclasses:
CmsHistoryFile
public class CmsFile extends CmsResource
A file resource in the OpenCms VFS.A file resource is a CmsResource that contains an additional byte array of binary data, which is the file content.
A file object is not allowed to have sub-resources.
- Since:
- 6.0.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opencms.file.CmsResource
CmsResource.CmsResourceCopyMode, CmsResource.CmsResourceDeleteMode, CmsResource.CmsResourceUndoMode
-
Nested classes/interfaces inherited from interface org.opencms.file.I_CmsResource
I_CmsResource.CmsResourceAttribute
-
-
Field Summary
-
Fields inherited from class org.opencms.file.CmsResource
COPY_AS_NEW, COPY_AS_SIBLING, COPY_PRESERVE_SIBLING, DATE_EXPIRED_DEFAULT, DATE_RELEASED_DEFAULT, DATE_RELEASED_EXPIRED_IGNORE, DELETE_PRESERVE_SIBLINGS, DELETE_REMOVE_SIBLINGS, FLAG_INTERNAL, FLAG_LABELED, FLAG_TEMPFILE, m_dateContent, m_length, NAME_CONSTRAINTS, STATE_CHANGED, STATE_DELETED, STATE_KEEP, STATE_NEW, STATE_UNCHANGED, TEMP_FILE_PREFIX, TOUCH_DATE_UNCHANGED, UNDO_CONTENT, UNDO_CONTENT_RECURSIVE, UNDO_MOVE_CONTENT, UNDO_MOVE_CONTENT_RECURSIVE, VFS_FOLDER_SITES, VFS_FOLDER_SYSTEM
-
Fields inherited from interface org.opencms.file.I_CmsResource
COMPARE_DATE_LAST_MODIFIED, COMPARE_DATE_RELEASED, COMPARE_ROOT_PATH, COMPARE_ROOT_PATH_IGNORE_CASE, COMPARE_ROOT_PATH_IGNORE_CASE_FOLDERS_FIRST
-
-
Constructor Summary
Constructors Constructor Description CmsFile(CmsResource resource)
Constructor, creates a new file Object from the given resource with an empty byte array as file content, if the resource does not implement a file.CmsFile(CmsUUID structureId, CmsUUID resourceId, java.lang.String path, int type, int flags, CmsUUID projectId, CmsResourceState state, long dateCreated, CmsUUID userCreated, long dateLastModified, CmsUUID userLastModified, long dateReleased, long dateExpired, int linkCount, int length, long dateContent, int version, byte[] content)
Constructor, creates a new file object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Returns a clone of this Objects instance.byte[]
getContents()
Returns the content of this file.int
getLength()
Returns the content length of this resource.boolean
isFile()
boolean
isFolder()
boolean
isTemporaryFile()
Returnstrue
if this resource is a temporary file.void
setContents(byte[] value)
Sets the contents of this file.-
Methods inherited from class org.opencms.file.CmsResource
checkResourceName, compareTo, equals, getCopy, getDateContent, getDateCreated, getDateExpired, getDateLastModified, getDateReleased, getExtension, getFlags, getFolderPath, getName, getName, getParentFolder, getPathLevel, getPathPart, getProjectLastModified, getResourceId, getRootPath, getSiblingCount, getState, getStructureId, getTypeId, getUserCreated, getUserLastModified, getVersion, hashCode, isExpired, isFolder, isInternal, isInternalOrInInternalFolder, isLabeled, isReleased, isReleasedAndNotExpired, isTemporaryFileName, isTouched, setDateExpired, setDateLastModified, setDateReleased, setFlags, setInternal, setState, setType, setUserLastModified, toString
-
-
-
-
Constructor Detail
-
CmsFile
public CmsFile(CmsResource resource)
Constructor, creates a new file Object from the given resource with an empty byte array as file content, if the resource does not implement a file.- Parameters:
resource
- the base resource object to create a file from
-
CmsFile
public CmsFile(CmsUUID structureId, CmsUUID resourceId, java.lang.String path, int type, int flags, CmsUUID projectId, CmsResourceState state, long dateCreated, CmsUUID userCreated, long dateLastModified, CmsUUID userLastModified, long dateReleased, long dateExpired, int linkCount, int length, long dateContent, int version, byte[] content)
Constructor, creates a new file object.- Parameters:
structureId
- the id of this resources structure recordresourceId
- the id of this resources resource recordpath
- the filename of this resourcetype
- the type of this resourceflags
- the flags of this resourceprojectId
- the project id this resource was last modified instate
- the state of this resourcedateCreated
- the creation date of this resourceuserCreated
- the id of the user who created this resourcedateLastModified
- the date of the last modification of this resourceuserLastModified
- the id of the user who did the last modification of this resourcedateReleased
- the release date of this resourcedateExpired
- the expiration date of this resourcelinkCount
- the count of all siblings of this resourcelength
- the size of the file content of this resourcedateContent
- the date of the last modification of the content of this resourceversion
- the version number of this resourcecontent
- the binary content data of this file
-
-
Method Detail
-
clone
public java.lang.Object clone()
Returns a clone of this Objects instance.- Overrides:
clone
in classCmsResource
- Returns:
- a clone of this instance
-
getContents
public byte[] getContents()
Returns the content of this file.- Returns:
- the content of this file
-
getLength
public int getLength()
Description copied from class:CmsResource
Returns the content length of this resource.If the resource is a file, then this is the byte size of the file content. If the resource is a folder, then the size is always -1.
- Specified by:
getLength
in interfaceI_CmsResource
- Overrides:
getLength
in classCmsResource
- Returns:
- the content length of the content
- See Also:
CmsResource.getLength()
-
isFile
public boolean isFile()
Description copied from class:CmsResource
- Specified by:
isFile
in interfaceI_CmsResource
- Overrides:
isFile
in classCmsResource
- Returns:
- true if this resource is a file, false otherwise
- See Also:
CmsResource.isFile()
-
isFolder
public boolean isFolder()
Description copied from class:CmsResource
- Specified by:
isFolder
in interfaceI_CmsResource
- Overrides:
isFolder
in classCmsResource
- Returns:
- true if this resource is a folder, false otherwise
- See Also:
CmsResource.isFolder()
-
isTemporaryFile
public boolean isTemporaryFile()
Description copied from class:CmsResource
Returnstrue
if this resource is a temporary file.A resource is considered a temporary file it is a file where the
CmsResource.FLAG_TEMPFILE
flag has been set, or if the file name (without parent folders) starts with the prefix char'~'
(tilde).- Overrides:
isTemporaryFile
in classCmsResource
- Returns:
true
if the given resource name is a temporary file- See Also:
CmsResource.isTemporaryFile()
-
setContents
public void setContents(byte[] value)
Sets the contents of this file.This will also set the date content, but only if the content is already set.
- Parameters:
value
- the content of this file
-
-