src/JavaClassAccessor.st
branchjk_new_structure
changeset 1390 4a623c4ec05f
child 1430 9331b0e95098
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/JavaClassAccessor.st	Tue Feb 28 20:34:52 2012 +0000
@@ -0,0 +1,166 @@
+"
+ 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:#JavaClassAccessor
+	instanceVariableNames:'name fullName package'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Languages-Java-Classes'
+!
+
+!JavaClassAccessor 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
+
+"
+! !
+
+!JavaClassAccessor class methodsFor:'instance creation'!
+
+fullName: aSymbol
+
+    ^self new setFullName: aSymbol
+
+    "Created: / 28-02-2012 / 19:20:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaClassAccessor methodsFor:'accessing'!
+
+fullName
+    ^ fullName
+!
+
+name
+    "Returns Smalltalk name"
+    ^name
+
+    "Created: / 28-02-2012 / 19:48:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+theClass
+    | cls |
+
+    cls := self theClassOrNil.
+    cls isNil ifTrue:[cls := Java classForName: (fullName copyReplaceAll: $/ with: $.)].
+    ^cls
+
+    "Created: / 28-02-2012 / 19:22:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+theClassOrNil
+    ^JavaVM registry classNamed: fullName.
+
+    "Created: / 28-02-2012 / 19:47:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaClassAccessor methodsFor:'error handling'!
+
+doesNotUnderstand: aMessage
+
+    ^aMessage sendTo: self theClass
+
+    "Created: / 28-02-2012 / 19:37:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaClassAccessor methodsFor:'initialization'!
+
+setFullName: aSymbol
+    fullName := aSymbol.
+    name := 'JAVA::' , ((fullName tokensBasedOn: $/) asStringWith: '::')
+
+    "Created: / 28-02-2012 / 19:21:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaClassAccessor methodsFor:'instance creation'!
+
+new
+
+    ^self theClass new
+
+    "Created: / 28-02-2012 / 19:34:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+newCleared
+
+    ^self theClass newCleared
+
+    "Created: / 28-02-2012 / 19:34:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaClassAccessor methodsFor:'printing & storing'!
+
+printOn:aStream
+    aStream nextPutAll: 'JAVA '.
+    (fullName tokensBasedOn: $/) 
+        do:[:component|aStream nextPutAll: component]
+        separatedBy:[aStream space].
+
+    "Modified: / 28-02-2012 / 20:27:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaClassAccessor methodsFor:'testing'!
+
+isBehavior
+
+    ^true
+
+    "Created: / 28-02-2012 / 19:36:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isClass
+
+    ^true
+
+    "Created: / 28-02-2012 / 20:00:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isJavaClass
+
+    ^true
+
+    "Created: / 28-02-2012 / 20:08:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaClassAccessor class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id$'
+! !