Package com.myscript.iink
Class ContentPackage
- java.lang.Object
- 
- com.myscript.iink.ContentPackage
 
- 
- All Implemented Interfaces:
- java.lang.AutoCloseable
 
 public class ContentPackage extends java.lang.Object implements java.lang.AutoCloseableA package stores the user content as a sorted collection of parts.- See Also:
- ContentPart
 
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull ContentPartclonePart(@NotNull ContentPart part)Adds an existing part to this package.voidclose()@NotNull ContentPartcreatePart(@NotNull java.lang.String type)Appends a new part to this package.voidextractObject(@NotNull java.lang.String url, @NotNull java.io.File file)Extracts an object from this package to a given file.protected voidfinalize()@NotNull ParameterSetgetMetadata()Returns this package's metadata as a parameter set.@NotNull ContentPartgetPart(int index)Returns the part at the specified index.@NotNull ContentPartgetPart(@NotNull java.lang.String id)Returns the specified part.intgetPartCount()Returns the number of parts in this package.@NotNull java.lang.StringgetPath()Returns the path of this package.intindexOfPart(@NotNull ContentPart part)Returns the index of a given part.booleanisClosed()Tells whether theclose()method has been called.voidremovePart(@NotNull ContentPart part)Removes the specified part.voidsave()Saves all ongoing modifications made to this package.voidsaveAs(@NotNull java.io.File file)Saves all ongoing modifications made to this package, to a new file.voidsaveToTemp()Saves all ongoing modifications made to this package to a temporary folder.voidsetMetadata(@NotNull ParameterSet parameters)Set this package's metadata with the given parameter set.
 
- 
- 
- 
Method Detail- 
finalizeprotected void finalize() throws java.lang.Throwable- Overrides:
- finalizein class- java.lang.Object
- Throws:
- java.lang.Throwable
 
 - 
closepublic final void close() - Specified by:
- closein interface- java.lang.AutoCloseable
 
 - 
isClosedpublic final boolean isClosed() Tells whether theclose()method has been called. Once an object is closed any method will throwIllegalStateException.- Returns:
- trueif this object is closed.
 
 - 
savepublic final void save() throws java.io.IOExceptionSaves all ongoing modifications made to this package.- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.io.IOException- when an I/O operation fails.
 
 - 
saveToTemppublic final void saveToTemp() throws java.io.IOExceptionSaves all ongoing modifications made to this package to a temporary folder. This operation is faster thansave().Note: by default temporary folder is located in the same directory as this package, and named by appending -filesto this package's name.Note: temporary folder location can be set via the content-package.temp-folderconfiguration property.- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.io.IOException- when an I/O operation fails.
 
 - 
saveAspublic final void saveAs(@NotNull @NotNull java.io.File file) throws java.io.IOExceptionSaves all ongoing modifications made to this package, to a new file.- Parameters:
- file- the new file name.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.io.IOException- when an I/O operation fails.
 
 - 
getPartCountpublic final int getPartCount() Returns the number of parts in this package.- Returns:
- the part count.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
 
 - 
getPart@NotNull public final @NotNull ContentPart getPart(int index) throws java.lang.IndexOutOfBoundsException Returns the part at the specified index.- Parameters:
- index- the index of the requested part.
- Returns:
- the requested part.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.lang.IndexOutOfBoundsException- when- indexis out of range.
 
 - 
getPart@NotNull public final @NotNull ContentPart getPart(@NotNull @NotNull java.lang.String id) throws java.lang.IllegalArgumentException Returns the specified part.- Parameters:
- id- the identifier of the requested part.
- Returns:
- the part.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.lang.IllegalArgumentException- when no part is associated with identifier- id.
 
 - 
indexOfPartpublic final int indexOfPart(@NotNull @NotNull ContentPart part)Returns the index of a given part.- Parameters:
- part- the part.
- Returns:
- the index of the part, or -1 if the part does not belong to this package.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.lang.IllegalStateException- when this package's part is closed.
 
 - 
createPart@NotNull public final @NotNull ContentPart createPart(@NotNull @NotNull java.lang.String type) throws java.lang.IllegalArgumentException Appends a new part to this package.- Parameters:
- type- the type of part.
- Returns:
- the newly created part.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.lang.IllegalArgumentException- when- typeis not a valid ContentPart type.
 
 - 
removePartpublic final void removePart(@NotNull @NotNull ContentPart part) throws java.lang.IllegalArgumentExceptionRemoves the specified part.- Parameters:
- part- the part to remove.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.lang.IllegalStateException- when this package's part is closed.
- java.lang.IllegalArgumentException- when part does not belong to this package.
- Since:
- 1.2
 
 - 
clonePart@NotNull public final @NotNull ContentPart clonePart(@NotNull @NotNull ContentPart part) Adds an existing part to this package.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. - Parameters:
- part- the part to clone into this package.
- Returns:
- the newly created part.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.lang.IllegalStateException- when this package's part is closed.
- java.lang.IllegalArgumentException- when- partis not valid.
- Since:
- 1.2
 
 - 
extractObjectpublic final void extractObject(@NotNull @NotNull java.lang.String url, @NotNull @NotNull java.io.File file) throws java.io.IOException, java.lang.IllegalArgumentExceptionExtracts an object from this package to a given file.- Parameters:
- url- URL of the object.
- file- destination file.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.lang.IllegalArgumentException- when no object named- urlexists.
- java.io.IOException- when an I/O operation fails.
 
 - 
getMetadata@NotNull public final @NotNull ParameterSet getMetadata() Returns this package's metadata as a parameter set.- Returns:
- the metadata.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
 
 - 
setMetadatapublic final void setMetadata(@NotNull @NotNull ParameterSet parameters)Set this package's metadata with the given parameter set.- Parameters:
- parameters- the metadata.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- java.lang.IllegalStateException- when- parametersis closed.
 
 - 
getPath@NotNull public final @NotNull java.lang.String getPath() Returns the path of this package.- Returns:
- the path.
- Throws:
- java.lang.IllegalStateException- when this package is closed.
- Since:
- 2.0
 
 
- 
 
-