ObjectCoder.st
branchjv
changeset 18556 2c67b0fa6ff5
parent 18011 deb0c3355881
parent 18553 6a1c042d2aab
child 19610 a9a6940944a9
--- a/ObjectCoder.st	Sat Jul 04 11:52:42 2015 +0100
+++ b/ObjectCoder.st	Mon Jul 06 06:06:17 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2000 by eXept Software AG
               All Rights Reserved
@@ -11,6 +13,8 @@
 "
 "{ Package: 'stx:libbasic' }"
 
+"{ NameSpace: Smalltalk }"
+
 AspectVisitor subclass:#ObjectCoder
 	instanceVariableNames:'stream'
 	classVariableNames:''
@@ -104,19 +108,11 @@
 !
 
 encode:anObject on:aStream
-
-    |coder|
-
-    coder := self new stream:aStream.
-    anObject acceptVisitor:coder with:nil.
+    self encode:anObject on:aStream with:nil
 !
 
 encode:anObject on:aStream with:info
-
-    |coder|
-
-    coder := self new stream:aStream.
-    anObject acceptVisitor:coder with:info.
+    self new encode:anObject on:aStream with:info
 !
 
 encode:anObject with:aParameter
@@ -142,7 +138,7 @@
 
     <resource: #obsolete>
 
-    ^ self new encodingOf:anObject with:aParameter
+    ^ self encode:anObject with:aParameter
 ! !
 
 !ObjectCoder methodsFor:'accessing'!
@@ -165,6 +161,17 @@
 
 !ObjectCoder methodsFor:'encoding'!
 
+encode:anObject on:aStream 
+    self encode:anObject on:aStream with:nil
+!
+
+encode:anObject on:aStream with:info
+    self stream:aStream.
+    self startEncoding.
+    anObject acceptVisitor:self with:info.
+    self endEncoding.
+!
+
 encodingOf:anObject
     "answer the encoded argument anObject"
 
@@ -181,12 +188,19 @@
     ] ifFalse:[
         stream reset.
     ].
-
+    self startEncoding.
     anObject acceptVisitor:self with:aParameter.
+    self endEncoding.
 
     ^ stream contents.
 !
 
+endEncoding
+    "redefinable - allows subclass to create a file trailer or similar stuff"
+
+    "/ intentionally left blank here
+!
+
 nextPut:anObject
     "encode anObject onto my stream"
 
@@ -206,6 +220,12 @@
         self nextPut:o
     ]
 
+!
+
+startEncoding
+    "redefinable - allows subclass to create a file header or similar stuff"
+
+    "/ intentionally left blank here
 ! !
 
 !ObjectCoder methodsFor:'encoding-smalltalk types'!
@@ -261,5 +281,10 @@
 !ObjectCoder class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ObjectCoder.st,v 1.17 2012-01-12 12:57:07 cg Exp $'
+    ^ '$Header$'
+!
+
+version_CVS
+    ^ '$Header$'
 ! !
+