xquery/trunk/XQuery__LibraryFunction.st
changeset 0 5057afe1ec87
child 18 3476eed46de5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xquery/trunk/XQuery__LibraryFunction.st	Tue Apr 08 19:47:42 2008 +0000
@@ -0,0 +1,107 @@
+"{ Package: 'stx:goodies/xmlsuite/xquery' }"
+
+"{ NameSpace: XQuery }"
+
+XQueryFunction subclass:#LibraryFunction
+	instanceVariableNames:'localName functionLibrary'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'XQuery-Functions'
+!
+
+
+!LibraryFunction class methodsFor:'utilities'!
+
+smalltalkize: localName
+
+    "transforms distinct-values into disticntValues"
+    | input output minusFound|
+    input := localName readStream.
+    output := (String new: localName size) writeStream.
+    minusFound := false.
+    [ input atEnd ] whileFalse: [
+        | c |
+        c := input next.
+        c = $- 
+            ifTrue:
+                [minusFound := true]
+            ifFalse:
+                [minusFound 
+                    ifTrue:
+                        [output nextPut:c asUppercase.
+                        minusFound := false]
+                    ifFalse:
+                        [output nextPut:c]]].
+
+    ^output contents
+
+    "
+        self smalltalkize: 'doc' 
+
+        self smalltalkize: 'distinct-values'  
+    "
+
+    "Created: / 28-08-2007 / 23:35:25 / janfrog"
+! !
+
+!LibraryFunction methodsFor:'accessing'!
+
+functionLibrary
+    ^ functionLibrary
+
+    "Created: / 28-08-2007 / 23:07:47 / janfrog"
+!
+
+smalltalkizedLocalName
+
+    ^self class smalltalkize: localName
+
+    "Created: / 28-08-2007 / 23:35:44 / janfrog"
+! !
+
+!LibraryFunction methodsFor:'function API'!
+
+evaluateInContext:context withParameters: parameters forInterpreter: interpreter
+
+    ^functionLibrary 
+        perform:(self smalltalkizedLocalName, 'InContext:withParameters:forInterpreter:') asSymbol
+        with: context
+        with: parameters
+        with: interpreter
+
+    "Created: / 28-08-2007 / 23:10:46 / janfrog"
+!
+
+localName
+    ^ localName
+
+    "Created: / 28-08-2007 / 23:07:47 / janfrog"
+!
+
+namespaceURI
+    ^ functionLibrary namespaceURI
+
+    "Created: / 28-08-2007 / 23:07:47 / janfrog"
+! !
+
+!LibraryFunction methodsFor:'initialization'!
+
+setFunctionLibrary: aFunctionLibrary
+
+    functionLibrary := aFunctionLibrary
+
+    "Created: / 28-08-2007 / 22:44:00 / janfrog"
+!
+
+setLocalName: name
+
+    localName := name
+
+    "Created: / 28-08-2007 / 23:08:47 / janfrog"
+! !
+
+!LibraryFunction class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xquery/XQuery__LibraryFunction.st,v 1.2 2007-09-21 11:21:48 vranyj1 Exp $'
+! !