Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jet.api
Class API

    java.lang.Object
      jet.api.API

Direct Known Subclasses:
  CatalogAPI, Designer

    public abstract class API

extends java.lang.Object

API class is an abstract class. It provides a series of editing methods for users.

Field Summary
`static int` | `BOOLEAN` Primitive property type values.
`static java.lang.String` | `CAT` The binary catalog file suffix.
`static int` | `CENTIMETER` The unit type value.
`static int` | `COLOR` Reference property type values.
`static int` | `DOUBLE` Primitive property type values.
`static int` | `ENUM` Reference property type values.
`static int` | `FLOAT` Primitive property type values.
`static int` | `INCH` The unit type value.
`static int` | `INTEGER` Primitive property type values.
`static int` | `LONG` Primitive property type values.
`static int` | `PIXEL` The unit type value.
`static int` | `REFERENCE` Reference property type values.
`static java.lang.String` | `RPT` The binary format report file suffix.
`static java.lang.String` | `SELFRPT` The binary self-contained report file suffix.
`static int` | `STRING` Reference property type values.
`static java.lang.String` | `TEXTRPT` The text format report file suffix.
`static int` | `UNKNOWN` Primitive property type values.
`static java.lang.String` | `XMLCAT` The XML format catalog file suffix.
`static java.lang.String` | `XMLRPT` The XML format report file suffix.

Constructor Summary
`API()`

Method Summary
`void` | `clearError()` Clears error message.
`void` | `clearMsg()` Clears messages of warning and error.
`void` | `clearWarning()` Clears warning message.
`void` | `closeLog()` Closes log.
`boolean` | `containPropName(java.lang.String handle, java.lang.String name)` Checks whether the property name is valid or not.
`abstract boolean` | `delete(java.lang.String handle)` Deletes an object from its parent node.
`boolean` | `getBool(java.lang.String handle, java.lang.String name)` Gets property value.
`java.lang.String[]` | `getChildren(java.lang.String objHandle)` Gets the handles of all children of an object.
`int` | `getClassType(java.lang.String handle)` Gets the object type of an object.
`java.awt.Color` | `getColor(java.lang.String handle, java.lang.String name)` Gets property value.
`double` | `getDouble(java.lang.String handle, java.lang.String name)` Gets property value.
`java.lang.String` | `getError()` Gets error message.
`float` | `getFloat(java.lang.String handle, java.lang.String name)` Gets property value.
`java.lang.String[]` | `getHandles()` Gets all handles of the objects of API.
`java.lang.String[]` | `getHandles(java.lang.String handle)` Gets children handles of the current node.
`java.lang.String[]` | `getHandles(java.lang.String handle, int type)` Gets children handles which are of the same object type in the current node.
`java.lang.String[]` | `getHandles(java.lang.String handle, int type, int depth)` Gets children handles which are of the same object type.
`java.lang.String` | `getInstanceName(java.lang.String handle)` Gets the instance name of an object.
`int` | `getInt(java.lang.String handle, java.lang.String name)` Gets property value.
`long` | `getLong(java.lang.String handle, java.lang.String name)` Gets property value.
`java.lang.String` | `getParent(java.lang.String handle)` Gets the parent handle of an object.
`java.lang.String[]` | `getPropNames(java.lang.String handle)` Gets property names of all the objects.
`int` | `getPropType(java.lang.String handle, java.lang.String name)` Gets the data type of the specified property of an object.
`java.lang.String` | `getQualifyName(java.lang.String handle)` Gets the qualified name of an object.
`java.lang.String` | `getString(java.lang.String handle, java.lang.String name)` Gets `STRING`, `ENUM`, `REFERENCE` type property value.
`java.lang.String[]` | `getStringArray(java.lang.String handle, java.lang.String name)` Gets String array if the property's value is a list.
`int` | `getUnit()` Gets the current unit setting.
`java.lang.String` | `getWarning()` Gets warning message.
`boolean` | `set(java.lang.String handle, java.lang.String name, boolean value)` Changes boolean type property value of an object.
`boolean` | `set(java.lang.String handle, java.lang.String name, java.awt.Color value)` Changes color type property value.
`boolean` | `set(java.lang.String handle, java.lang.String name, double value)` Changes double type property value of an object.
`boolean` | `set(java.lang.String handle, java.lang.String name, float value)` Changes float type property value of an object.
`boolean` | `set(java.lang.String handle, java.lang.String name, int value)` Changes int type property value of an object.
`boolean` | `set(java.lang.String handle, java.lang.String name, long value)` Changes long type property value of an object.
`boolean` | `set(java.lang.String handle, java.lang.String name, java.lang.String value)` Changes String type property value of an object.
`boolean` | `setLog(java.io.OutputStream log, java.lang.String encoding)` Sets the API's error log to the specified OutputStream.
`boolean` | `setLog(java.lang.String fileName)` Sets the API's error log to a file.
`boolean` | `setLog(java.lang.String fileName, boolean append)` Sets the API's error log to a file.
`boolean` | `setReference(java.lang.String handle, java.lang.String name, java.lang.String refHandle)` Changes reference property value of an object.
`boolean` | `setUnit(int unit)` Sets unit for API usage.
`void` | `writeLog(java.lang.String msg)` Writes message to the log.
`void` | `writeLog(java.lang.String title, java.lang.Throwable e)` Writes Throwable to the log.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### UNKNOWN

    public static final int UNKNOWN

  Primitive property type values.

  See Also:
    Constant Field Values

### BOOLEAN

    public static final int BOOLEAN

  Primitive property type values.

  See Also:
    Constant Field Values

### INTEGER

    public static final int INTEGER

  Primitive property type values.

  See Also:
    Constant Field Values

### LONG

    public static final int LONG

  Primitive property type values.

  See Also:
    Constant Field Values

### FLOAT

    public static final int FLOAT

  Primitive property type values.

  See Also:
    Constant Field Values

### DOUBLE

    public static final int DOUBLE

  Primitive property type values.

  See Also:
    Constant Field Values

### STRING

    public static final int STRING

  Reference property type values.

  See Also:
    Constant Field Values

### COLOR

    public static final int COLOR

  Reference property type values.

  See Also:
    Constant Field Values

### ENUM

    public static final int ENUM

  Reference property type values. The property is a value list.

  See Also:
    Constant Field Values

### REFERENCE

    public static final int REFERENCE

  Reference property type values.

  See Also:
    Constant Field Values

### INCH

    public static final int INCH

  The unit type value.

  See Also:
    Constant Field Values

### CENTIMETER

    public static final int CENTIMETER

  The unit type value.

  See Also:
    Constant Field Values

### PIXEL

    public static final int PIXEL

  The unit type value.

  See Also:
    Constant Field Values

### RPT

    public static final java.lang.String RPT

  The binary format report file suffix.

  See Also:
    Constant Field Values

### XMLRPT

    public static final java.lang.String XMLRPT

  The XML format report file suffix.

  See Also:
    Constant Field Values

### SELFRPT

    public static final java.lang.String SELFRPT

  The binary self-contained report file suffix. This includes report template and the catalog within it.

  See Also:
    Constant Field Values

### TEXTRPT

    public static final java.lang.String TEXTRPT

  The text format report file suffix.

  See Also:
    Constant Field Values

### CAT

    public static final java.lang.String CAT

  The binary catalog file suffix.

  See Also:
    Constant Field Values

### XMLCAT

    public static final java.lang.String XMLCAT

  The XML format catalog file suffix.

  See Also:
    Constant Field Values

Constructor Detail

### API

    public API()

Method Detail

### setUnit

    public boolean setUnit(int unit)

  Sets unit for API usage. API will translate the `float`, `double` values that users set to JReport internal unit.

  Parameters:
    `unit` - It must be either `INCH` or `CENTIMETER`.
  Returns:
    `true` if the unit setting succeeded;`false` otherwise.

### getUnit

    public int getUnit()

  Gets the current unit setting.

  Returns:
    value of `INCH` or `CENTIMETER`.

### delete

    public abstract boolean delete(java.lang.String handle)

  Deletes an object from its parent node.

  Parameters:
    `handle` - Handle of the object to be deleted.
  Returns:
    `true` if an object is removed from its parent node; `false` otherwise.

### getPropNames

    public java.lang.String[] getPropNames(java.lang.String handle)

  Gets property names of all the objects. The JReport properties of an object can be presented as some pairs of `propertyName` and `value`.

  Parameters:
    `handle` - Handle of the selected object.
  Returns:
    property names array; null, if the handle is invalid.

### containPropName

    public boolean containPropName(java.lang.String handle,
                                   java.lang.String name)

  Checks whether the property name is valid or not.

  Parameters:
    `handle` - Handle of the selected object.
    `name` - The property name.
  Returns:
    `true`if it exists; `false`otherwise.````

### getPropType

    public int getPropType(java.lang.String handle,
                           java.lang.String name)

  Gets the data type of the specified property of an object. Gets the proper data type of the property before setting its property value.

  Parameters:
    `handle` - Handle of the object.
    `name` - Name of the property.
  Returns:
    int value of the type of the property. The useful constants:
    - `BOOLEAN` - boolean value.
    - `INTEGER` - int value.
    - `LONG` - long value.
    - `FLOAT` - float value.
    - `DOUBLE` - double value.
    - `STRING` - String value.
    - `COLOR` - color value.
    - `ENUM` - a list value.
    - `REFERENCE` - JReport reference object.

### set

    public boolean set(java.lang.String handle,
                       java.lang.String name,
                       boolean value)

  Changes boolean type property value of an object.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
    `value` - Property value.
  Returns:
    true if the property value is changed.
  See Also:
    `getPropType(String, String)`, `getBool(String, String)`

### set

    public boolean set(java.lang.String handle,
                       java.lang.String name,
                       int value)

  Changes int type property value of an object.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
    `value` - Property value.
  Returns:
    true if the property value is changed.
  See Also:
    `getPropType(String, String)`, `getInt(String, String)`

### set

    public boolean set(java.lang.String handle,
                       java.lang.String name,
                       long value)

  Changes long type property value of an object.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
    `value` - Property value.
  Returns:
    true if the property value is changed.
  See Also:
    `getPropType(String, String)`, `getLong(String, String)`

### set

    public boolean set(java.lang.String handle,
                       java.lang.String name,
                       float value)

  Changes float type property value of an object.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
    `value` - Property value.
  Returns:
    true if the property value is changed.
  See Also:
    `getPropType(String, String)`, `getFloat(String, String)`

### set

    public boolean set(java.lang.String handle,
                       java.lang.String name,
                       double value)

  Changes double type property value of an object.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
    `value` - Property value.
  Returns:
    true if the property value is changed.
  See Also:
    `getPropType(String, String)`, `getDouble(String, String)`

### set

    public boolean set(java.lang.String handle,
                       java.lang.String name,
                       java.lang.String value)

  Changes String type property value of an object.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
    `value` - Property value.
  Returns:
    true if the property value is changed.
  See Also:
    `getPropType(String, String)`, `getString(String, String)`

### set

    public boolean set(java.lang.String handle,
                       java.lang.String name,
                       java.awt.Color value)

  Changes color type property value.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
    `value` - Color property value.
  Returns:
    true if the property value is changed.
  See Also:
    `getPropType(String, String)`, `getColor(String, String)`

### setReference

    public boolean setReference(java.lang.String handle,
                                java.lang.String name,
                                java.lang.String refHandle)

  Changes reference property value of an object. The property's value is a handle string of the referenced object.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
    `refHandle` - Handle of the referenced object.
  Returns:
    true if the property value is changed.
  See Also:
    `getPropType(String, String)`, `getString(String, String)`

### getBool

    public boolean getBool(java.lang.String handle,
                           java.lang.String name)

  Gets property value. After calling this method, you must immediately check the error message. If the error message is not null, the return value will not be usable.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
  Returns:
    Property value.
  See Also:
    `getPropType(String, String)`, `set(String, String, boolean)`

### getInt

    public int getInt(java.lang.String handle,
                      java.lang.String name)

  Gets property value. After calling this method, you must immediately check the error message. If the error message is not null, the return value will not be usable.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
  Returns:
    Property value.
  See Also:
    `getPropType(String, String)`, `set(String, String, int)`

### getLong

    public long getLong(java.lang.String handle,
                        java.lang.String name)

  Gets property value. After calling this method, you must immediately check the error message. If the error message is not null, the return value will not be usable.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
  Returns:
    Property value.
  See Also:
    `getPropType(String, String)`, `set(String, String, long)`

### getFloat

    public float getFloat(java.lang.String handle,
                          java.lang.String name)

  Gets property value. After calling this method, you must immediately check the error message. If the error message is not null, the return value will not be usable.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
  Returns:
    Property value.
  See Also:
    `getPropType(String, String)`, `set(String, String, float)`

### getDouble

    public double getDouble(java.lang.String handle,
                            java.lang.String name)

  Gets property value. After calling this method you must immediately check the error message. If the error message is not null, the return value will not be usable.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
  Returns:
    Property value.
  See Also:
    `getPropType(String, String)`, `set(String, String, double)`

### getString

    public java.lang.String getString(java.lang.String handle,
                                      java.lang.String name)

  Gets `STRING`, `ENUM`, `REFERENCE` type property value. After calling this method, you must immediately check the error message. If the error message is not null, the return value will not be usable.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
  Returns:
    Property value.
  See Also:
    `getPropType(String, String)`, `set(String, String, String)`

### getStringArray

    public java.lang.String[] getStringArray(java.lang.String handle,
                                             java.lang.String name)

  Gets String array if the property's value is a list. After calling this method, you must immediately check the error message. If the error message is not null, the return value will not be usable.

  Parameters:
    `handle` - Handle of the target object.
    `name` - Property name.
  Returns:
    Property value.
  See Also:
    `getPropType(String, String)`, `set(String, String, String)`

### getColor

    public java.awt.Color getColor(java.lang.String handle,
                                   java.lang.String name)

  Gets property value. After calling this method, you must immediately check the error message. If the error message is not null, the return value will not be usable.

  Parameters:
    `handle` - Handle of the target object.
    `name` - The property name.
  Returns:
    Property value.
  See Also:
    `getPropType(String, String)`, `set(String, String, Color)`

### getHandles

    public java.lang.String[] getHandles()

  Gets all handles of the objects of API.

  Returns:
    Handle array.

### getHandles

    public java.lang.String[] getHandles(java.lang.String handle)

  Gets children handles of the current node.

  Parameters:
    `handle` - Parent node handle.
  Returns:
    a String array of handles of all children objects of the specified parent node; empty array if the parent handle is invalid.

### getHandles

    public java.lang.String[] getHandles(java.lang.String handle,
                                         int type)

  Gets children handles which are of the same object type in the current node.

  Parameters:
    `type` - Type value of the object.
    `handle` - Parent node handle.
  Returns:
    a String array of handles of all children objects of the specified parent node; empty array if the parent handle is invalid.
  See Also:
    `getClassType(String)`

### getHandles

    public java.lang.String[] getHandles(java.lang.String handle,
                                         int type,
                                         int depth)

  Gets children handles which are of the same object type.

  Parameters:
    `type` - Object type value that is defined in API class.
    `handle` - Parent node handle.
    `deepth` - level Depth related to the scan step to the current level in the report tree. When the depth is -1, all the handles of the report will be returned. When the depth is 0, the children handles of the current node will be returned. When the depth is number n, the children handles of n levels and the current level will be returned.
  Returns:
    a String array of handles of all children objects of the specified parent node; empty array if the parent handle is invalid.

### getInstanceName

    public java.lang.String getInstanceName(java.lang.String handle)

  Gets the instance name of an object.

  Parameters:
    `handle` - Handle of an object.
  Returns:
    the instance name of the object; `null` if the handle is invalid.

### getQualifyName

    public java.lang.String getQualifyName(java.lang.String handle)

  Gets the qualified name of an object.

  Parameters:
    `handle` - Handle of an object.
  Returns:
    The qualified name of the object; `null` if the handle is invalid.

### getClassType

    public int getClassType(java.lang.String handle)

  Gets the object type of an object.

  Parameters:
    `handle` - Handle of the object.
  Returns:
    int format value of the object's type that are defined in API class; `UNKNOWN` if the handle is invalid or the object is unsupported.

### getParent

    public java.lang.String getParent(java.lang.String handle)

  Gets the parent handle of an object.

  Parameters:
    `handle` - Handle of the object.
  Returns:
    handle of parent object; `null` if the handle is invalid, see `getError()`; if the object is a root node, see `getWarning()`.

### getWarning

    public java.lang.String getWarning()

  Gets warning message.

  Returns:
    warning message if the operation is executed successfully but with warnings; null, otherwise.

### clearWarning

    public void clearWarning()

  Clears warning message.

### getError

    public java.lang.String getError()

  Gets error message.

  Returns:
    error message if the operation fails to be executed; `null`, if the operation is executed successfully.

### clearError

    public void clearError()

  Clears error message.

### clearMsg

    public void clearMsg()

  Clears messages of warning and error.

### setLog

    public boolean setLog(java.io.OutputStream log,
                          java.lang.String encoding)

  Sets the API's error log to the specified OutputStream. All the error messages, warning messages during the API application duration will be logged.

  Parameters:
    `log` - The output stream of log messages to be output.
    `encoding` - Specifies the encoding of the log.
  Returns:
    `true` if log creation succeeded; `false` if #UnsupportedEncodingException is thrown.

### setLog

    public boolean setLog(java.lang.String fileName,
                          boolean append)

  Sets the API's error log to a file. All the error messages, warning messages during the API application duration will be logged.

  Parameters:
    `fileName` - The system-dependent file name,the output log file that the messages to be output.
    `append` - If `true`, then the messages will be written to the end of the file rather than the beginning.
  Returns:
    `true` if log creation succeeded; `false` if #FileNotFoundException is thrown. If the file exists but it is a directory rather than a regular file, or it does not exist and cannot be created, or cannot be opened for any other reason, then a FileNotFoundException is thrown.

### setLog

    public boolean setLog(java.lang.String fileName)

  Sets the API's error log to a file. All the error messages, warning messages during the API application duration will be logged.

  Parameters:
    `fileName` - The system-dependent file name,the output log file that messages to be output.
  Returns:
    `true` if log creation succeeded;`false` if #FileNotFoundException is thrown. If the file exists but it is a directory rather than a regular file, or it does not exist and cannot be created, or cannot be opened for any other reason, then a FileNotFoundException is thrown.

### writeLog

    public void writeLog(java.lang.String msg)

  Writes message to the log.

  Parameters:
    `msg` - The message to be output into the log.

### writeLog

    public void writeLog(java.lang.String title,
                         java.lang.Throwable e)

  Writes Throwable to the log.

  Parameters:
    `title` - The title to be output into the log.
    `e` - The Throwable to be output into the log.

### closeLog

    public void closeLog()
                  throws java.io.IOException

  Closes log.

  Throws:
    `java.io.IOException`

### getChildren

    public java.lang.String[] getChildren(java.lang.String objHandle)

  Gets the handles of all children of an object.

  Parameters:
    `objHandle` - The handle of the object
  Returns:
    a String array of the handles for all of the children; empty array if the object's handle is invalid.
  See Also:
    `getHandles(String)`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD