diff options
author | Ken Mc Neill <[email protected]> | 2011-01-17 13:48:11 +0000 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2011-12-31 15:05:57 -0800 |
commit | 68c9ff9cc009124d546b24b4951e76bebd044dba (patch) | |
tree | 65c13b97e9eb32cf33344ce90b71073fff912cb9 | |
parent | a11750b98a15a5e17f787e1ab90ba4f82ba7cf69 (diff) |
j3dutils: cherry-pick fix from svn trunk issue 656
Issue 656
git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@207 9497e636-51bd-65ba-982d-a4982e1767a5
Signed-off-by: Harvey Harrison <[email protected]>
-rw-r--r-- | src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/MediaContainerState.java | 84 |
1 files changed, 61 insertions, 23 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/MediaContainerState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/MediaContainerState.java index f8db37b..c1bc869 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/MediaContainerState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/MediaContainerState.java @@ -44,37 +44,75 @@ package com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d; -import java.io.IOException; import java.io.DataInput; import java.io.DataOutput; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + import javax.media.j3d.MediaContainer; -import javax.media.j3d.SceneGraphObject; + import com.sun.j3d.utils.scenegraph.io.retained.Controller; import com.sun.j3d.utils.scenegraph.io.retained.SymbolTableData; public class MediaContainerState extends NodeComponentState { - public MediaContainerState(SymbolTableData symbol,Controller control) { - super( symbol, control ); - } - - public void writeObject( DataOutput out ) throws IOException { - super.writeObject( out ); - - out.writeBoolean( ((MediaContainer)node).getCacheEnable() ); - out.writeUTF( ((MediaContainer)node).getURLString() ); - } - - public void readObject( DataInput in ) throws IOException { - super.readObject( in ); - - ((MediaContainer)node).setCacheEnable( in.readBoolean() ); - ((MediaContainer)node).setURLString( in.readUTF() ); - } - - protected javax.media.j3d.SceneGraphObject createNode() { - return new MediaContainer(); - } + private static final int URL_STRING = 0; + private static final int URL_OBJECT = 1; + private static final int INPUT_STREAM = 2; + + public MediaContainerState(SymbolTableData symbol, Controller control) { + super(symbol, control); + } + + public void writeObject(DataOutput out) throws IOException { + super.writeObject(out); + + // issue 656: rework + MediaContainer mediaContainer = (MediaContainer) node; + out.writeBoolean(mediaContainer.getCacheEnable()); + // out.writeUTF( ((MediaContainer)node).getURLString() ); + + if (mediaContainer.getURLString() != null) { + out.writeInt(URL_STRING); + out.writeUTF(mediaContainer.getURLString()); + return; + } + if (mediaContainer.getURLObject() != null) { + out.writeInt(URL_OBJECT); + out.writeUTF(mediaContainer.getURLObject().toString()); + return; + } + out.writeInt(INPUT_STREAM); + } + + public void readObject(DataInput in) throws IOException { + super.readObject(in); + + ((MediaContainer) node).setCacheEnable(in.readBoolean()); + + int type = in.readInt(); + + switch (type) { + case URL_STRING: + ((MediaContainer) node).setURLString(in.readUTF()); + return; + case URL_OBJECT: + try { + ((MediaContainer) node).setURLObject(new URI(in.readUTF()) + .toURL()); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + return; + case INPUT_STREAM: + // do nothing + } + + } + protected javax.media.j3d.SceneGraphObject createNode() { + return new MediaContainer(); + } } |