Package org.ghost4j
Class Ghostscript
- java.lang.Object
-
- org.ghost4j.Ghostscript
-
public class Ghostscript extends java.lang.ObjectClass representing the Ghostscript interpreter.
-
-
Field Summary
Fields Modifier and Type Field Description private static DisplayCallbackdisplayCallbackDisplay callback used to handle display.private static DisplayDatadisplayDataStores display data when working with display callback.private static GhostscriptinstanceHolds singleton instance.private static GhostscriptLibrary.display_callback_snativeDisplayCallbackHolds the native display callback.private static GhostscriptLibrary.gs_main_instance.ByReferencenativeInstanceByRefHolds Ghostscript interpreter native instance (C pointer).static java.lang.StringPROPERTY_NAME_ENCODINGName of the system property used to set the encoding to use for stdin.private static java.io.OutputStreamstdErrError output stream.private static java.io.InputStreamstdInStandard input stream.private static java.io.OutputStreamstdOutStandard output stream.
-
Constructor Summary
Constructors Modifier Constructor Description privateGhostscript()Private constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private GhostscriptLibrary.display_callback_sbuildNativeDisplayCallback(DisplayCallback displayCallback)Builds a native display callback from a DisplayCallback object.static voiddeleteInstance()Deletes the singleton instance of the Ghostscript object.voidexit()Exits Ghostscript interpreter.DisplayCallbackgetDisplayCallback()Gets the display callback set on the Ghostscript interpreter (may be null if not set).private DisplayDatagetDisplayData()static GhostscriptgetInstance()Singleton access method.private GhostscriptLibrary.gs_main_instance.ByReferencegetNativeInstanceByRef()Singleton factory method for getting a Ghostscript,interpreter instance.static GhostscriptRevisiongetRevision()Gets Ghostscript revision data.java.io.OutputStreamgetStdErr()Gets the error output stream of the Ghostscript interpreter (may be null if not set).java.io.InputStreamgetStdIn()Gets the standard input stream of the Ghostscript interpreter (may be null if not set).java.io.OutputStreamgetStdOut()Gets the standard output stream of the Ghostscript interpreter (may be null if not set).voidinitialize(java.lang.String[] args)Initializes Ghostscript interpreter.voidrunFile(java.lang.String fileName)Sends file Ghostscript interpreter.voidrunString(java.lang.String string)Sends command string to Ghostscript interpreter.voidsetDisplayCallback(DisplayCallback displayCallback)Sets a display callback for the Ghostscript interpreter.voidsetStdErr(java.io.OutputStream stdErr)Sets the error output stream of the Ghostscript interpreter.voidsetStdIn(java.io.InputStream stdIn)Sets the standard input stream of the Ghostscript interpreter.voidsetStdOut(java.io.OutputStream stdOut)Sets the standard output stream of the Ghostscript interpreter.
-
-
-
Field Detail
-
PROPERTY_NAME_ENCODING
public static final java.lang.String PROPERTY_NAME_ENCODING
Name of the system property used to set the encoding to use for stdin.- See Also:
- Constant Field Values
-
nativeInstanceByRef
private static GhostscriptLibrary.gs_main_instance.ByReference nativeInstanceByRef
Holds Ghostscript interpreter native instance (C pointer).
-
instance
private static Ghostscript instance
Holds singleton instance.
-
stdIn
private static java.io.InputStream stdIn
Standard input stream.
-
stdOut
private static java.io.OutputStream stdOut
Standard output stream.
-
stdErr
private static java.io.OutputStream stdErr
Error output stream.
-
displayCallback
private static DisplayCallback displayCallback
Display callback used to handle display.
-
displayData
private static DisplayData displayData
Stores display data when working with display callback.
-
nativeDisplayCallback
private static GhostscriptLibrary.display_callback_s nativeDisplayCallback
Holds the native display callback.
-
-
Method Detail
-
getInstance
public static Ghostscript getInstance()
Singleton access method.- Returns:
- The singleton instance.
-
getDisplayCallback
public DisplayCallback getDisplayCallback()
Gets the display callback set on the Ghostscript interpreter (may be null if not set).- Returns:
- The DisplayCallback or null
-
setDisplayCallback
public void setDisplayCallback(DisplayCallback displayCallback)
Sets a display callback for the Ghostscript interpreter.- Parameters:
displayCallback- DisplayCallback object
-
getStdErr
public java.io.OutputStream getStdErr()
Gets the error output stream of the Ghostscript interpreter (may be null if not set).- Returns:
- The OutputStream or null
-
setStdErr
public void setStdErr(java.io.OutputStream stdErr)
Sets the error output stream of the Ghostscript interpreter.- Parameters:
stdErr- OutputStream object
-
getStdOut
public java.io.OutputStream getStdOut()
Gets the standard output stream of the Ghostscript interpreter (may be null if not set).- Returns:
- The OutputStream or null
-
setStdOut
public void setStdOut(java.io.OutputStream stdOut)
Sets the standard output stream of the Ghostscript interpreter.- Parameters:
stdOut- OutputStream object
-
getStdIn
public java.io.InputStream getStdIn()
Gets the standard input stream of the Ghostscript interpreter (may be null if not set).- Returns:
- The InputStream or null
-
setStdIn
public void setStdIn(java.io.InputStream stdIn)
Sets the standard input stream of the Ghostscript interpreter.- Parameters:
stdIn- InputStream object
-
getNativeInstanceByRef
private GhostscriptLibrary.gs_main_instance.ByReference getNativeInstanceByRef() throws GhostscriptException
Singleton factory method for getting a Ghostscript,interpreter instance. Only called from class itself.- Returns:
- Ghostscript instance.
- Throws:
GhostscriptException
-
getDisplayData
private DisplayData getDisplayData()
-
getRevision
public static GhostscriptRevision getRevision()
Gets Ghostscript revision data.- Returns:
- Revision data.
-
initialize
public void initialize(java.lang.String[] args) throws GhostscriptExceptionInitializes Ghostscript interpreter.- Parameters:
args- Interpreter parameters. Use the same as Ghostscript command line arguments.- Throws:
GhostscriptException
-
buildNativeDisplayCallback
private GhostscriptLibrary.display_callback_s buildNativeDisplayCallback(DisplayCallback displayCallback) throws GhostscriptException
Builds a native display callback from a DisplayCallback object.- Parameters:
displayCallback- DisplayCallback to use.- Returns:
- The created native display callback.
- Throws:
GhostscriptException
-
exit
public void exit() throws GhostscriptExceptionExits Ghostscript interpreter. Must be called after initialize.- Throws:
GhostscriptException
-
runString
public void runString(java.lang.String string) throws GhostscriptExceptionSends command string to Ghostscript interpreter. Must be called after initialize method.- Parameters:
string- Command string- Throws:
GhostscriptException
-
runFile
public void runFile(java.lang.String fileName) throws GhostscriptExceptionSends file Ghostscript interpreter. Must be called after initialize method.- Parameters:
fileName- File name- Throws:
GhostscriptException
-
deleteInstance
public static void deleteInstance() throws GhostscriptExceptionDeletes the singleton instance of the Ghostscript object. This ensures that the native Ghostscrit interpreter instance is deleted. This method must be called if Ghostscript is not used anymore or maybe reinitialized.- Throws:
GhostscriptException
-
-