Saros
Distributed Collaborative Editing and Distributed Party Programming
de.fu_berlin.inf.dpp.activities.FileActivity Class Reference
Inheritance diagram for de.fu_berlin.inf.dpp.activities.FileActivity:
de.fu_berlin.inf.dpp.activities.AbstractResourceActivity de.fu_berlin.inf.dpp.activities.AbstractActivity de.fu_berlin.inf.dpp.activities.IResourceActivity de.fu_berlin.inf.dpp.activities.IActivity de.fu_berlin.inf.dpp.activities.IActivity de.fu_berlin.inf.dpp.activities.RecoveryFileActivity

List of all members.

Public Types

enum  Purpose { ACTIVITY, RECOVERY }
enum  Type { CREATED, REMOVED, MOVED }

Public Member Functions

 FileActivity (User source, Type type, SPath newPath, SPath oldPath, byte[] content, String encoding, Purpose purpose)
boolean isValid ()
SPath getOldPath ()
Type getType ()
byte[] getContent ()
String getEncoding ()
String toString ()
int hashCode ()
boolean equals (Object obj)
void dispatch (IActivityReceiver receiver)
boolean isRecovery ()

Static Public Member Functions

static FileActivity created (User source, SPath path, byte[] content, String encoding, Purpose purpose)
static FileActivity moved (User source, SPath destPath, SPath sourcePath, byte[] content, String encoding)
static FileActivity removed (User source, SPath path, Purpose purpose)

Protected Attributes

final SPath oldPath
final Type type
final Purpose purpose
String encoding
final byte[] content

Member Enumeration Documentation

Enumeration used to distinguish file activities which are caused as part of a consistency recovery and those used as regular activities.

Enumerator:
ACTIVITY 
RECOVERY 
Enumerator:
CREATED 

The file was created or modified, but the path stayed the same.

REMOVED 

The file was deleted.

MOVED 

The path of the file changed. The content might have changed, too.


Constructor & Destructor Documentation

de.fu_berlin.inf.dpp.activities.FileActivity.FileActivity ( User  source,
Type  type,
SPath  newPath,
SPath  oldPath,
byte[]  content,
String  encoding,
Purpose  purpose 
)

Generic constructor for FileActivitys

Parameters:
sourcethe user who is the source (originator) of this Activity
newPathwhere to save the data (if Type#CREATED), destination of a move (if Type#MOVED), file to remove (if Type#REMOVED); never null
oldPathif type is Type#MOVED, the path from where the file was moved (null otherwise)
contentcontent of the file denoted by the path (only valid for Type#CREATED and Type#MOVED)
encodingthe encoding the content is encoded with or null

Member Function Documentation

static FileActivity de.fu_berlin.inf.dpp.activities.FileActivity.created ( User  source,
SPath  path,
byte[]  content,
String  encoding,
Purpose  purpose 
) [static]

Utility method for creating a FileActivity of type Type#CREATED for a given path.

Parameters:
pathpath referencing the newly created file
contentcontent of the file denoted by the path
encodingthe encoding the content is encoded with or null
void de.fu_berlin.inf.dpp.activities.FileActivity.dispatch ( IActivityReceiver  receiver)
boolean de.fu_berlin.inf.dpp.activities.FileActivity.equals ( Object  obj)
byte [] de.fu_berlin.inf.dpp.activities.FileActivity.getContent ( )
Returns:
the content of this file or null if not available

Important: the content of the array must not be changed

See also:
created(User, SPath, byte[], String, Purpose)
moved(User, SPath, SPath, byte[], String)
String de.fu_berlin.inf.dpp.activities.FileActivity.getEncoding ( )

Returns the encoding the content is encoded with.

Returns:
the encoding or null if it is not available
SPath de.fu_berlin.inf.dpp.activities.FileActivity.getOldPath ( )

Returns the old/source path in case this Activity represents a moving of files.

Type de.fu_berlin.inf.dpp.activities.FileActivity.getType ( )
int de.fu_berlin.inf.dpp.activities.FileActivity.hashCode ( )
boolean de.fu_berlin.inf.dpp.activities.FileActivity.isRecovery ( )
boolean de.fu_berlin.inf.dpp.activities.FileActivity.isValid ( )
static FileActivity de.fu_berlin.inf.dpp.activities.FileActivity.moved ( User  source,
SPath  destPath,
SPath  sourcePath,
byte[]  content,
String  encoding 
) [static]

Builder for moving files (type Type#MOVED).

Parameters:
sourceJID of the origin user
destPathpath where the file moved to
sourcePathpath where the file moved from
contentcontent of the file denoted by the path, may be null to indicate that the file content was not changed when moved
encodingthe encoding the content is encoded with or null
static FileActivity de.fu_berlin.inf.dpp.activities.FileActivity.removed ( User  source,
SPath  path,
Purpose  purpose 
) [static]

Builder for removing files (type Type#REMOVED)

Parameters:
paththe path of the file to remove
String de.fu_berlin.inf.dpp.activities.FileActivity.toString ( )

Member Data Documentation

 All Classes Namespaces Files Functions Variables Enumerations