public class ContentPackage extends java.lang.Object implements IAutoCloseable
ContentPart
Modifier and Type | Method and Description |
---|---|
ContentPart |
clonePart(ContentPart part)
Adds an existing part to this package.
|
void |
close()
Deletes native counterpart of this auto closable object
|
ContentPart |
createPart(java.lang.String type)
Appends a new part to this package.
|
void |
extractObject(java.lang.String url,
java.io.File file)
Extracts an object from this package to a given file.
|
ParameterSet |
getMetadata()
Returns this package's metadata as a parameter set.
|
ContentPart |
getPart(int index)
Returns the part at the specified index.
|
ContentPart |
getPart(java.lang.String id)
Returns the specified part.
|
int |
getPartCount()
Returns the number of parts in this package.
|
int |
indexOfPart(ContentPart part)
Returns the index of a given part.
|
boolean |
isClosed()
Tells whether the
close() method has been called. |
void |
removePart(ContentPart part)
Removes the specified part.
|
void |
save()
Saves all ongoing modifications made to this package.
|
void |
saveAs(java.io.File file)
Saves all ongoing modifications made to this package, to a new file.
|
void |
saveToTemp()
Saves all ongoing modifications made to this package to a temporary folder.
|
void |
setMetadata(ParameterSet parameters)
Set this package's metadata with the given parameter set.
|
public final void close()
IAutoCloseable
close
in interface IAutoCloseable
public final boolean isClosed()
close()
method has been called. Once an object
is closed any method will throw IllegalStateException
.true
if this object is closed.public final void save() throws java.io.IOException
java.io.IOException
- when an I/O operation fails.public final void saveToTemp() throws java.io.IOException
save()
.
Note: by default temporary folder is located in the same directory as this
package, and named by appending -files
to this package's name.
Note: temporary folder location can be set via the
content-package.temp-folder
configuration property.
java.io.IOException
- when an I/O operation fails.public final void saveAs(java.io.File file) throws java.io.IOException
file
- the new file name.java.io.IOException
- when an I/O operation fails.public final int getPartCount()
public final ContentPart getPart(int index) throws java.lang.IndexOutOfBoundsException
index
- the index of the requested part.java.lang.IndexOutOfBoundsException
- when index
is out of range.public final ContentPart getPart(java.lang.String id) throws java.lang.IllegalArgumentException
id
- the identifier of the requested part.java.lang.IllegalArgumentException
- when no part is associated with identifier id
.public final int indexOfPart(ContentPart part)
part
- the part.public final ContentPart createPart(java.lang.String type) throws java.lang.IllegalArgumentException
type
- the type of part.java.lang.IllegalArgumentException
- when type
is not a valid ContentPart type.public final void removePart(ContentPart part) throws java.lang.IllegalArgumentException
part
- the part to remove.java.lang.IllegalArgumentException
- when part does not belong to this package.public final ContentPart clonePart(ContentPart part)
Note: Part modifications that have not been saved (to temporary directory or to an actual package file) will not be imported.
Note: The part can be an existing part from this package or from another open package.
part
- the part to clone into this package.java.lang.IllegalArgumentException
- when part
is not valid.public final void extractObject(java.lang.String url, java.io.File file) throws java.io.IOException, java.lang.IllegalArgumentException
url
- URL of the object.file
- destination file.java.lang.IllegalArgumentException
- when no object named url
exists.java.io.IOException
- when an I/O operation fails.public final ParameterSet getMetadata()
public final void setMetadata(ParameterSet parameters)
parameters
- the metadata.