Notification.st
changeset 23304 eb5349cc3973
parent 22888 fd3825a9dc9e
child 24021 d0173ca4be64
equal deleted inserted replaced
23303:64f287d03213 23304:eb5349cc3973
   132 ! !
   132 ! !
   133 
   133 
   134 
   134 
   135 !Notification class methodsFor:'queries'!
   135 !Notification class methodsFor:'queries'!
   136 
   136 
   137 accepts:aSignal
   137 accepts:aSignalOrExceptionClass
   138     "return true, if the receiver accepts the argument, aSignal.
   138     "return true, if the receiver accepts the argument, aSignal.
   139      (i.e. the receiver is aSignal or a parent of it). False otherwise."
   139      (i.e. the receiver is aSignal or a parent of it). False otherwise."
   140 
   140 
   141     |s|
   141     |s|
   142 
   142 
   143     self == aSignal ifTrue:[^ true].
   143     self == aSignalOrExceptionClass ifTrue:[^ true].
   144     aSignal isQuerySignal ifFalse:[^ false].
   144     aSignalOrExceptionClass isQuerySignal ifFalse:[^ false].
   145 
   145 
   146     s := aSignal parent.
   146     s := aSignalOrExceptionClass.
   147     [s notNil] whileTrue:[
   147     [(s := s parent) notNil] whileTrue:[
   148         self == s ifTrue:[^ true].
   148         self == s ifTrue:[^ true].
   149         s := s parent
       
   150     ].
   149     ].
   151     ^ false
   150     ^ false
   152 
   151 
   153     "Modified: / 22.3.1999 / 12:45:32 / stefan"
   152     "Modified: / 22-03-1999 / 12:45:32 / stefan"
   154     "Created: / 23.7.1999 / 15:18:00 / stefan"
   153     "Created: / 23-07-1999 / 15:18:00 / stefan"
       
   154     "Modified (format): / 28-08-2018 / 11:15:50 / Claus Gittinger"
   155 !
   155 !
   156 
   156 
   157 defaultAnswer
   157 defaultAnswer
   158     "Return the default answer to the Query. This method is called,
   158     "Return the default answer to the Query. This method is called,
   159      if nobody catches the signal.
   159      if nobody catches the signal.
   191 
   191 
   192 handles:anException
   192 handles:anException
   193     "return true, if the receiver handles the argument, anException.
   193     "return true, if the receiver handles the argument, anException.
   194      (i.e. the receiver is anExceptions signal or a parent of it)"
   194      (i.e. the receiver is anExceptions signal or a parent of it)"
   195 
   195 
   196     |signal|
   196     ^ self accepts:(anException creator).
   197 
   197 
   198     signal := anException creator.
   198 "/    |signal|
   199 
   199 "/
   200     self == signal ifTrue:[^ true].               "quick check"
   200 "/    signal := anException creator.
   201     anException isNotification ifFalse:[^ false]. "speed up non-queries by not traversing the parent chain"
   201 "/
   202 
   202 "/    self == signal ifTrue:[^ true].               "quick check"
   203     [(signal := signal parent) notNil] whileTrue:[
   203 "/    anException isNotification ifFalse:[^ false]. "speed up non-queries by not traversing the parent chain"
   204         self == signal ifTrue:[^ true].
   204 "/
   205     ].
   205 "/    [(signal := signal parent) notNil] whileTrue:[
   206     ^ false
   206 "/        self == signal ifTrue:[^ true].
       
   207 "/    ].
       
   208 "/    ^ false
       
   209 
       
   210     "Modified: / 28-08-2018 / 11:26:39 / Claus Gittinger"
   207 !
   211 !
   208 
   212 
   209 isQuerySignal
   213 isQuerySignal
   210     "return true, if this is a querySignal - always return true here"
   214     "return true, if this is a querySignal - always return true here"
   211 
   215