SmallSenseResultSet.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 06 Sep 2012 17:38:47 +0100
changeset 28 f516772ba2b8
parent 0 893cc7b0ed1d
child 29 fe650a6e5704
permissions -rw-r--r--
- SmallSenseChecker class definition added: #initialize #new changed: #checkMethodsForClass: - extensions ...

"{ Package: 'stx:libtool/smallsense' }"

Object subclass:#SmallSenseResultSet
	instanceVariableNames:'items position objectNameCollection selectedObjectIndex
		selectedName'
	classVariableNames:''
	poolDictionaries:''
	category:'SmallSense-Core'
!


!SmallSenseResultSet methodsFor:'accessing'!

items

    ^items

    "Created: / 26-11-2011 / 19:06:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

objectCollection
    ^ items
!

objectCollection:something
    items := something.

    "Modified: / 16-03-2011 / 16:42:19 / Jakub <zelenja7@fel.cvut.cz>"
!

objectNameCollection
    ^ objectNameCollection

    "Modified: / 06-04-2011 / 16:31:19 / Jakub <zelenja7@fel.cvut.cz>"
!

objectNameCollection:something
    objectNameCollection := something.
!

position
    ^ position
!

position:something
    position := something.
!

selectedName
    ^ selectedName
!

selectedName:something 
    self findByName:something.
    selectedName := something.

    "Modified: / 17-03-2011 / 12:10:57 / Jakub <zelenja7@fel.cvut.cz>"
!

selectedObjectDescription
    ^ (items at:selectedObjectIndex) description.

    "Modified: / 16-03-2011 / 18:17:38 / Jakub <zelenja7@fel.cvut.cz>"
!

selectedObjectIndex
    ^ selectedObjectIndex
!

selectedObjectIndex:something
    selectedObjectIndex := something.
! !

!SmallSenseResultSet methodsFor:'adding'!

add:object 
    "Add senseResultObject to objectCollection and objectNameCollection"
    
    |helperIndex|

    self checkCollection.
    (object notNil) ifTrue:[
        helperIndex := objectNameCollection indexOf:(object name).
        (helperIndex = 0) ifTrue:[
            items add:object.
            objectNameCollection add:(object name).
        ].
    ].

    "Created: / 16-03-2011 / 16:43:10 / Jakub <zelenja7@fel.cvut.cz>"
    "Modified: / 04-04-2011 / 13:48:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

join: collection 
    "joining two SmallSenseResultCollection"
    
    (collection objectCollection isNil) ifTrue: [
        ^ nil.
    ].
    collection objectCollection do: [:each | 
        self add: each.
    ].

    "Created: / 17-03-2011 / 12:11:39 / Jakub <zelenja7@fel.cvut.cz>"
    "Modified: / 17-03-2011 / 17:56:06 / Jakub <zelenja7@fel.cvut.cz>"
    "Modified: / 04-04-2011 / 13:49:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (format): / 27-11-2011 / 10:05:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SmallSenseResultSet methodsFor:'checking'!

checkCollection
    (objectNameCollection isNil) 
        ifTrue:[ objectNameCollection := SortedCollection new. ].
    (items isNil) 
        ifTrue:[ items := SortedCollection sortBlock:[:a :b|a name < b name]].

    "Created: / 16-03-2011 / 16:46:39 / Jakub <zelenja7@fel.cvut.cz>"
    "Modified: / 07-04-2011 / 10:01:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SmallSenseResultSet methodsFor:'finding'!

findByName:name
|index|
index:=1.
items do:[:each|
(each asString startsWith:name)ifTrue:[
    selectedObjectIndex:=index.
    ^index
].
index:=index+1.
].
selectedObjectIndex:=1.
^index.

    "Created: / 16-03-2011 / 17:16:24 / Jakub <zelenja7@fel.cvut.cz>"
    "Modified: / 16-03-2011 / 18:16:55 / Jakub <zelenja7@fel.cvut.cz>"
! !

!SmallSenseResultSet methodsFor:'queries'!

isEmpty

    ^items isEmptyOrNil

    "Created: / 27-11-2011 / 10:03:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SmallSenseResultSet class methodsFor:'documentation'!

version_SVN
    ^ '$Id: SmallSenseResultSet.st 7826 2011-11-27 09:48:43Z vranyj1 $'
! !