aboutsummaryrefslogtreecommitdiff
path: root/vars/utils.groovy
diff options
context:
space:
mode:
authorMatt Rendina <mrendina@stsci.edu>2017-11-30 11:00:16 -0500
committerMatt Rendina <mrendina@stsci.edu>2017-11-30 11:00:16 -0500
commit86179f6ede2b4108dd0a489a739eebada107be67 (patch)
tree061729dc462d0cc4b867dadc1e95fe4583baaa09 /vars/utils.groovy
parenteaf163f77eecce3a68da9d14f7b5044ace21781e (diff)
downloadjscu_refactor-86179f6ede2b4108dd0a489a739eebada107be67.tar.gz
Different implementation
Diffstat (limited to 'vars/utils.groovy')
-rw-r--r--vars/utils.groovy42
1 files changed, 26 insertions, 16 deletions
diff --git a/vars/utils.groovy b/vars/utils.groovy
index 1def2c6..98bacf5 100644
--- a/vars/utils.groovy
+++ b/vars/utils.groovy
@@ -101,20 +101,30 @@ def concurrent(configs) {
} //end concurrent
-/**
- * This method makes a "deep clone" of any object it is given.
- */
-def deepClone(object) {
- //try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream()
- ObjectOutputStream oos = new ObjectOutputStream(baos)
- oos.writeObject(object)
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray())
- ObjectInputStream ois = new ObjectInputStream(bais)
- return ois.readObject()
- //}
- //catch (Exception e) {
- // e.printStackTrace()
- // return null
- //}
+///**
+// * This method makes a "deep clone" of any object it is given.
+// */
+//def deepClone(object) {
+// //try {
+// ByteArrayOutputStream baos = new ByteArrayOutputStream()
+// ObjectOutputStream oos = new ObjectOutputStream(baos)
+// oos.writeObject(object)
+// ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray())
+// ObjectInputStream ois = new ObjectInputStream(bais)
+// return ois.readObject()
+// //}
+// //catch (Exception e) {
+// // e.printStackTrace()
+// // return null
+// //}
+//}
+
+// standard deep copy implementation
+def deepcopy(orig) {
+ bos = new ByteArrayOutputStream()
+ oos = new ObjectOutputStream(bos)
+ oos.writeObject(orig); oos.flush()
+ bin = new ByteArrayInputStream(bos.toByteArray())
+ ois = new ObjectInputStream(bin)
+ return ois.readObject()
}