JavaClassContentRef2.st
changeset 749 e898eaeff091
child 2152 1cbdfbcc685c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/JavaClassContentRef2.st	Fri Aug 19 08:58:19 2011 +0000
@@ -0,0 +1,223 @@
+"
+ COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+                            SWING Research Group, Czech Technical University in Prague
+
+ Parts of the code written by Claus Gittinger are under following
+ license:
+
+ 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.
+
+ Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the 'Software'), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ [1] Code written at SWING Research Group contain a signature
+     of one of the above copright owners.
+"
+"{ Package: 'stx:libjava' }"
+
+JavaRef2 subclass:#JavaClassContentRef2
+	instanceVariableNames:'classRefIndex nameAndTypeIndex classCache nameAndTypeCache'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Languages-Java-Reader-Support-new'
+!
+
+!JavaClassContentRef2 class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+                            SWING Research Group, Czech Technical University in Prague
+
+ Parts of the code written by Claus Gittinger are under following
+ license:
+
+ 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.
+
+ Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the 'Software'), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ [1] Code written at SWING Research Group contain a signature
+     of one of the above copright owners.
+
+"
+! !
+
+!JavaClassContentRef2 class methodsFor:'instance creation'!
+
+in: aJavaConstantPool withNameAndTypeAt: nameAndTypeCPIndex andClassAt: classRefCPIndex 
+    ^ self basicNew 
+        initializeIn: aJavaConstantPool
+        withNameAndTypeAt: nameAndTypeCPIndex
+        andClassAt: classRefCPIndex.
+
+    "Created: / 12-05-2011 / 18:36:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaClassContentRef2 methodsFor:'accessing'!
+
+classRef
+    ^ constantPool at: classRefIndex.
+
+    "Modified: / 12-05-2011 / 18:38:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+descriptor
+    ^ self nameAndType descriptor.
+
+    "Created: / 08-04-2011 / 15:08:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 12-05-2011 / 18:39:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+name
+    ^ self nameAndType name.
+
+    "Created: / 08-04-2011 / 13:54:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 12-05-2011 / 18:39:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+nameAndType
+    ^ constantPool at: nameAndTypeIndex.
+
+    "Created: / 11-04-2011 / 19:57:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 12-05-2011 / 18:39:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+selector
+    ^ self nameAndType selector.
+
+    "Created: / 11-04-2011 / 20:38:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 12-05-2011 / 18:39:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+signature
+    ^ self nameAndType signature.
+
+    "Created: / 20-05-2011 / 17:10:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaClassContentRef2 methodsFor:'comparing'!
+
+= anotherJavaRef
+    "superclass JavaRef2 says that I am responsible to implement this method"
+
+    ^ self shouldImplement
+!
+
+hash
+    "superclass JavaRef2 says that I am responsible to implement this method"
+
+    ^ self shouldImplement
+! !
+
+!JavaClassContentRef2 methodsFor:'initialization'!
+
+initializeIn: aJavaConstantPool withNameAndTypeAt: nameAndTypeCPIndex andClassAt: classRefCPIndex    
+    constantPool := aJavaConstantPool.
+    classRefIndex := classRefCPIndex.
+    nameAndTypeIndex := nameAndTypeCPIndex.
+    super initialize.
+
+    "Created: / 12-05-2011 / 18:37:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaClassContentRef2 methodsFor:'printing'!
+
+displayString
+    "superclass JavaRef2 says that I am responsible to implement this method"
+
+    ^ self classRef displayString , '.' , self name
+
+    "Created: / 14-08-2011 / 21:18:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+printString
+    ^ 'JavaClassContentRef: class=[' , self classRef printString , '] name=[' 
+        , self nameAndType printString , ']'.
+
+    "Created: / 10-05-2011 / 14:15:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 12-05-2011 / 18:40:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaClassContentRef2 methodsFor:'resolving'!
+
+invalidate
+    self classRef invalidate.    
+    classCache := nil.
+    nameAndTypeCache := nil.
+    super invalidate.
+
+    "Created: / 13-04-2011 / 12:21:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 18-05-2011 / 12:41:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+invalidateForClass: internalJavaClassName 
+    "Invalidate (means call invalidate) reference if it has something to do with given class (e.g Class named internalJavaClassName was unloaded).
+     Return true, if reference was invalidated."
+    
+    (self classRef invalidateForClass: internalJavaClassName) 
+        ifTrue: 
+            [ self invalidate.
+            ^ true ].
+    ^ false.
+
+    "Modified: / 12-05-2011 / 18:40:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaClassContentRef2 class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id$'
+! !
\ No newline at end of file