|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.EmbeddedFile
public final class EmbeddedFile
This class represents a file which may be embedded into a PDF document, either
by using the AnnotationFile
class or through the PDF.getEmbeddedFiles()
map.
Constructor Summary | |
---|---|
EmbeddedFile(File file)
Create a new EmbeddedFile object to embed the specified file. |
|
EmbeddedFile(InputStream in,
String name)
Set the content of this Embeddedfile to the specified InputStream. |
|
EmbeddedFile(PDF pdf,
String name)
Set the content of this EmbeddedFile to the specified PDF. |
Method Summary | |
---|---|
Date |
getCreationDate()
Return the Creation Date of this file, or null if not specified. |
InputStream |
getData()
Return the attached file as an InputStream, or null if the file
is not attached and is referenced by name only. |
String |
getDescription()
Return the description for this file as set by setDescription(java.lang.String) ,
or null if not set. |
Date |
getModDate()
Return the Last-modified Date of this file, or null if not specified. |
String |
getName()
Return the Filename of the file |
int |
getSize()
Return the size of the attached file, or -1 if not specified (note the file always has a size of course, but that size isn't always stored in the PDF. |
String |
getType()
Return the MIME type of this file attachment if specified, or null if
not specified. |
boolean |
isValid()
Returns true if the file matches the stored checksum or if no checksum is specified. |
void |
setCreationDate(Date date)
Set the Creation Date of this file. |
void |
setDescription(String desc)
Set the optional description for this file. |
void |
setModDate(Date date)
Set the Last-modified Date of this file. |
void |
setType(String mimetype)
Set the MIME type for this file attachment. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public EmbeddedFile(File file) throws IOException
file
- the file to embed
IOException
public EmbeddedFile(InputStream in, String name) throws IOException
in
- the InputStream to read from - must not be nullname
- the filename - must not be null
IOException
public EmbeddedFile(PDF pdf, String name) throws IOException
pdf
- the PDF to store as an embedded file.name
- the "filename" of the PDF to use when storing it internally.
IOException
Method Detail |
---|
public String getName()
public void setType(String mimetype)
mimetype
- the MIME type of the filepublic String getType()
null
if
not specified.
public void setDescription(String desc)
desc
- the description to usepublic String getDescription()
setDescription(java.lang.String)
,
or null
if not set.
public void setCreationDate(Date date)
date
- the Last-modified Date of this filepublic Date getCreationDate()
null
if not specified.
public void setModDate(Date date)
EmbeddedFile
from the EmbeddedFile(File)
constructor, this value is initialised to the
correct date.
date
- the Last-modified Date of this filepublic Date getModDate()
null
if not specified.
public int getSize()
public InputStream getData()
null
if the file
is not attached and is referenced by name only.
public boolean isValid()
Returns true if the file matches the stored checksum or if no checksum is specified. Note most files are stored compressed using the Flate algorithm, which is self-checksumming, so this method is a little redundant. However the MD5 checksum optionally stored with embedded files is much stronger, so we provide this method for completeness.
Note that if no checksum is stored this method returns true
,
so although a false
definitely indicates a corrupt file, a
true
doesn't guarantee that it isn't corrupt.
As this method calls the getData()
method internally, the InputStream
returned from that method must not be open prior to this call, otherwise
the checksum will almost certainly fail.
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |