sg.edu.nyp.drmPublisher
Class DMFile

java.lang.Object
  extended bysg.edu.nyp.drmPublisher.DMFile
All Implemented Interfaces:
java.io.Serializable

public class DMFile
extends java.lang.Object
implements java.io.Serializable

Author:
Pierre Trocme
See Also:
Serialized Form

Constructor Summary
DMFile(boolean binaryEncoding, java.io.File contentFile)
          Build a dm file handling Forward Lock for a specified file.
DMFile(java.io.File contentFile)
          A basic constructor.
 
Method Summary
 java.io.File generateDMFile(java.lang.String prefix)
          Write the DMFile described by this DMFile object.
 java.io.File generateDMFile(java.lang.String prefix, java.lang.String path)
          Write the DMFile described by this DMFile object.
 java.lang.String getBoundaryString()
           
 java.io.File getContentFile()
          Provide the file handled by this DMFile object.
 java.lang.String getContentType()
          Give the MIME content type handled by the DMFile object.
 boolean isBinaryEncoding()
          Tell whether the output file will be binary encoded or not.
 boolean isHasBeenWritten()
          Giev an indication about this DMFile .dm file generation.
 void setBinaryEncoding(boolean b)
          Set the encoding.
 boolean setBoundaryString(java.lang.String string)
          Set the BoundaryString.
 void setContentType(java.lang.String string)
          Set the contentType
 void setRandomBoundaryString()
          Set a random boundaryString.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DMFile

public DMFile(boolean binaryEncoding,
              java.io.File contentFile)
Build a dm file handling Forward Lock for a specified file.

Parameters:
binaryEncoding - To select binary or Base64 encoding.
contentFile - The file to be wrapped

DMFile

public DMFile(java.io.File contentFile)
A basic constructor.

Parameters:
contentFile - the file to be managed by this drm Object.
Method Detail

generateDMFile

public java.io.File generateDMFile(java.lang.String prefix,
                                   java.lang.String path)
                            throws java.io.IOException
Write the DMFile described by this DMFile object. If the boundaryString has not been set, it is randomly generated before generating the file.

Parameters:
prefix - the prefix to be append to the output filename
path - the directory where the file will be created
Returns:
the build file.
Throws:
java.io.IOException - if an I/O Exception occurs.

generateDMFile

public java.io.File generateDMFile(java.lang.String prefix)
                            throws java.io.IOException
Write the DMFile described by this DMFile object. If the boundaryString has not been set, it is randomly generated before generating the file.

Parameters:
prefix - the prefix to be append to the output filename
Returns:
the build file.
Throws:
java.io.IOException - if an I/O Exception occurs.

isBinaryEncoding

public boolean isBinaryEncoding()
Tell whether the output file will be binary encoded or not.

Returns:
true if the file will be bynary encoded, else base64encoding will be used.

getContentType

public java.lang.String getContentType()
Give the MIME content type handled by the DMFile object.

Returns:
the MIME content type.

getContentFile

public java.io.File getContentFile()
Provide the file handled by this DMFile object.

Returns:
the handled file.

setBinaryEncoding

public void setBinaryEncoding(boolean b)
Set the encoding.

Parameters:
b - the mode to be set

setContentType

public void setContentType(java.lang.String string)
Set the contentType

Parameters:
string - the MIME contentType to set.

isHasBeenWritten

public boolean isHasBeenWritten()
Giev an indication about this DMFile .dm file generation.

Returns:
true if the .dm file has been at least once generated, false else.

setRandomBoundaryString

public void setRandomBoundaryString()
Set a random boundaryString.


getBoundaryString

public java.lang.String getBoundaryString()
Returns:

setBoundaryString

public boolean setBoundaryString(java.lang.String string)
Set the BoundaryString. If the provided String is not RFC2046 compliant, this method does nothing.

Parameters:
string - the String to set
Returns:
true if the string is a RFC2046 conform boundary String, false in other cases.