You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2008/03/26 23:40:44 UTC
[Couchdb Wiki] Trivial Update of "Getting Started With LotusScript" by
NoahSlater
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The following page has been changed by NoahSlater:
http://wiki.apache.org/couchdb/Getting_Started_With_LotusScript
------------------------------------------------------------------------------
== LS2CouchDb ==
{{{
- Option Public
+ Option Public
- Uselsx "*javacon"
+ Uselsx "*javacon"
}}}
{{{
- Sub Initialize
+ Sub Initialize
- %REM
+ %REM
- LotusScript LS2J classes for CouchDb
+ LotusScript LS2J classes for CouchDb
- Copyright (C) 2006 Alan Bell - Dominux Consulting
+ Copyright (C) 2006 Alan Bell - Dominux Consulting
- This program is free software; you can redistribute it and/or
+ This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
+ modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
+ as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
+ of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
+ along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- %ENDREM
+ %ENDREM
- 'right now this just implements the basic database operations
+ 'right now this just implements the basic database operations
- 'feel free to fix bugs and add functionailty to it in the Wiki
+ 'feel free to fix bugs and add functionailty to it in the Wiki
- 'there is a total lack of releasing of objects right now so it will leak memory like a sieve
+ 'there is a total lack of releasing of objects right now so it will leak memory like a sieve
- 'error handling would be nice too.
+ 'error handling would be nice too.
- Dim cserver As couchserver
+ Dim cserver As couchserver
- Set cserver=New couchserver("http://localhost","5984","")
+ Set cserver=New couchserver("http://localhost","5984","")
- 'create a database
+ 'create a database
- Call cserver.put("/ls2couch/","")
+ Call cserver.put("/ls2couch/","")
- 'create a document
+ 'create a document
- Call cserver.put("/ls2couch/document_id", |{"type":"comment","body":"First Post!"}|)
+ Call cserver.put("/ls2couch/document_id", |{"type":"comment","body":"First Post!"}|)
- 'retrieve the document
+ 'retrieve the document
- Print cserver.cget("/ls2couch/document_id")
+ Print cserver.cget("/ls2couch/document_id")
- 'delete the database
+ 'delete the database
- Call cserver.del("/ls2couch/")
+ Call cserver.del("/ls2couch/")
- End Sub
+ End Sub
}}}
{{{
- Class couchserver
+ Class couchserver
- Private host As String
+ Private host As String
- Private port As String
+ Private port As String
- Private options As String
+ Private options As String
- Private proxyserver As String
+ Private proxyserver As String
- Private proxyport As String
+ Private proxyport As String
- Private jses As JAVASESSION
+ Private jses As JAVASESSION
- Private jclass As JAVACLASS
+ Private jclass As JAVACLASS
- Private jurl As JAVAOBJECT
+ Private jurl As JAVAOBJECT
- Private jcon As JAVAOBJECT
+ Private jcon As JAVAOBJECT
- Sub new(host As String,port As String,options As String)
+ Sub new(host As String,port As String,options As String)
- 'this corresponds to the initialise method in the Ruby classes
+ 'this corresponds to the initialise method in the Ruby classes
- Me.host=host
+ Me.host=host
- Me.port=port
+ Me.port=port
- Me.options=options
+ Me.options=options
- Set Me.jses=New JAVASESSION()
+ Set Me.jses=New JAVASESSION()
- End Sub
+ End Sub
- Sub setproxy(proxyserver As String,proxyport As String)
+ Sub setproxy(proxyserver As String,proxyport As String)
- 'this should do something. At the moment it does not.
+ 'this should do something. At the moment it does not.
- Me.proxyserver=proxyserver
+ Me.proxyserver=proxyserver
- Me.proxyport=proxyport
+ Me.proxyport=proxyport
- End Sub
+ End Sub
- Sub del(uri As String)
+ Sub del(uri As String)
- 'this corresponds to the delete method in the Ruby classes
+ 'this corresponds to the delete method in the Ruby classes
- Set Me.jclass=jses.GetClass("java/net/URL")
+ Set Me.jclass=jses.GetClass("java/net/URL")
- Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri)
+ Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri)
- Set jcon=jurl.openConnection()
+ Set jcon=jurl.openConnection()
- Me.jcon.setRequestMethod("DELETE")
+ Me.jcon.setRequestMethod("DELETE")
- Call Me.jcon.connect()
+ Call Me.jcon.connect()
- Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it.
+ Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it.
- Call ist.close()
+ Call ist.close()
- End Sub
+ End Sub
- Function cget(uri As String) As String
+ Function cget(uri As String) As String
- 'this corresponds to the get class in Ruby. "get" is a reserved word
+ 'this corresponds to the get class in Ruby. "get" is a reserved word
- Set Me.jclass=jses.GetClass("java/net/URL")
+ Set Me.jclass=jses.GetClass("java/net/URL")
- Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri)
+ Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri)
- Set jcon=jurl.openConnection()
+ Set jcon=jurl.openConnection()
- Me.jcon.setRequestMethod("GET")
+ Me.jcon.setRequestMethod("GET")
- Call Me.jcon.connect()
+ Call Me.jcon.connect()
- Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it.
+ Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it.
- Set Me.jclass=jses.GetClass("java/io/InputStreamReader")
+ Set Me.jclass=jses.GetClass("java/io/InputStreamReader")
- Set ireader=Me.jclass.CreateObject("(Ljava/io/InputStream;)V",ist)
+ Set ireader=Me.jclass.CreateObject("(Ljava/io/InputStream;)V",ist)
- Set Me.jclass=jses.GetClass("java/io/BufferedReader")
+ Set Me.jclass=jses.GetClass("java/io/BufferedReader")
- Set bReader=Me.jclass.CreateObject("(Ljava/io/Reader;)V",ireader)
+ Set bReader=Me.jclass.CreateObject("(Ljava/io/Reader;)V",ireader)
- cget=bReader.readLine()
+ cget=bReader.readLine()
- Call ist.close()
+ Call ist.close()
- End Function
+ End Function
- Sub put (uri As String,xml As String)
+ Sub put (uri As String,xml As String)
- Set Me.jclass=jses.GetClass("java/net/URL")
+ Set Me.jclass=jses.GetClass("java/net/URL")
- Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri)
+ Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri)
- Set jcon=jurl.openConnection()
+ Set jcon=jurl.openConnection()
- Me.jcon.setRequestMethod("PUT")
+ Me.jcon.setRequestMethod("PUT")
- Me.jcon.setdooutput(True)
+ Me.jcon.setdooutput(True)
- Call Me.jcon.connect()
+ Call Me.jcon.connect()
- Set ost=jcon.getOutputStream()
+ Set ost=jcon.getOutputStream()
- Set Me.jclass=jses.GetClass("java/io/OutputStreamWriter")
+ Set Me.jclass=jses.GetClass("java/io/OutputStreamWriter")
- Set owriter=Me.jclass.CreateObject("(Ljava/io/OutputStream;)V",ost)
+ Set owriter=Me.jclass.CreateObject("(Ljava/io/OutputStream;)V",ost)
- Call owriter.write(xml,0,Len(xml))
+ Call owriter.write(xml,0,Len(xml))
- Call owriter.flush()
+ Call owriter.flush()
- Call ost.write(32)
+ Call ost.write(32)
- Call ost.flush()
+ Call ost.flush()
- Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it.
+ Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it.
- Call ist.close()
+ Call ist.close()
- End Sub
+ End Sub
- Sub post(uri As String,xml As String)
+ Sub post(uri As String,xml As String)
- Set Me.jclass=jses.GetClass("java/net/URL")
+ Set Me.jclass=jses.GetClass("java/net/URL")
- Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri)
+ Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri)
- Set jcon=jurl.openConnection()
+ Set jcon=jurl.openConnection()
- Me.jcon.setRequestMethod("PUT")
+ Me.jcon.setRequestMethod("PUT")
- Me.jcon.setdooutput(True)
+ Me.jcon.setdooutput(True)
- Call Me.jcon.connect()
+ Call Me.jcon.connect()
- Set ost=jcon.getOutputStream()
+ Set ost=jcon.getOutputStream()
- Call ost.write(32)
+ Call ost.write(32)
- Call ost.flush()
+ Call ost.flush()
- Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it.
+ Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it.
- Call ist.close()
+ Call ist.close()
- End Sub
+ End Sub
- End Class
+ End Class
}}}