com.jme.util
Class CloneImportExport

java.lang.Object
  extended by com.jme.util.CloneImportExport
All Implemented Interfaces:
JMEExporter, JMEImporter

public class CloneImportExport
extends java.lang.Object
implements JMEExporter, JMEImporter

A JMEImporter and JMEExporter that stores the capsule information locally in a hash from Savable to info. This gives a local copy without any overhead of streams, zipping or setup. Found to be slightly more performant. Note: Not thread safe. Note: Ignored fields take precedence over shallow copy specification Intended usage looks something like: CloneImportExport ie = new CloneImportExport(); ie.saveClone(node); Node copy1 = (Node) ie.loadClone(); Node copy2 = (Node) ie.loadClone(); Node copy3 = (Node) ie.loadClone();

Version:
$Id: CloneImportExport.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
kevin

Constructor Summary
CloneImportExport()
           
 
Method Summary
 void addIgnoredField(java.lang.String field)
          Add a field to be ignored during the cloning process.
 void addIgnoredFields(java.util.ArrayList<java.lang.String> fields)
          Add a list of fields to be ignored during the clong process.
 void addShadowCopyField(java.lang.String field)
          Add a field to be copied by reference only, this may be useful to allow copies to shared references to certain buffers within the copies
 void addShallowCopyFields(java.util.ArrayList<java.lang.String> fields)
          Add a list of fields to be copied by reference only, this may be useful to allow copies to shared references to certain buffers within the copies
 void applyConfiguration(CloneConfiguration config)
          Apply a complete configuration to the cloner process
 com.jme.util.CloneImportExport.CloneCapsule getCapsule(Savable object)
           
 Savable load(java.io.File f)
           
 Savable load(java.io.InputStream f)
           
 Savable load(java.net.URL f)
           
 Savable loadClone()
          Load the savable that is currently stored in this import/export utility.
 boolean save(Savable object, java.io.File f)
           
 boolean save(Savable object, java.io.OutputStream f)
           
 boolean saveClone(Savable object)
          Save the specified savable into the local state to allow it to be cloned later using loadClone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CloneImportExport

public CloneImportExport()
Method Detail

getCapsule

public com.jme.util.CloneImportExport.CloneCapsule getCapsule(Savable object)
Specified by:
getCapsule in interface JMEExporter
Specified by:
getCapsule in interface JMEImporter
See Also:
JMEExporter.getCapsule(com.jme.util.export.Savable)

applyConfiguration

public void applyConfiguration(CloneConfiguration config)
Apply a complete configuration to the cloner process

Parameters:
config - The configuration to apply

addShadowCopyField

public void addShadowCopyField(java.lang.String field)
Add a field to be copied by reference only, this may be useful to allow copies to shared references to certain buffers within the copies

Parameters:
field - The name of the field to shallow copy

addShallowCopyFields

public void addShallowCopyFields(java.util.ArrayList<java.lang.String> fields)
Add a list of fields to be copied by reference only, this may be useful to allow copies to shared references to certain buffers within the copies

Parameters:
fields - The name of the fields to shallow copy

addIgnoredField

public void addIgnoredField(java.lang.String field)
Add a field to be ignored during the cloning process. The default values for these fields will be returned

Parameters:
field - The name of field to be ignored

addIgnoredFields

public void addIgnoredFields(java.util.ArrayList<java.lang.String> fields)
Add a list of fields to be ignored during the clong process. The default values will be returned when these fields are copied

Parameters:
fields - The names of the fields to be ignored

saveClone

public boolean saveClone(Savable object)
Save the specified savable into the local state to allow it to be cloned later using loadClone

Parameters:
object - The savable which we're cloning
Returns:
True if the saveable was synced ok

save

public boolean save(Savable object,
                    java.io.OutputStream f)
             throws java.io.IOException
Specified by:
save in interface JMEExporter
Throws:
java.io.IOException
See Also:
JMEExporter.save(com.jme.util.export.Savable, java.io.OutputStream)

save

public boolean save(Savable object,
                    java.io.File f)
             throws java.io.IOException
Specified by:
save in interface JMEExporter
Throws:
java.io.IOException
See Also:
JMEExporter.save(com.jme.util.export.Savable, java.io.File)

loadClone

public Savable loadClone()
Load the savable that is currently stored in this import/export utility. This will create a clone of the savable previously saved using saveClone

Returns:
The cloned savable

load

public Savable load(java.io.InputStream f)
             throws java.io.IOException
Specified by:
load in interface JMEImporter
Throws:
java.io.IOException
See Also:
JMEImporter.load(java.io.InputStream)

load

public Savable load(java.net.URL f)
             throws java.io.IOException
Specified by:
load in interface JMEImporter
Throws:
java.io.IOException
See Also:
JMEImporter.load(java.net.URL)

load

public Savable load(java.io.File f)
             throws java.io.IOException
Specified by:
load in interface JMEImporter
Throws:
java.io.IOException
See Also:
JMEImporter.load(java.io.File)