01: /*
02: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/NodePersistance.java,v 1.1 2005/04/20 22:20:47 paulby Exp $
03: *
04: * Sun Public License Notice
05: *
06: * The contents of this file are subject to the Sun Public License Version
07: * 1.0 (the "License"). You may not use this file except in compliance with
08: * the License. A copy of the License is available at http://www.sun.com/
09: *
10: * The Original Code is the Java 3D(tm) Scene Graph Editor.
11: * The Initial Developer of the Original Code is Paul Byrne.
12: * Portions created by Paul Byrne are Copyright (C) 2002.
13: * All Rights Reserved.
14: *
15: * Contributor(s): Paul Byrne.
16: *
17: **/
18: package org.jdesktop.j3dedit.scenegrapheditor;
19:
20: import java.io.*;
21: import java.util.Properties;
22:
23: /**
24: * Container for storing node data which needs to be persistant and is not
25: * held in the scene graph
26: *
27: * @author Paul Byrne
28: * @version 1.5, 01/18/02
29: */
30: public class NodePersistance extends Object implements Serializable {
31:
32: private transient Properties properties;
33:
34: /** Creates new NodePersistance */
35: public NodePersistance() {
36: properties = null;
37: }
38:
39: /**
40: * Returns true if this object contains data
41: */
42: public boolean containsData() {
43: return (properties != null);
44: }
45:
46: public void setData(String key, String value) {
47: if (properties == null)
48: properties = new Properties();
49:
50: properties.setProperty(key, value);
51: }
52:
53: public String getData(String key) {
54: return properties.getProperty(key);
55: }
56:
57: private void writeObject(ObjectOutputStream out) throws IOException {
58: out.defaultWriteObject();
59: properties.store(out, null);
60:
61: properties.list(System.out);
62: }
63:
64: private void readObject(ObjectInputStream in) throws IOException,
65: ClassNotFoundException {
66: in.defaultReadObject();
67: properties = new Properties();
68: properties.load(in);
69: }
70:
71: }
|