cmsresource.java
来自「找了很久才找到到源代码」· Java 代码 · 共 1,296 行 · 第 1/4 页
JAVA
1,296 行
/**
* Returns the change state of this resource.<p>
*
* This may be {@link CmsResource#STATE_UNCHANGED},
* {@link CmsResource#STATE_CHANGED}, {@link CmsResource#STATE_NEW}
* or {@link CmsResource#STATE_DELETED}.<p>
*
* @return the state of this resource
*/
public CmsResourceState getState() {
return m_state;
}
/**
* Returns the id of the structure record of this resource.<p>
*
* @return the id of the structure record of this resource
*/
public CmsUUID getStructureId() {
return m_structureId;
}
/**
* Returns the resource type id for this resource.<p>
*
* @return the resource type id of this resource
*/
public int getTypeId() {
return m_typeId;
}
/**
* Returns the user id of the {@link CmsUser} who created this resource.<p>
*
* @return the user id of the {@link CmsUser} who created this resource
*/
public CmsUUID getUserCreated() {
return m_userCreated;
}
/**
* Returns the user id of the {@link CmsUser} who made the last change on this resource.<p>
*
* @return the user id of the {@link CmsUser} who made the last change<p>
*/
public CmsUUID getUserLastModified() {
return m_userLastModified;
}
/**
* Returns the version number of this resource.<p>
*
* @return the version number of this resource
*/
public int getVersion() {
return m_version;
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
if (m_structureId != null) {
return m_structureId.hashCode();
}
return CmsUUID.getNullUUID().hashCode();
}
/**
* Returns <code>true</code> if this resource is expired at the given time according to the
* information stored in {@link #getDateExpired()}.<p>
*
* @param time the time to check the expiration date against
*
* @return <code>true</code> if this resource is expired at the given time
*
* @see #isReleased(long)
* @see #isReleasedAndNotExpired(long)
* @see #DATE_RELEASED_EXPIRED_IGNORE
* @see CmsResource#getDateReleased()
* @see CmsRequestContext#getRequestTime()
*/
public boolean isExpired(long time) {
return (time > m_dateExpired) && (time != DATE_RELEASED_EXPIRED_IGNORE);
}
/**
* Returns <code>true</code> if the resource is a {@link CmsFile}, that is not a {@link CmsFolder}.<p>
*
* @return true if this resource is a file, false otherwise
*/
public boolean isFile() {
return !m_isFolder;
}
/**
* Returns <code>true</code> if the resource is a {@link CmsFolder}, that is not a {@link CmsFile}.<p>
*
* @return true if this resource is a folder, false otherwise
*/
public boolean isFolder() {
return m_isFolder;
}
/**
* Returns <code>true</code> if the resource is marked as internal.<p>
*
* An internal resource can be read by the OpenCms API, but it can not be delivered
* by a direct request from an outside user.<p>
*
* For example if the resource <code>/internal.xml</code>
* has been set as marked as internal, this resource can not be requested by an HTTP request,
* so when a user enters <code>http:/www.myserver.com/opencms/opencms/internal.xml</code> in the browser
* this will generate a {@link CmsVfsResourceNotFoundException}.<p>
*
* This state is stored as bit 1 in the resource flags.<p>
*
* @return <code>true</code> if the resource is internal
*/
public boolean isInternal() {
return ((m_flags & FLAG_INTERNAL) > 0);
}
/**
* Returns <code>true</code> if the resource has to be labeled with a special icon in the explorer view.<p>
*
* This state is stored as bit 2 in the resource flags.<p>
*
* @return <code>true</code> if the resource has to be labeled in the explorer view
*/
public boolean isLabeled() {
return ((m_flags & CmsResource.FLAG_LABELED) > 0);
}
/**
* Returns <code>true</code> if this resource is released at the given time according to the
* information stored in {@link #getDateReleased()}.<p>
*
* @param time the time to check the release date against
*
* @return <code>true</code> if this resource is released at the given time
*
* @see #isExpired(long)
* @see #isReleasedAndNotExpired(long)
* @see #DATE_RELEASED_EXPIRED_IGNORE
* @see CmsResource#getDateReleased()
* @see CmsRequestContext#getRequestTime()
*/
public boolean isReleased(long time) {
return (time > m_dateReleased) || (time == DATE_RELEASED_EXPIRED_IGNORE);
}
/**
* Returns <code>true</code> if this resource is valid at the given time according to the
* information stored in {@link #getDateReleased()} and {@link #getDateExpired()}.<p>
*
* A resource is valid if it is released and not yet expired.<p>
*
* @param time the time to check the release and expiration date against
*
* @return <code>true</code> if this resource is valid at the given time
*
* @see #isExpired(long)
* @see #isReleased(long)
* @see #DATE_RELEASED_EXPIRED_IGNORE
* @see CmsResource#getDateReleased()
* @see CmsRequestContext#getRequestTime()
*/
public boolean isReleasedAndNotExpired(long time) {
return ((time < m_dateExpired) && (time > m_dateReleased)) || (time == DATE_RELEASED_EXPIRED_IGNORE);
}
/**
* Returns <code>true</code> if this resource was touched.<p>
*
* @return <code>true</code> if this resource was touched
*/
public boolean isTouched() {
return m_isTouched;
}
/**
* Sets the expiration date this resource.<p>
*
* @param time the expiration date to set
*/
public void setDateExpired(long time) {
m_dateExpired = time;
}
/**
* Sets the date of the last modification of this resource.<p>
*
* @param time the last modification date to set
*/
public void setDateLastModified(long time) {
m_isTouched = true;
m_dateLastModified = time;
}
/**
* Sets the release date this resource.<p>
*
* @param time the release date to set
*/
public void setDateReleased(long time) {
m_dateReleased = time;
}
/**
* Sets the flags of this resource.<p>
*
* The resource flags integer is used as bit set that contains special information about the resource.
* The following methods internally use the resource flags:<ul>
* <li>{@link #isInternal()}
* <li>{@link #isLabeled()}
* </ul>
*
* @param flags the flags value to set
*/
public void setFlags(int flags) {
m_flags = flags;
}
/**
* Sets the state of this resource.<p>
*
* @param state the state to set
*/
public void setState(CmsResourceState state) {
m_state = state;
}
/**
* Sets the type of this resource.<p>
*
* @param type the type to set
*/
public void setType(int type) {
m_typeId = type;
}
/**
* Sets the user id of the user who changed this resource.<p>
*
* @param resourceLastModifiedByUserId the user id of the user who changed the resource
*/
public void setUserLastModified(CmsUUID resourceLastModifiedByUserId) {
m_userLastModified = resourceLastModifiedByUserId;
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
StringBuffer result = new StringBuffer();
result.append("[");
result.append(this.getClass().getName());
result.append(", path: ");
result.append(m_rootPath);
result.append(", structure id ");
result.append(m_structureId);
result.append(", resource id: ");
result.append(m_resourceId);
result.append(", type id: ");
result.append(m_typeId);
result.append(", folder: ");
result.append(m_isFolder);
result.append(", flags: ");
result.append(m_flags);
result.append(", project: ");
result.append(m_projectLastModified);
result.append(", state: ");
result.append(m_state);
result.append(", date created: ");
result.append(new java.util.Date(m_dateCreated));
result.append(", user created: ");
result.append(m_userCreated);
result.append(", date lastmodified: ");
result.append(new java.util.Date(m_dateLastModified));
result.append(", user lastmodified: ");
result.append(m_userLastModified);
result.append(", date released: ");
result.append(new java.util.Date(m_dateReleased));
result.append(", date expired: ");
result.append(new java.util.Date(m_dateExpired));
result.append(", date content: ");
result.append(new java.util.Date(m_dateContent));
result.append(", size: ");
result.append(m_length);
result.append(", sibling count: ");
result.append(m_siblingCount);
result.append(", version: ");
result.append(m_version);
result.append("]");
return result.toString();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?