GLG Toolkit, Java Class Library  Version 4.6
Saving and Serialization

This group contains methods for saving and serializing either drawings or individual objects. More...

Detailed Description

This group contains methods for saving and serializing either drawings or individual objects.

Functions

boolean SaveObject (Object medium, GlgMediumType medium_type)
 Saves the object into a stream using a default charset. More...
 
boolean SaveObject (Object medium, GlgMediumType medium_type, String charset_name)
 Saves the object into a stream using the specified charset. More...
 
boolean SaveObject (String filename)
 Saves the object to a file using a default charset. More...
 
boolean SaveObject (String filename, String charset_name)
 Saves the object to a file using the specified charset. More...
 

Function Documentation

◆ SaveObject() [1/4]

boolean SaveObject ( Object  medium,
GlgMediumType  medium_type 
)

Saves the object into a stream using a default charset.

This method serializes the object and all its subsidiary objects into a stream using the GLG ASCII save format that provides maximum portability between different deployment environments.

Parameters
mediumThe destination stream to save to.
medium_typeDestination type, must be STREAM.
Returns
Success or failure status.

◆ SaveObject() [2/4]

boolean SaveObject ( Object  medium,
GlgMediumType  medium_type,
String  charset_name 
)

Saves the object into a stream using the specified charset.

This method serializes the object and all its subsidiary objects into a stream using the GLG ASCII save format that provides maximum portability between different deployment environments.

Parameters
mediumThe destination stream to save to.
medium_typeDestination type, must be STREAM.
charset_nameName of a charset for string encoding.
Returns
Success or failure status.

◆ SaveObject() [3/4]

boolean SaveObject ( String  filename)

Saves the object to a file using a default charset.

This method can be used to save either a viewport, or any GlgObject object.

Parameters
filenameThe file to save the object to.
Returns
false if the file is not accessible for writing, true if the object was successfully saved.

This method saves the specified object and all its subsidiary objects to a file. A GLG object of any type may be saved in this fashion and later loaded using LoadObject. The method uses the GLG ASCII save format that provides maximum portability between different deployment environments.

For applications that load a drawing, modify it and save if back to a file, the drawing should be loaded using LoadObject instead of LoadWidget. LoadWidget extracts the $Widget viewport from the loaded drawing, discarding the rest of the drawing, while LoadObject returns an object that represents the whole drawing.

Using SaveObject to save a viewport loaded with LoadWidget will result in a loss of information contained in the discarded part of the drawing, such as the type of the coordinate system used to display the viewport, which will make it difficult to load and edit the drawing in the Graphics Builder. The following example demonstrates the proper technique:

GlgObject drawing = GlgObject.LoadObject( "drawing.g" );
GlgObject viewport = GlgObject.LoadWidgetFromObject( drawing ); // Extract $Widget viewport.
... // Code that modifies the drawing using the <i>viewport</i> object ID.
drawing.SaveObject( "new_drawing.g" );

◆ SaveObject() [4/4]

boolean SaveObject ( String  filename,
String  charset_name 
)

Saves the object to a file using the specified charset.

This method is similar to the SaveObject method described above, but allows to save using the specified charset.

Parameters
filenameThe file to save the object to.
charset_nameName of a charset for string encoding.
Returns
false if the file is not accessible for writing, true if the object was successfully saved.