--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xquery/trunk/XQuery__CompositeCommand.st Tue Apr 08 19:47:42 2008 +0000
@@ -0,0 +1,132 @@
+"{ Package: 'stx:goodies/xmlsuite/xquery' }"
+
+"{ NameSpace: XQuery }"
+
+UpdateCommand subclass:#CompositeCommand
+ instanceVariableNames:'commands'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'XQuery-Update Facility'
+!
+
+!CompositeCommand class methodsFor:'documentation'!
+
+documentation
+"
+ documentation to be added.
+
+ [author:]
+ Lukas Wroblewski (wrobll1@merunka)
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+
+"
+!
+
+history
+ "Created: / 02-01-2008 / 13:04:08 / wrobll1"
+! !
+
+!CompositeCommand class methodsFor:'instance creation'!
+
+new
+ ^ self basicNew initialize.
+!
+
+with: cmd1 with: cmd2
+
+ ^self new
+ add:cmd1;
+ add:cmd2;
+ yourself
+! !
+
+!CompositeCommand class methodsFor:'priorities'!
+
+priority
+ "Superclass says that I am responsible to implement this method"
+
+ self shouldImplement
+! !
+
+!CompositeCommand methodsFor:'adding & removing'!
+
+add: cmd
+
+ commands add: cmd
+! !
+
+!CompositeCommand methodsFor:'checks'!
+
+checkSourceSequence:arg
+ "Superclass says that I am responsible to implement this method"
+
+ self shouldNotImplement
+!
+
+checkTargetSequence:arg
+ "Superclass says that I am responsible to implement this method"
+
+ self shouldNotImplement
+! !
+
+!CompositeCommand methodsFor:'enumerating'!
+
+do: aBlock
+
+ commands do:aBlock
+! !
+
+!CompositeCommand methodsFor:'executing'!
+
+execute
+ "Superclass says that I am responsible to implement this method"
+
+ self flatten.
+ commands := commands asSortedCollection.
+ commands do:[:cmd|cmd execute]
+! !
+
+!CompositeCommand methodsFor:'flattening'!
+
+flatten
+
+ | flattenedCommandStream |
+ flattenedCommandStream := OrderedCollection new writeStream.
+ self flattenOn: flattenedCommandStream.
+ commands := flattenedCommandStream contents.
+!
+
+flattenOn: aStream
+
+ commands do:[:cmd|cmd flattenOn: aStream].
+! !
+
+!CompositeCommand methodsFor:'initialization'!
+
+initialize
+ "Invoked when a new instance is created."
+
+ "/ please change as required (and remove this comment)
+ commands := SortedCollection new.
+
+ "/ super initialize. -- commented since inherited method does nothing
+! !
+
+!CompositeCommand methodsFor:'merging'!
+
+mergeWith: anotherCmd
+
+ self add: anotherCmd.
+ ^self
+! !
+
+!CompositeCommand class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xquery/XQuery__CompositeCommand.st,v 1.1 2008-01-02 14:09:05 wrobll1 Exp $'
+! !