org.silverpeas.viewer
Class ViewerContext

java.lang.Object
  extended by org.silverpeas.viewer.ViewerContext
All Implemented Interfaces:
Cloneable

public class ViewerContext
extends Object
implements Cloneable

This class permits to handled a context during the conversion processes.

Author:
Yohann Chastagnier

Constructor Summary
protected ViewerContext(String originalFileName, File originalSourceFile)
           
 
Method Summary
protected  ViewerContext clone()
           
static ViewerContext from(SimpleDocument document)
          Initializes a context from an instance of SimpleDocument.
 String getOriginalFileName()
          Gets the name of the original file.
 File getOriginalSourceFile()
          Gets the original file.
 String getViewId()
          Gets the identifier associated to the current conversion processes for viewing.
 TemporaryWorkspaceTranslation getWorkspace()
          Gets the workspace into which the processes will write the results.
 boolean isCacheRequired()
          Indicates if cache is required.
 boolean isProcessingCache()
          Indicates if the current process is the one which is in charge of performing the conversion tasks.
 void processingCache()
          Sets into context that the current process is in charge of the conversion tasks.
 ViewerContext withUniqueDocumentId(String uniqueDocumentId)
          Sets a unique identifier associated to the current document to convert.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewerContext

protected ViewerContext(String originalFileName,
                        File originalSourceFile)
Method Detail

from

public static ViewerContext from(SimpleDocument document)
Initializes a context from an instance of SimpleDocument.

Parameters:
document - the SimpleDocument for which the file must be converted.
Returns:
an instance of ViewerContext initialized from the given SimpleDocument.

getOriginalFileName

public String getOriginalFileName()
Gets the name of the original file.

Returns:
the name as string.

getOriginalSourceFile

public File getOriginalSourceFile()
Gets the original file.

Returns:
the File that represents the original file.

getWorkspace

public TemporaryWorkspaceTranslation getWorkspace()
Gets the workspace into which the processes will write the results.

Returns:
the File that represents the workspace.

getViewId

public String getViewId()
Gets the identifier associated to the current conversion processes for viewing.
If an id has been explicitly set, then it is returned.
Otherwise, a unique id is computed.

Returns:
a unique identifier as string.

withUniqueDocumentId

public ViewerContext withUniqueDocumentId(String uniqueDocumentId)
Sets a unique identifier associated to the current document to convert.
This id is used by getViewId() in order to compute the final unique identifier.

Parameters:
uniqueDocumentId - a unique document identifier (please be careful about 'unique' word).
Returns:
the current context instance.

isCacheRequired

public boolean isCacheRequired()
Indicates if cache is required.

Returns:
true if required, false otherwise.

isProcessingCache

public boolean isProcessingCache()
Indicates if the current process is the one which is in charge of performing the conversion tasks.

Returns:
true if the current process is in charge, false otherwise.

processingCache

public void processingCache()
Sets into context that the current process is in charge of the conversion tasks.


clone

protected ViewerContext clone()
Overrides:
clone in class Object


Copyright © 2016 Silverpeas. All Rights Reserved.