org.jboss.shotoku
Interface Resource

All Known Subinterfaces:
Directory, Node

public interface Resource

Common parts of nodes and directories interfaces.

Author:
Adam Warski (adamw@aster.pl), Damon Sicore (damon@sicore.com)

Method Summary
 void copyTo(Directory dir, java.lang.String newName, java.lang.String logMessage)
          Copies this resource to the given directory.
 void delete()
          Deletes this node or directory (immediately, no save() is needed).
 void deleteProperty(java.lang.String propertyName)
          Deletes the the given property.
 ContentManager getContentManager()
          Gets the content manager from which this resource was obtained from.
 java.lang.String getFullName()
          Gets the full name of this resource, that is, path to this resource relative to the content manager this node was read from.
 long getLastModification()
          Gets the last modification time of this node.
 java.util.Date getLastModificationDate()
          Gets the last modification time of this node, represented as a date object.
 java.lang.String getName()
          Gets the name of this resource (node/ directory).
 Directory getParent()
          Gets a directory to which this node/ directory belongs.
 java.util.Map<java.lang.String,java.lang.String> getProperties()
          Gets a map of all properties associated with this resource.
 java.lang.String getProperty(java.lang.String propertyName)
          Gets the value of the given property.
 boolean hasModifications()
          Checks if this resource has any modifications (that is, if any of its properties are changed, or content; new resources will always return "true" before a save).
 void moveTo(Directory dir, java.lang.String logMessage)
          Moves this resource to the given directory.
 void save(java.lang.String logMessage)
          Saves modified properties and possibly content (in case of nodes).
 void setProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Sets the value of the given property.
 

Method Detail

copyTo

void copyTo(Directory dir,
            java.lang.String newName,
            java.lang.String logMessage)
            throws CopyException
Copies this resource to the given directory. This can't be called if this resource is new and not yet saved.

Parameters:
dir - Directory to copy this resource to. This can't be a new and not saved directory.
newName - New name of this resource (in directory dir after copying).
logMessage - Log message associated with this resource copy.
Throws:
CopyException

moveTo

void moveTo(Directory dir,
            java.lang.String logMessage)
            throws MoveException
Moves this resource to the given directory. This can't be called if this resource is new and not yet saved. This resource should not be used after performing this operation.

Parameters:
dir - Directory to move this resource to. This can't be a new and not saved directory.
logMessage - Log message associated with this resource move.
Throws:
MoveException

getProperties

java.util.Map<java.lang.String,java.lang.String> getProperties()
                                                               throws RepositoryException
Gets a map of all properties associated with this resource.

Returns:
A map of properties associated with this resource.
Throws:
RepositoryException

getProperty

java.lang.String getProperty(java.lang.String propertyName)
                             throws RepositoryException
Gets the value of the given property.

Parameters:
propertyName - Name of the property to get.
Returns:
Value of the given property.
Throws:
RepositoryException

deleteProperty

void deleteProperty(java.lang.String propertyName)
                    throws RepositoryException
Deletes the the given property.

Parameters:
propertyName - Name of the property to delete.
Throws:
RepositoryException

setProperty

void setProperty(java.lang.String propertyName,
                 java.lang.String propertyValue)
Sets the value of the given property. Only after saving this change will be persisted.

Parameters:
propertyName - Name of the property to set. It must begin with a character, and cannot contain any special characters (so the regexp to which a property name must match would be [a-z][a-z0-9]*).
propertyValue - Value of the property to set.

getParent

Directory getParent()
                    throws RepositoryException
Gets a directory to which this node/ directory belongs.

Returns:
A directory to which this node/ directory belongs. Null if this directory is already the root directory.
Throws:
RepositoryException

save

void save(java.lang.String logMessage)
          throws SaveException,
                 RepositoryException
Saves modified properties and possibly content (in case of nodes).

Parameters:
logMessage - Log message for saving this node/ directory.
Throws:
SaveException
RepositoryException

delete

void delete()
            throws DeleteException,
                   RepositoryException
Deletes this node or directory (immediately, no save() is needed). This resource should not be used after performing this operation.

Throws:
DeleteException
RepositoryException

getName

java.lang.String getName()
Gets the name of this resource (node/ directory).

Returns:
Name of this resource (node/ directory). An empty string, if this is the root directory.

getFullName

java.lang.String getFullName()
Gets the full name of this resource, that is, path to this resource relative to the content manager this node was read from.

Returns:
Full name of this resource.

hasModifications

boolean hasModifications()
Checks if this resource has any modifications (that is, if any of its properties are changed, or content; new resources will always return "true" before a save).

Returns:
True iff this resource has unsaved modifications.

getLastModification

long getLastModification()
                         throws RepositoryException
Gets the last modification time of this node.

Returns:
Last modification time of this node.
Throws:
RepositoryException

getLastModificationDate

java.util.Date getLastModificationDate()
                                       throws RepositoryException
Gets the last modification time of this node, represented as a date object.

Returns:
Last modification time of this node, represented as a date.
Throws:
RepositoryException

getContentManager

ContentManager getContentManager()
Gets the content manager from which this resource was obtained from.

Returns:
Content manager instance from which this resource was obtained from.


Copyright © -2006 . All Rights Reserved.