ilog.views.io
Class IlvInputStream

java.lang.Object
  extended by ilog.views.io.IlvInputStream
Direct Known Subclasses:
IlvDXFInputStream, IlvMapInputStream, SVGInputStream

public class IlvInputStream
extends Object

This class allows an ILOG JViews formatted file to be read. The files must have been saved by an IlvOutputStream in order to be read. Note that this format is different from the ILOG Views C++ format. This class provides a wide range of methods that allow you to read the fields of a graphic object.

See Also:
IlvOutputStream, IlvManager.read(java.io.InputStream)

Constructor Summary
IlvInputStream(InputStream stream)
          Creates an IlvInputStream from an InputStream.
 
Method Summary
 URL getDocumentBase()
          Returns the URL from which this stream is reading data, or null if this stream was created directly from an InputStream.
 IlvGraphicBag getGraphicBag()
          Returns the graphic bag.
 IlvGraphicEnumeration getObjects()
          Returns an enumeration of the graphic objects that have been read.
protected  IlvPersistentObject invokeConstructor(Constructor constructor)
          Invokes the given constructor.
 boolean isASCIIMode()
          Returns whether the stream is in ASCII mode.
 void read(IlvGraphicBag bag)
          Reads an IlvInputStream.
 boolean readBoolean(String field)
          Reads a field of type boolean.
 boolean[] readBooleanArray(String field)
          Reads a field of type boolean[].
 Color readColor(String field)
          Reads a field of type Color.
 Color[] readColorArray(String field)
          Reads a field of type Color[].
 double readDouble(String field)
          Reads a field of type double.
 double[] readDoubleArray(String field)
          Reads a field of type double[].
protected  void readExtensions()
          This method allows subclasses of IlvManager or IlvGrapher to read additional information saved (after the manager layers) using the corresponding method writeExtensions of the class IlvOutputStream.
 float readFloat(String field)
          Reads a field of type float.
 float[] readFloatArray(String field)
          Reads a field of type float[].
 Font readFont(String field)
          Reads a field of type font.
 Font[] readFontArray(String field)
          Reads a field of type font[].
 GradientPaint readGradient(String field)
          Reads a single AWT gradient field.
 int readInt(String field)
          Reads a field of type int.
 int[] readIntArray(String field)
          Reads a field of type int[].
 long readLong(String field)
          Reads a field of type long.
 long[] readLongArray(String field)
          Reads a field of type long[].
protected  IlvGraphic readObject(boolean add, int index)
          Reads an IlvGraphic.
 IlvGraphic readObject(String field)
          Reads a field of type IlvGraphic.
 Object[] readObjectArray(String field, String spec)
          Reads a field containing a nested Object[] value.
 IlvGraphic[] readObjects(String field)
          Reads a field of type IlvGraphic[].
 IlvPattern readPattern(String field)
          Reads a pattern field.
 IlvPersistentObject readPersistentObject(String field)
          Reads a field of type IlvPersistentObject.
 IlvPersistentObject[] readPersistentObjects(String field)
          Reads a field of type IlvPersistentObject[].
 IlvPoint readPoint(String field)
          Reads a field of type IlvPoint.
 IlvPoint[] readPointArray(String field)
          Reads a field of type IlvPoint[].
 IlvRect readRect(String field)
          Reads a field of type IlvRect.
 IlvRect[] readRectArray(String field)
          Reads a field of type IlvRect[].
 Shape readShape(String pathfield, String rulefield)
          Reads a Java 2D Shape object.
 short readShort(String field)
          Reads a field of type short.
 short[] readShortArray(String field)
          Reads a field of type short[].
 String readString(String field)
          Reads a field of type String.
 String[] readStringArray(String field)
          Reads a field of type String[].
 BasicStroke readStroke(String field)
          Reads a single AWT BasicStroke field.
 IlvTexture readTexture(String field)
          Reads a texture field.
 IlvTransformer readTransformer(String field)
          Reads a field of type IlvTransformer.
 IlvTransformer[] readTransformerArray(String field)
          Reads a field of type IlvTransformer[].
 void registerGraphic(IlvGraphic g)
          Registers an IlvGraphic that has been read.
 void setCopyPasteMode()
          Sets this IlvInputStream in a copy/paste mode.
 void setDocumentBase(URL url)
          Sets the base URL for this IlvInputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvInputStream

public IlvInputStream(InputStream stream)
Creates an IlvInputStream from an InputStream.

Method Detail

isASCIIMode

public boolean isASCIIMode()
Returns whether the stream is in ASCII mode. Initially, the input stream is always in ASCII mode when reading an IVL file. However, if it detects during the read process that it contains binary data, it switches to binary mode. Therefore, this method can be used after the reading of the stream to determine whether the stream contained ASCII data or binary data.

Since:
JViews 8.1

setDocumentBase

public void setDocumentBase(URL url)
Sets the base URL for this IlvInputStream. You should not call this method. This method is public for implementation purposes.


getDocumentBase

public URL getDocumentBase()
Returns the URL from which this stream is reading data, or null if this stream was created directly from an InputStream.


read

public void read(IlvGraphicBag bag)
          throws IOException,
                 IlvReadFileException
Reads an IlvInputStream.

Parameters:
bag - The graphic bag in which objects will be added.
Throws:
IOException - if there are any I/O errors.
IlvReadFileException - if the format is not correct or if some classes cannot be loaded.

getGraphicBag

public final IlvGraphicBag getGraphicBag()
Returns the graphic bag.

Returns:
The graphic bag passed as a parameter to the read method.

setCopyPasteMode

public void setCopyPasteMode()
Sets this IlvInputStream in a copy/paste mode. You should not use this method. The method is public for implementation purposes.


getObjects

public IlvGraphicEnumeration getObjects()
Returns an enumeration of the graphic objects that have been read. You should not use this method. The method is public for implementation purposes.


registerGraphic

public void registerGraphic(IlvGraphic g)
Registers an IlvGraphic that has been read. You should not use this method. The method is public for implementation purposes.


invokeConstructor

protected IlvPersistentObject invokeConstructor(Constructor constructor)
                                         throws InstantiationException,
                                                IllegalAccessException,
                                                IllegalArgumentException,
                                                InvocationTargetException
Invokes the given constructor.

This method is called to create every object read from the input stream. It can be overridden in subclasses of IlvInputStream defined in other packages to create private objects defined in these packages.

Parameters:
constructor - The constructor to invoke.
Returns:
The new object.
Throws:
InstantiationException - if the class that declares the underlying constructor represents an abstract class.
IllegalAccessException - if the underlying constructor is inaccessible.
IllegalArgumentException - if the number of actual and formal parameters differ, or if an unwrapping conversion fails.
InvocationTargetException - if the underlying constructor throws an exception.
See Also:
Constructor.newInstance(java.lang.Object...)

readObject

protected IlvGraphic readObject(boolean add,
                                int index)
                         throws IOException,
                                IlvReadFileException
Reads an IlvGraphic. This method is used internally by other ILOG JViews packages. It should not be redefined by end users.

Throws:
IlvReadFileException - if the format is not correct.
IOException - standard IO errors.

readBoolean

public final boolean readBoolean(String field)
                          throws IlvReadFileException
Reads a field of type boolean.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or the field is not a boolean. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readBooleanArray

public final boolean[] readBooleanArray(String field)
                                 throws IlvReadFileException
Reads a field of type boolean[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readShort

public final short readShort(String field)
                      throws IlvReadFileException
Reads a field of type short.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readShortArray

public final short[] readShortArray(String field)
                             throws IlvReadFileException
Reads a field of type short[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readInt

public final int readInt(String field)
                  throws IlvReadFileException
Reads a field of type int.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readIntArray

public final int[] readIntArray(String field)
                         throws IlvReadFileException
Reads a field of type int[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readLong

public final long readLong(String field)
                    throws IlvReadFileException
Reads a field of type long.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readLongArray

public final long[] readLongArray(String field)
                           throws IlvReadFileException
Reads a field of type long[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readFloat

public final float readFloat(String field)
                      throws IlvReadFileException
Reads a field of type float.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readFloatArray

public final float[] readFloatArray(String field)
                             throws IlvReadFileException
Reads a field of type float[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readDouble

public final double readDouble(String field)
                        throws IlvReadFileException
Reads a field of type double.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readDoubleArray

public final double[] readDoubleArray(String field)
                               throws IlvReadFileException
Reads a field of type double[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readString

public final String readString(String field)
                        throws IlvReadFileException
Reads a field of type String.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readStringArray

public final String[] readStringArray(String field)
                               throws IlvReadFileException
Reads a field of type String[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readPoint

public final IlvPoint readPoint(String field)
                         throws IlvReadFileException
Reads a field of type IlvPoint.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readPointArray

public final IlvPoint[] readPointArray(String field)
                                throws IlvReadFileException
Reads a field of type IlvPoint[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readRect

public final IlvRect readRect(String field)
                       throws IlvReadFileException
Reads a field of type IlvRect.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readRectArray

public final IlvRect[] readRectArray(String field)
                              throws IlvReadFileException
Reads a field of type IlvRect[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readTransformer

public final IlvTransformer readTransformer(String field)
                                     throws IlvReadFileException
Reads a field of type IlvTransformer.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readTransformerArray

public final IlvTransformer[] readTransformerArray(String field)
                                            throws IlvReadFileException
Reads a field of type IlvTransformer[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readColor

public final Color readColor(String field)
                      throws IlvReadFileException
Reads a field of type Color.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readColorArray

public final Color[] readColorArray(String field)
                             throws IlvReadFileException
Reads a field of type Color[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readFont

public final Font readFont(String field)
                    throws IlvReadFileException
Reads a field of type font.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readFontArray

public final Font[] readFontArray(String field)
                           throws IlvReadFileException
Reads a field of type font[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readShape

public final Shape readShape(String pathfield,
                             String rulefield)
                      throws IlvReadFileException
Reads a Java 2D Shape object.

Parameters:
pathfield - The name of the path field.
rulefield - The name of the winding rule field.
Throws:
IlvReadFileException

readGradient

public final GradientPaint readGradient(String field)
                                 throws IlvReadFileException
Reads a single AWT gradient field.

Parameters:
field - The name of the field.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readPattern

public final IlvPattern readPattern(String field)
                             throws IlvReadFileException
Reads a pattern field. This method reads an IlvPattern object from the file.

Parameters:
field - The name of the field.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.
See Also:
IlvPattern

readTexture

public final IlvTexture readTexture(String field)
                             throws IlvReadFileException
Reads a texture field. This method reads an IlvTexture object from the file.

Parameters:
field - The name of the field.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.
See Also:
IlvTexture

readStroke

public final BasicStroke readStroke(String field)
                             throws IlvReadFileException
Reads a single AWT BasicStroke field.

Parameters:
field - The name of the field.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readObject

public final IlvGraphic readObject(String field)
                            throws IlvReadFileException
Reads a field of type IlvGraphic.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readObjects

public final IlvGraphic[] readObjects(String field)
                               throws IlvReadFileException
Reads a field of type IlvGraphic[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readPersistentObject

public final IlvPersistentObject readPersistentObject(String field)
                                               throws IlvReadFileException
Reads a field of type IlvPersistentObject.

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readPersistentObjects

public final IlvPersistentObject[] readPersistentObjects(String field)
                                                  throws IlvReadFileException
Reads a field of type IlvPersistentObject[].

Parameters:
field - The name of the field to be read.
Throws:
IlvReadFileException - if the field is not present or if the field does not have the correct type. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.

readObjectArray

public final Object[] readObjectArray(String field,
                                      String spec)
                               throws IlvReadFileException
Reads a field containing a nested Object[] value. The specification indicates which objects can be found in the array, and is used to perform a type check during reading.

Example specification: "(i)*sst"

In this example, it reads 4 entries and returns an array of four. The first entry is an array of Integer objects. The second entry is a string. The third array is a string that acts as type indicator for the forth entry. The forth entry is an object whose type is according to the type indicator, that is, if the type indicator is "i", then the forth entry is an Integer object.

Brackets indicate nestings. Example: "((i)*sst)*"

In this example, the returned array consists of subarrays. Each subarray is organized as in the first example. The "*" indicates the that (i) array is repetitive, that is, contains multiple integers.

The type indicators:

Parameters:
field - The name of the field to be read.
spec - The specification of the types in the returned array.
Throws:
IlvReadFileException - if the field is not present or if the content of the field does not match the type specification. If the field is not present, then an IlvFieldNotFoundException is launched. This allows optional fields to be detected.
Since:
JViews 8.0

readExtensions

protected void readExtensions()
                       throws IlvReadFileException
This method allows subclasses of IlvManager or IlvGrapher to read additional information saved (after the manager layers) using the corresponding method writeExtensions of the class IlvOutputStream.

Throws:
IlvReadFileException - if the format is not correct.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.