JavaField.st
branchdirectory_structure_refactoring
changeset 1818 2e5ed72e7dfd
parent 1441 0faa0f8eda0c
child 1864 60a8dc26c8c6
equal deleted inserted replaced
1817:b86c40afbf1f 1818:2e5ed72e7dfd
       
     1 "
       
     2  COPYRIGHT (c) 1996-2011 by Claus Gittinger
       
     3 
       
     4  New code and modifications done at SWING Research Group [1]:
       
     5 
       
     6  COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
       
     7                             SWING Research Group, Czech Technical University in Prague
       
     8 
       
     9  This software is furnished under a license and may be used
       
    10  only in accordance with the terms of that license and with the
       
    11  inclusion of the above copyright notice.   This software may not
       
    12  be provided or otherwise made available to, or used by, any
       
    13  other person.  No title to or ownership of the software is
       
    14  hereby transferred.
       
    15 
       
    16  [1] Code written at SWING Research Group contains a signature
       
    17      of one of the above copright owners. For exact set of such code,
       
    18      see the differences between this version and version stx:libjava
       
    19      as of 1.9.2010
       
    20 "
       
    21 "{ Package: 'stx:libjava' }"
       
    22 
       
    23 Object subclass:#JavaField
       
    24 	instanceVariableNames:'accessFlags class name descriptor signature index constantValue
       
    25 		annotations constantPool'
       
    26 	classVariableNames:'A_FINAL A_PRIVATE A_PROTECTED A_PUBLIC A_STATIC A_TRANSIENT
       
    27 		A_VOLATILE A_SMALLTALK A_SYNTHETIC A_ENUM FieldTypeClasses'
       
    28 	poolDictionaries:''
       
    29 	category:'Languages-Java-Reader-Support'
       
    30 !
       
    31 
       
    32 !JavaField class methodsFor:'documentation'!
       
    33 
       
    34 copyright
       
    35 "
       
    36  COPYRIGHT (c) 1996-2011 by Claus Gittinger
       
    37 
       
    38  New code and modifications done at SWING Research Group [1]:
       
    39 
       
    40  COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
       
    41                             SWING Research Group, Czech Technical University in Prague
       
    42 
       
    43  This software is furnished under a license and may be used
       
    44  only in accordance with the terms of that license and with the
       
    45  inclusion of the above copyright notice.   This software may not
       
    46  be provided or otherwise made available to, or used by, any
       
    47  other person.  No title to or ownership of the software is
       
    48  hereby transferred.
       
    49 
       
    50  [1] Code written at SWING Research Group contains a signature
       
    51      of one of the above copright owners. For exact set of such code,
       
    52      see the differences between this version and version stx:libjava
       
    53      as of 1.9.2010
       
    54 
       
    55 "
       
    56 ! !
       
    57 
       
    58 !JavaField class methodsFor:'class initialization'!
       
    59 
       
    60 initialize
       
    61     A_PUBLIC := 16r0001.
       
    62     A_PRIVATE := 16r0002.
       
    63     A_PROTECTED := 16r0004.
       
    64     A_STATIC := 16r0008.
       
    65     A_FINAL := 16r0010.
       
    66     A_VOLATILE := 16r0040.
       
    67     A_TRANSIENT := 16r0080.
       
    68     A_SYNTHETIC := 16r1000.
       
    69     A_ENUM := 16r4000.
       
    70     FieldTypeClasses := (IdentityDictionary new)
       
    71                 at: #B put: JavaByte;
       
    72                 at: #C put: Character;
       
    73                 at: #D put: Float;
       
    74                 at: #F put: ShortFloat;
       
    75                 at: #I put: Integer;
       
    76                 at: #J put: LargeInteger;
       
    77                 at: #S put: JavaShort;
       
    78                 at: #Z put: Boolean;
       
    79                 at: #'[B' put: ByteArray;
       
    80                 at: #'[C' put: Unicode16String;
       
    81                 at: #'[D' put: DoubleArray;
       
    82                 at: #'[F' put: FloatArray;
       
    83                 at: #'[I' put: SignedIntegerArray;
       
    84                 at: #'[J' put: SignedLongIntegerArray;
       
    85                 at: #'[S' put: WordArray;
       
    86                 at: #'[Z' put: BooleanArray;
       
    87                 yourself
       
    88 
       
    89     "
       
    90      self initialize"
       
    91 
       
    92     "Modified: / 13-05-1998 / 14:44:43 / cg"
       
    93     "Modified: / 21-02-2012 / 09:28:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    94 ! !
       
    95 
       
    96 !JavaField class methodsFor:'constants'!
       
    97 
       
    98 A_FINAL
       
    99     ^ A_FINAL
       
   100 
       
   101 
       
   102 !
       
   103 
       
   104 A_PRIVATE
       
   105     ^ A_PRIVATE
       
   106 
       
   107 
       
   108 !
       
   109 
       
   110 A_PROTECTED
       
   111     ^ A_PROTECTED
       
   112 
       
   113     "Created: / 13.5.1998 / 13:03:51 / cg"
       
   114 !
       
   115 
       
   116 A_PUBLIC
       
   117     ^ A_PUBLIC
       
   118 
       
   119 
       
   120 !
       
   121 
       
   122 A_STATIC
       
   123     ^ A_STATIC
       
   124 
       
   125     "Created: / 13.5.1998 / 13:03:55 / cg"
       
   126 !
       
   127 
       
   128 A_TRANSIENT
       
   129     ^ A_TRANSIENT
       
   130 
       
   131 
       
   132 !
       
   133 
       
   134 A_VOLATILE
       
   135     ^ A_VOLATILE
       
   136 
       
   137 
       
   138 ! !
       
   139 
       
   140 !JavaField methodsFor:'accessing'!
       
   141 
       
   142 accessFlags
       
   143     ^ accessFlags
       
   144 !
       
   145 
       
   146 annotations
       
   147     ^ annotations
       
   148 !
       
   149 
       
   150 annotations:something
       
   151     annotations := something.
       
   152 !
       
   153 
       
   154 constantPool
       
   155 
       
   156     ^ constantPool
       
   157 
       
   158     "Created: / 17-12-2010 / 18:40:23 / Marcel Hlopko <hlopik@gmail.com>"
       
   159     "Modified: / 27-07-2011 / 09:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   160 !
       
   161 
       
   162 constantValue
       
   163     ^ constantValue
       
   164 !
       
   165 
       
   166 constantValue:aValue
       
   167     constantValue := aValue
       
   168 !
       
   169 
       
   170 descriptor
       
   171     ^ descriptor
       
   172 
       
   173     "Created: / 21-02-2012 / 11:13:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   174 !
       
   175 
       
   176 ensureHasAnnotations
       
   177     annotations ifNil: [ annotations := JavaAnnotationContainer for:self ].
       
   178     ^ annotations
       
   179 
       
   180     "Created: / 25-02-2011 / 16:04:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   181     "Modified: / 16-03-2011 / 17:13:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
       
   182 !
       
   183 
       
   184 index
       
   185 
       
   186     index ifNil:[
       
   187         self isStatic ifTrue:[
       
   188             index := class class instVarOffsetOf: name
       
   189         ] ifFalse:[
       
   190             index := class instVarOffsetOf: name
       
   191         ].
       
   192     ].
       
   193     ^ index
       
   194 
       
   195     "Modified: / 17-08-2011 / 09:26:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   196 !
       
   197 
       
   198 javaClass
       
   199 
       
   200     ^ class
       
   201 
       
   202     "Created: / 27-07-2011 / 09:17:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   203 !
       
   204 
       
   205 name
       
   206     ^ name
       
   207 !
       
   208 
       
   209 signature
       
   210     ^ signature
       
   211 
       
   212     "Created: / 15.10.1998 / 10:37:06 / cg"
       
   213 ! !
       
   214 
       
   215 !JavaField methodsFor:'initialization'!
       
   216 
       
   217 setAccessFlags:flags
       
   218     accessFlags := flags.
       
   219 
       
   220     "Created: 16.4.1996 / 13:04:25 / cg"
       
   221 !
       
   222 
       
   223 setClass: aClass
       
   224 
       
   225     class := aClass
       
   226 
       
   227     "Created: / 27-07-2011 / 09:27:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   228 !
       
   229 
       
   230 setConstantPool:aJavaContantPool
       
   231 
       
   232     constantPool := aJavaContantPool.
       
   233 
       
   234     "Created: / 17-12-2010 / 18:41:59 / Marcel Hlopko <hlopik@gmail.com>"
       
   235     "Created: / 27-07-2011 / 09:30:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   236 !
       
   237 
       
   238 setConstantValue:something
       
   239     constantValue := something.
       
   240 
       
   241     "Created: 16.4.1996 / 13:04:58 / cg"
       
   242 !
       
   243 
       
   244 setDescriptor:aString
       
   245 
       
   246     descriptor := aString.
       
   247 
       
   248     "Created: / 16-04-1996 / 13:04:43 / cg"
       
   249     "Created: / 14-08-2011 / 19:40:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   250 !
       
   251 
       
   252 setIndex:anInteger
       
   253     index := anInteger.
       
   254 
       
   255     "Created: / 22-11-2010 / 17:13:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   256 !
       
   257 
       
   258 setName:aString
       
   259     name := aString.
       
   260 
       
   261     "Created: 16.4.1996 / 13:04:35 / cg"
       
   262 !
       
   263 
       
   264 setSignature:aString
       
   265     signature := aString.
       
   266 
       
   267     "Created: 16.4.1996 / 13:04:43 / cg"
       
   268 ! !
       
   269 
       
   270 !JavaField methodsFor:'printing & storing'!
       
   271 
       
   272 printOn: aStream 
       
   273     | signatureOrDescriptor |
       
   274     signature notNil ifTrue: [ signatureOrDescriptor := signature ] ifFalse: [
       
   275         descriptor notNil ifTrue: [ signatureOrDescriptor := descriptor ] ifFalse: [
       
   276             signatureOrDescriptor := 'unknown descriptor'
       
   277         ]
       
   278     ].
       
   279     super printOn: aStream.
       
   280     aStream
       
   281         nextPutAll: '(name: ';
       
   282         nextPutAll: name;
       
   283         nextPut: $,;
       
   284         space;
       
   285         nextPutAll: 'descriptor: ';
       
   286         nextPutAll: signatureOrDescriptor;
       
   287         nextPut: $)
       
   288 
       
   289     "Created: / 22-05-2011 / 16:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   290     "Modified: / 07-12-2011 / 22:03:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
       
   291 ! !
       
   292 
       
   293 !JavaField methodsFor:'queries'!
       
   294 
       
   295 initialValue
       
   296     ^ JavaClass initialValueFromSignature: descriptor
       
   297 
       
   298     "Modified: / 14-08-2011 / 19:59:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   299 !
       
   300 
       
   301 isFinal
       
   302     ^ (accessFlags bitAnd:A_FINAL) ~~ 0
       
   303 
       
   304     "Modified: / 13.5.1998 / 12:59:26 / cg"
       
   305 !
       
   306 
       
   307 isPrivate
       
   308     ^ (accessFlags bitAnd:A_PRIVATE) ~~ 0
       
   309 
       
   310     "Modified: / 13.5.1998 / 12:59:30 / cg"
       
   311 !
       
   312 
       
   313 isProtected
       
   314     ^ (accessFlags bitAnd:A_PROTECTED) ~~ 0
       
   315 
       
   316     "Modified: / 13.5.1998 / 12:59:35 / cg"
       
   317 !
       
   318 
       
   319 isPublic
       
   320     ^ (accessFlags bitAnd:A_PUBLIC) ~~ 0
       
   321 
       
   322     "Modified: / 13.5.1998 / 12:59:40 / cg"
       
   323 !
       
   324 
       
   325 isStatic
       
   326     ^ (accessFlags bitAnd:A_STATIC) ~~ 0
       
   327 
       
   328     "Modified: / 13.5.1998 / 12:59:43 / cg"
       
   329 !
       
   330 
       
   331 isSynthetic
       
   332     ^ (accessFlags bitAnd:A_SYNTHETIC) ~~ 0
       
   333 
       
   334     "Modified: / 13-05-1998 / 12:59:40 / cg"
       
   335     "Created: / 30-03-2012 / 19:49:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   336 !
       
   337 
       
   338 isTransient
       
   339     ^ (accessFlags bitAnd:A_TRANSIENT) ~~ 0
       
   340 
       
   341     "Modified: / 13.5.1998 / 12:59:51 / cg"
       
   342 !
       
   343 
       
   344 isVolatile
       
   345     ^ (accessFlags bitAnd:A_VOLATILE) ~~ 0
       
   346 
       
   347     "Modified: / 13.5.1998 / 12:59:56 / cg"
       
   348 !
       
   349 
       
   350 type
       
   351     ^ JavaMethod typeFromSignature:descriptor in:nil
       
   352 
       
   353     "Modified: / 08-01-1998 / 19:13:22 / cg"
       
   354     "Modified: / 14-08-2011 / 19:43:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   355 !
       
   356 
       
   357 typeClass
       
   358 
       
   359     ^(JavaDescriptor fromString: descriptor) javaClass.
       
   360 
       
   361     "Created: / 23-11-2010 / 17:02:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   362     "Modified: / 14-08-2011 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   363 ! !
       
   364 
       
   365 !JavaField class methodsFor:'documentation'!
       
   366 
       
   367 version
       
   368     ^ '$Id$'
       
   369 !
       
   370 
       
   371 version_CVS
       
   372     ^ '§Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaField.st,v 1.17 2009/10/09 14:04:34 cg Exp §'
       
   373 !
       
   374 
       
   375 version_SVN
       
   376     ^ '$Id$'
       
   377 ! !
       
   378 
       
   379 JavaField initialize!