Annotation.st
author Claus Gittinger <cg@exept.de>
Sun, 03 Jul 2011 17:00:45 +0200
changeset 13479 d2d9938cf03f
parent 13403 9cdd42752750
child 13613 f3c2a2ac07a1
permissions -rw-r--r--
changed: #copyright

"
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
              All Rights Reserved

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.
"
"{ Package: 'stx:libbasic' }"

Object subclass:#Annotation
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Extensions'
!

Annotation subclass:#NameSpace
	instanceVariableNames:'nameSpace'
	classVariableNames:''
	poolDictionaries:''
	privateIn:Annotation
!

Annotation subclass:#Resource
	instanceVariableNames:'type value'
	classVariableNames:''
	poolDictionaries:''
	privateIn:Annotation
!

Annotation subclass:#Unknown
	instanceVariableNames:'key arguments'
	classVariableNames:''
	poolDictionaries:''
	privateIn:Annotation
!

!Annotation class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
              All Rights Reserved

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.
"
! !

!Annotation class methodsFor:'instance creation'!

key: key arguments: arguments

    ^(self respondsTo: key)
        ifTrue:
            [self 
                perform: key 
                withArguments: arguments]
        ifFalse:
            [Annotation::Unknown new 
                key: key 
                arguments: arguments]

    "Created: / 19-05-2010 / 16:47:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 02-07-2010 / 16:22:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

namespace: aString

    ^Annotation::NameSpace new nameSpaceName: aString

    "Created: / 19-05-2010 / 16:01:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

resource: type

    ^Annotation::Resource new type: type

    "Created: / 16-07-2010 / 11:31:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

resource: type value: value

    ^Annotation::Resource new 
        type: type;
        value: value

    "Created: / 16-07-2010 / 11:31:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation methodsFor:'accessing'!

first

    ^self key

    "Created: / 10-07-2010 / 21:38:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

key

    ^self subclassResponsibility

    "Created: / 19-05-2010 / 16:23:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 16-07-2010 / 11:29:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation methodsFor:'printing & storing'!

printOn:aStream
    "append a printed representation if the receiver to the argument, aStream"

    self storeOn:aStream.

    "Modified: / 19-05-2010 / 16:25:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

storeOn:aStream

    self subclassResponsibility

    "Created: / 19-05-2010 / 16:26:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation methodsFor:'processing'!

annotatesClass: aClass

    ^self subclassResponsibility

    "Created: / 20-05-2010 / 11:15:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

annotatesMethod: aMethod

    ^self subclassResponsibility

    "Created: / 20-05-2010 / 11:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation methodsFor:'testing'!

isUnknown
    ^ false
! !

!Annotation::NameSpace methodsFor:'accessing'!

key

    ^#namespace:

    "Created: / 19-05-2010 / 16:23:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

nameSpace
    ^ nameSpace
!

nameSpace:something
    nameSpace := something.
! !

!Annotation::NameSpace methodsFor:'initialization'!

nameSpaceName: aString

    self nameSpace: (NameSpace name: aString)

    "Created: / 19-05-2010 / 16:02:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation::NameSpace methodsFor:'printing & storing'!

storeOn:aStream
    "superclass Annotation says that I am responsible to implement this method"

    aStream nextPutAll: '(Annotation namespace: '.
    nameSpace name storeOn: aStream.
    aStream nextPut:$)

    "Modified: / 19-05-2010 / 16:27:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation::NameSpace methodsFor:'processing'!

annotatesClass:aClass

    "Nothing to do"

    "Modified: / 20-05-2010 / 11:16:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

annotatesMethod:aMethod

    aMethod lookupObject: NamespaceAwareLookup instance

    "Modified: / 20-05-2010 / 11:18:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation::Resource methodsFor:'accessing'!

key
    "superclass Annotation says that I am responsible to implement this method"

    ^value 
        ifNil:[#resource:]
        ifNotNil:[#resource:value:]

    "Modified: / 16-07-2010 / 11:30:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

type
    ^ type
!

type:something
    type := something.
!

value
    ^ value
!

value:something
    value := something.
! !

!Annotation::Resource methodsFor:'printing & storing'!

storeOn:aStream

    aStream nextPutAll: '(Annotation resource: '.
    type storeOn: aStream.
    value ifNotNil:
        [aStream nextPutAll: ' value: '.
        value storeOn: aStream].    
    aStream nextPut:$)

    "Modified: / 16-07-2010 / 11:36:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation::Resource methodsFor:'processing'!

annotatesClass:aClass

    "Nothing to do"

    "Modified: / 16-07-2010 / 11:28:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

annotatesMethod:aMethod

    "Nothing to do"

    "Modified: / 16-07-2010 / 11:28:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation::Unknown methodsFor:'accessing'!

arguments
    ^ arguments
!

key
    ^ key
! !

!Annotation::Unknown methodsFor:'initialization'!

key:keyArg arguments:argumentsArg 
    key := keyArg.
    arguments := argumentsArg.
! !

!Annotation::Unknown methodsFor:'printing & storing'!

storeOn:aStream
    "superclass Annotation says that I am responsible to implement this method"

    aStream nextPutAll: '(Annotation key: '.
    key storeOn: aStream.
    aStream nextPutAll: ' arguments: '.
    arguments storeOn: aStream.
    aStream nextPut: $).

    "Modified: / 19-05-2010 / 16:46:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation::Unknown methodsFor:'processing'!

annotatesClass:aClass

    "Nothing to do"

    "Modified: / 20-05-2010 / 11:15:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

annotatesMethod:aMethod

    "Nothing to do"

    "Modified: / 20-05-2010 / 11:15:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Annotation::Unknown methodsFor:'testing'!

isUnknown
    ^ true
! !

!Annotation class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libbasic/Annotation.st,v 1.2 2011-07-03 15:00:45 cg Exp $'
!

version_SVN
    ^ '§Id: Annotation.st,v 1.1 2011/06/28 11:04:04 vrany Exp §'
! !