JavaField.st
author Claus Gittinger <cg@exept.de>
Thu, 24 Nov 2011 12:54:18 +0100
changeset 2287 10460992fed5
parent 2210 7c45c135cfd2
child 2353 fa7400d022a0
permissions -rw-r--r--
fixed: #version_SVN ($ to §)

"
 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 (*)

 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.

 (*) extensions, changes and fixes for java1.1 compatibility.
     For a list of changes, see a list of diffs against the last stable version before 2011-08.
"
"{ Package: 'stx:libjava' }"

Object subclass:#JavaField
	instanceVariableNames:'accessFlags class name descriptor signature index constantValue
		annotations constantPool'
	classVariableNames:'A_FINAL A_PRIVATE A_PROTECTED A_PUBLIC A_STATIC A_TRANSIENT
		A_VOLATILE A_SMALLTALK A_SYBTHETIC A_ENUM FieldTypeClasses'
	poolDictionaries:''
	category:'Languages-Java-Reader-Support'
!

!JavaField 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 (*)

 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.

 (*) extensions, changes and fixes for java1.1 compatibility.
     For a list of changes, see a list of diffs against the last stable version before 2011-08.

"
! !

!JavaField class methodsFor:'class initialization'!

initialize
    A_PUBLIC    := 16r0001. "/ JavaClass A_PUBLIC
    A_PRIVATE   := 16r0002.
    A_PROTECTED := 16r0004.
    A_STATIC    := 16r0008.
    A_FINAL     := 16r0010. "/ JavaClass A_FINAL
    A_VOLATILE  := 16r0040.
    A_TRANSIENT := 16r0080.
    A_SYBTHETIC := 16r1000.
    A_ENUM      := 16r4000.

    FieldTypeClasses := IdentityDictionary new
        "Base types"
        "/WARNING: If you change something here, you MUST also
        "/         change JavaDescriptor class>>#initialize !!!!!!

        at: #B  put: Byte;
        at: #C  put: Character;
        at: #D  put: Float;
        at: #F  put: ShortFloat;
        at: #I  put: Integer;       "Kludge: instances of java int are in fact SmallIntegers"
        at: #J  put: LargeInteger;
        at: #S  put: Short;
        at: #Z  put: Boolean;

        "Array types"
        "/WARNING: If you change something here, you MUST also
        "/         change JavaDescriptor class>>#initialize !!!!!!
        at: #'[B'  put: ByteArray;
        at: #'[C'  put: Unicode16String;
        at: #'[D'  put: DoubleArray;
        at: #'[F'  put: FloatArray;
        at: #'[I'  put: SignedIntegerArray;       "Kludge: instances of java int are in fact SmallIntegers"
        at: #'[J'  put: SignedLongIntegerArray;
        at: #'[S'  put: WordArray;
        at: #'[Z'  put: BooleanArray;

        yourself
        

        

    "
     self initialize
    "

    "Modified: / 13-05-1998 / 14:44:43 / cg"
    "Modified: / 10-08-2011 / 00:48:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaField class methodsFor:'constants'!

A_FINAL
    ^ A_FINAL


!

A_PRIVATE
    ^ A_PRIVATE


!

A_PROTECTED
    ^ A_PROTECTED

    "Created: / 13.5.1998 / 13:03:51 / cg"
!

A_PUBLIC
    ^ A_PUBLIC


!

A_STATIC
    ^ A_STATIC

    "Created: / 13.5.1998 / 13:03:55 / cg"
!

A_TRANSIENT
    ^ A_TRANSIENT


!

A_VOLATILE
    ^ A_VOLATILE


! !

!JavaField methodsFor:'accessing'!

accessFlags
    ^ accessFlags
!

annotations
    ^ annotations
!

annotations:something
    annotations := something.
!

constantPool

    ^ constantPool

    "Created: / 17-12-2010 / 18:40:23 / Marcel Hlopko <hlopik@gmail.com>"
    "Modified: / 27-07-2011 / 09:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

constantValue
    ^ constantValue
!

constantValue:aValue
    constantValue := aValue
!

ensureHasAnnotations
    annotations ifNil: [ annotations := JavaAnnotationContainer for:self ].
    ^ annotations

    "Created: / 25-02-2011 / 16:04:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-03-2011 / 17:13:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!

index

    index ifNil:[
        self isStatic ifTrue:[
            index := class class instVarOffsetOf: name
        ] ifFalse:[
            index := class instVarOffsetOf: name
        ].
    ].
    ^ index

    "Modified: / 17-08-2011 / 09:26:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

javaClass

    ^ class

    "Created: / 27-07-2011 / 09:17:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

name
    ^ name
!

signature
    ^ signature

    "Created: / 15.10.1998 / 10:37:06 / cg"
! !

!JavaField methodsFor:'initialization'!

setAccessFlags:flags
    accessFlags := flags.

    "Created: 16.4.1996 / 13:04:25 / cg"
!

setClass: aClass

    class := aClass

    "Created: / 27-07-2011 / 09:27:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setConstantPool:aJavaContantPool

    constantPool := aJavaContantPool.

    "Created: / 17-12-2010 / 18:41:59 / Marcel Hlopko <hlopik@gmail.com>"
    "Created: / 27-07-2011 / 09:30:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setConstantValue:something
    constantValue := something.

    "Created: 16.4.1996 / 13:04:58 / cg"
!

setDescriptor:aString

    descriptor := aString.

    "Created: / 16-04-1996 / 13:04:43 / cg"
    "Created: / 14-08-2011 / 19:40:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setIndex:anInteger
    index := anInteger.

    "Created: / 22-11-2010 / 17:13:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

setName:aString
    name := aString.

    "Created: 16.4.1996 / 13:04:35 / cg"
!

setSignature:aString
    signature := aString.

    "Created: 16.4.1996 / 13:04:43 / cg"
! !

!JavaField methodsFor:'printing & storing'!

printOn: aStream

    super printOn: aStream.
    aStream 
        nextPutAll:'(name: ';
        nextPutAll: name;
        nextPut:$,; space;
        nextPutAll:'descriptor: ';
        nextPutAll: signature;
        nextPut:$)

    "Created: / 22-05-2011 / 16:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaField methodsFor:'queries'!

initialValue
    ^ JavaClass initialValueFromSignature: descriptor

    "Modified: / 14-08-2011 / 19:59:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

isFinal
    ^ (accessFlags bitAnd:A_FINAL) ~~ 0

    "Modified: / 13.5.1998 / 12:59:26 / cg"
!

isPrivate
    ^ (accessFlags bitAnd:A_PRIVATE) ~~ 0

    "Modified: / 13.5.1998 / 12:59:30 / cg"
!

isProtected
    ^ (accessFlags bitAnd:A_PROTECTED) ~~ 0

    "Modified: / 13.5.1998 / 12:59:35 / cg"
!

isPublic
    ^ (accessFlags bitAnd:A_PUBLIC) ~~ 0

    "Modified: / 13.5.1998 / 12:59:40 / cg"
!

isStatic
    ^ (accessFlags bitAnd:A_STATIC) ~~ 0

    "Modified: / 13.5.1998 / 12:59:43 / cg"
!

isTransient
    ^ (accessFlags bitAnd:A_TRANSIENT) ~~ 0

    "Modified: / 13.5.1998 / 12:59:51 / cg"
!

isVolatile
    ^ (accessFlags bitAnd:A_VOLATILE) ~~ 0

    "Modified: / 13.5.1998 / 12:59:56 / cg"
!

type
    ^ JavaMethod typeFromSignature:descriptor in:nil

    "Modified: / 08-01-1998 / 19:13:22 / cg"
    "Modified: / 14-08-2011 / 19:43:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

typeClass

    ^(JavaDescriptor fromString: descriptor) javaClass.

    "Created: / 23-11-2010 / 17:02:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 14-08-2011 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaField class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libjava/JavaField.st,v 1.20 2011-11-24 11:54:18 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libjava/JavaField.st,v 1.20 2011-11-24 11:54:18 cg Exp $'
!

version_SVN
    ^ '§Id: JavaField.st,v 1.18 2011/08/18 18:42:48 vrany Exp §'
! !

JavaField initialize!