--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/JavaExamples.st Sun May 13 17:30:17 2012 +0000
@@ -0,0 +1,232 @@
+"
+ COPYRIGHT (c) 1996-2011 by Claus Gittinger
+
+ New code and modifications done at SWING Research Group [1]:
+
+ COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ SWING Research Group, Czech Technical University in Prague
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+
+ [1] Code written at SWING Research Group contains a signature
+ of one of the above copright owners. For exact set of such code,
+ see the differences between this version and version stx:libjava
+ as of 1.9.2010
+"
+"{ Package: 'stx:libjava' }"
+
+Object subclass:#JavaExamples
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Languages-Java-Utilities'
+!
+
+Object subclass:#CDDatabaseParser
+ instanceVariableNames:'index title artist tag'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:JavaExamples
+!
+
+!JavaExamples class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1996-2011 by Claus Gittinger
+
+ New code and modifications done at SWING Research Group [1]:
+
+ COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ SWING Research Group, Czech Technical University in Prague
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+
+ [1] Code written at SWING Research Group contains a signature
+ of one of the above copright owners. For exact set of such code,
+ see the differences between this version and version stx:libjava
+ as of 1.9.2010
+
+"
+! !
+
+!JavaExamples class methodsFor:'examples'!
+
+example_1
+ "A CD .xml parsing example. The parser raises a UserNotification
+ whenever it parses a CD, it raises a UserNotification. The notification
+ is then handled and printed. Demonstrates:
+ - proxy creation
+ - exception handling
+
+ cd.xml may look like:
+
+ <?xml version='1.0' encoding='ISO-8859-1'?>
+ <catalog>
+ <cd>
+ <title>Empire Burlesque</title>
+ <artist>Bob Dylan</artist>
+ <country>USA</country>
+ <company>Columbia</company>
+ <price>10.90</price>
+ <year>1985</year>
+ </cd>
+ </catalog>
+
+
+
+ "
+
+ | factory parser |
+
+ factory := JAVA javax xml parsers SAXParserFactory newInstance.
+ parser := factory newSAXParser getXMLReader.
+ parser setContentHandler: JavaExamples::CDDatabaseParser new.
+ [
+ parser parse: '/home/jv/Projects/libjava/demo/saxon/cd.xml'.
+ ] on: JAVA java io IOException do:[:ioe|
+ Transcript showCR: 'I/O error: ', ioe getMessage.
+ ioe printStackTrace
+ ] on: UserNotification do:[:un|
+ Transcript showCR: un messageText.
+ un proceed.
+ ]
+
+ "Created: / 13-05-2012 / 18:27:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaExamples::CDDatabaseParser class methodsFor:'documentation'!
+
+documentation
+"
+ A simple XML CD database parser - a demonstration
+ of stx:libjava capabilities. See JavaExamples>>example_1
+
+ [author:]
+ Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+
+"
+! !
+
+!JavaExamples::CDDatabaseParser class methodsFor:'initialization'!
+
+initialize
+
+ self lookupObject: JavaLookup instance
+
+ "Created: / 13-05-2012 / 17:24:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+
+!JavaExamples::CDDatabaseParser methodsFor:'SAX2 interface'!
+
+characters: string offset: off length: len
+
+ tag = 'title' ifTrue:[
+ title := string copyFrom: off + 1 to: off + len.
+ tag := nil.
+ ].
+ tag = 'artist' ifTrue:[
+ artist := string copyFrom: off + 1 to: off + len.
+ tag := nil.
+ ].
+
+ "Created: / 13-05-2012 / 17:27:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+endDocument
+
+ "Created: / 16-04-2005 / 12:28:31 / janfrog"
+!
+
+endDocumentFragment
+
+ "Created: / 10-08-2007 / 09:22:12 / janfrog"
+!
+
+endElement:namespace localName:localName qName:qName
+
+
+ qName = 'cd' ifTrue:[
+ index := index + 1.
+ UserNotification notify:
+ (index printString , '. ', title , ' - ' , artist)
+ ]
+
+ "Created: / 13-05-2012 / 17:38:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+endPrefixMapping:prefix
+
+ "Created: / 16-04-2005 / 12:29:45 / janfrog"
+!
+
+ignorableWhitespace:aString
+
+ "Created: / 16-04-2005 / 12:30:04 / janfrog"
+!
+
+processingInstruction:target data:data
+
+ "Created: / 16-04-2005 / 12:31:04 / janfrog"
+!
+
+setDocumentLocator:aLocator
+
+ "Created: / 16-04-2005 / 12:30:37 / janfrog"
+ "Modified: / 13-05-2012 / 17:26:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+skippedEnrity:aString
+
+ "Created: / 16-04-2005 / 12:31:18 / janfrog"
+!
+
+startDocument
+
+ index := 0
+
+ "Created: / 16-04-2005 / 12:31:25 / janfrog"
+ "Modified: / 13-05-2012 / 17:30:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+startDocumentFragment
+
+ "Created: / 10-08-2007 / 09:22:07 / janfrog"
+!
+
+startElement:namespace localName:localName qName:qName attributes:attributes
+
+ tag := qName.
+
+ "Created: / 13-05-2012 / 17:37:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+startPrefix:prefix mappingTo:uri
+
+ "Created: / 17-04-2005 / 08:47:18 / janfrog"
+! !
+
+!JavaExamples class methodsFor:'documentation'!
+
+version_SVN
+ ^ '$Id:: $'
+! !
+
+JavaExamples::CDDatabaseParser initialize!
--- a/src/abbrev.stc Sun May 13 13:49:40 2012 +0000
+++ b/src/abbrev.stc Sun May 13 17:30:17 2012 +0000
@@ -139,3 +139,4 @@
JavaCompiler_Eclipse JavaCompiler_Eclipse stx:libjava 'Languages-Java-Tools-Eclipse' 0
JavaMetaclass JavaMetaclass stx:libjava 'Languages-Java-Classes' 0
GroovyMetaclass GroovyMetaclass stx:libjava 'Languages-Groovy-Classes' 0
+JavaExamples JavaExamples stx:libjava 'Languages-Java-Utilities' 0
--- a/src/libjava.rc Sun May 13 13:49:40 2012 +0000
+++ b/src/libjava.rc Sun May 13 17:30:17 2012 +0000
@@ -3,7 +3,7 @@
// automagically generated from the projectDefinition: stx_libjava.
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 6,2,1823,1823
+ FILEVERSION 6,2,1849,1849
PRODUCTVERSION 6,2,1,1
#if (__BORLANDC__)
FILEFLAGSMASK VS_FF_DEBUG | VS_FF_PRERELEASE
@@ -20,12 +20,12 @@
BEGIN
VALUE "CompanyName", "eXept Software AG\0"
VALUE "FileDescription", "Smalltalk/X Class library (LIB)\0"
- VALUE "FileVersion", "6.2.1823.1823\0"
+ VALUE "FileVersion", "6.2.1849.1849\0"
VALUE "InternalName", "stx:libjava\0"
VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\nCopyright Jan Vrany, Jan Kurs and Marcel Hlopko\b SWING Research Group, Czech Technical University In Prague\0"
VALUE "ProductName", "Smalltalk/X\0"
VALUE "ProductVersion", "6.2.1.1\0"
- VALUE "ProductDate", "Sat, 12 May 2012 20:13:14 GMT\0"
+ VALUE "ProductDate", "Sun, 13 May 2012 17:32:11 GMT\0"
END
END
--- a/src/stx_libjava.st Sun May 13 13:49:40 2012 +0000
+++ b/src/stx_libjava.st Sun May 13 17:30:17 2012 +0000
@@ -391,6 +391,7 @@
#'JavaCompiler_Eclipse'
JavaMetaclass
GroovyMetaclass
+ (JavaExamples autoload)
)
!
@@ -613,7 +614,7 @@
"Return a SVN revision number of myself.
This number is updated after a commit"
- ^ "$SVN-Revision:"'1847 '"$"
+ ^ "$SVN-Revision:"'1851 '"$"
! !
!stx_libjava class methodsFor:'file generation'!