CharacterArray.st
changeset 21126 df27a601562c
parent 21122 a75ae33b406f
child 21128 46bd3b6dba0f
equal deleted inserted replaced
21125:aa7155bed06e 21126:df27a601562c
   347     ^ EncodingFailedSignal
   347     ^ EncodingFailedSignal
   348 
   348 
   349     "Modified: 28.6.1997 / 20:09:35 / cg"
   349     "Modified: 28.6.1997 / 20:09:35 / cg"
   350     "Created: 3.8.1997 / 18:16:40 / cg"
   350     "Created: 3.8.1997 / 18:16:40 / cg"
   351 ! !
   351 ! !
   352 
       
   353 
   352 
   354 !CharacterArray class methodsFor:'cleanup'!
   353 !CharacterArray class methodsFor:'cleanup'!
   355 
   354 
   356 lowSpaceCleanup
   355 lowSpaceCleanup
   357     "cleanup in low-memory situations"
   356     "cleanup in low-memory situations"
  4984         ].
  4983         ].
  4985     "
  4984     "
  4986 ! !
  4985 ! !
  4987 
  4986 
  4988 
  4987 
  4989 
       
  4990 
       
  4991 !CharacterArray methodsFor:'matching - glob expressions'!
  4988 !CharacterArray methodsFor:'matching - glob expressions'!
  4992 
  4989 
  4993 compoundMatch:aString
  4990 compoundMatch:aString
  4994     "like match, but the receiver may be a compound match pattern,
  4991     "like match, but the receiver may be a compound match pattern,
  4995      consisting of multiple simple GLOB patterns, separated by semicolons.
  4992      consisting of multiple simple GLOB patterns, separated by semicolons.
  6591                         key := self copyFrom:idx+2 to:idx2-1.
  6588                         key := self copyFrom:idx+2 to:idx2-1.
  6592                         idx := idx2 - 1.
  6589                         idx := idx2 - 1.
  6593                         (argArrayOrDictionary includesKey:key) ifTrue:[
  6590                         (argArrayOrDictionary includesKey:key) ifTrue:[
  6594                             v := argArrayOrDictionary at:key
  6591                             v := argArrayOrDictionary at:key
  6595                         ] ifFalse:[
  6592                         ] ifFalse:[
  6596                             key := key asSymbolIfInterned ? key.
  6593                             key := key asSymbolIfInternedOrSelf.
  6597                             (argArrayOrDictionary includesKey:key) ifTrue:[
  6594                             (argArrayOrDictionary includesKey:key) ifTrue:[
  6598                                 v := argArrayOrDictionary at:key
  6595                                 v := argArrayOrDictionary at:key
  6599                             ] ifFalse:[
  6596                             ] ifFalse:[
  6600                                 (key size == 1 and:[ argArrayOrDictionary includesKey:(key at:1)]) ifTrue:[
  6597                                 (key size == 1 and:[ argArrayOrDictionary includesKey:(key at:1)]) ifTrue:[
  6601                                     v := argArrayOrDictionary at:(key at:1)
  6598                                     v := argArrayOrDictionary at:(key at:1)
  6611                         (next isLetter and:[argArrayOrDictionary isSequenceable not "is a Dictionary"]) ifTrue:[
  6608                         (next isLetter and:[argArrayOrDictionary isSequenceable not "is a Dictionary"]) ifTrue:[
  6612                             "so next is a non-numeric single character."
  6609                             "so next is a non-numeric single character."
  6613                             v := argArrayOrDictionary
  6610                             v := argArrayOrDictionary
  6614                                     at:next
  6611                                     at:next
  6615                                     ifAbsent:[
  6612                                     ifAbsent:[
  6616                                         "try symbol instead of character"
  6613                                         "try symbol or string instead of character"
  6617                                         argArrayOrDictionary
  6614                                         argArrayOrDictionary
  6618                                             at:next asSymbol
  6615                                             at:next asSymbolIfInternedOrSelf
  6619                                             ifAbsent:[String with:escapeCharacter with:next].
  6616                                             ifAbsent:[String with:escapeCharacter with:next].
  6620                                  ].
  6617                                  ].
  6621                         ] ifFalse:[
  6618                         ] ifFalse:[
  6622                             v := String with:$% with:next.
  6619                             v := String with:$% with:next.
  6623                         ].
  6620                         ].
  8038      '        ' isBlank
  8035      '        ' isBlank
  8039      '        ' asUnicode16String isBlank
  8036      '        ' asUnicode16String isBlank
  8040     "
  8037     "
  8041 !
  8038 !
  8042 
  8039 
       
  8040 isInfix
       
  8041     "return true, if the receiver is a binary message selector"
       
  8042 
       
  8043     ^ self first isLetterOrDigit not
       
  8044 
       
  8045     "
       
  8046      #at:put: isInfix
       
  8047      #at: isInfix
       
  8048      #+ isInfix
       
  8049      #size isInfix
       
  8050     "
       
  8051 
       
  8052     "Created: / 1.11.1997 / 12:34:55 / cg"
       
  8053     "Modified: / 1.11.1997 / 12:36:37 / cg"
       
  8054 !
       
  8055 
       
  8056 isKeyword
       
  8057     "return true, if the receiver is a keyword message selector.
       
  8058      This is a quick check, which only looks at the last character.
       
  8059      Should only be used, if we already know that the receiver forms a valid selector.
       
  8060      To check an arbitrary string, use isKeywordSelector.
       
  8061      Bad naming, but compatibility is asking for it."
       
  8062 
       
  8063     ^ self last == $:
       
  8064 
       
  8065     "
       
  8066      #at:put: isKeyword
       
  8067      #at: isKeyword
       
  8068      #+ isKeyword
       
  8069      #size isKeyword
       
  8070     "
       
  8071 
       
  8072     "Created: / 01-11-1997 / 12:34:55 / cg"
       
  8073     "Modified (comment): / 30-04-2016 / 18:19:11 / cg"
       
  8074 !
       
  8075 
  8043 isKeywordSelector
  8076 isKeywordSelector
  8044     "return true, iff there are only alphanumeric or underline characters separated by colons.
  8077     "return true, iff there are only alphanumeric or underline characters separated by colons.
  8045      Must end with a colon.
  8078      Must end with a colon.
  8046      You can use this to check an arbitrary string for being valid as a keyword.
  8079      You can use this to check an arbitrary string for being valid as a keyword.
  8047      If you have a valid selector at hand, and need to know if it is a keyword or not,
  8080      If you have a valid selector at hand, and need to know if it is a keyword or not,
  8150      true is returned here - redefinition of Object>>isString."
  8183      true is returned here - redefinition of Object>>isString."
  8151 
  8184 
  8152     ^ true
  8185     ^ true
  8153 !
  8186 !
  8154 
  8187 
       
  8188 isUnary
       
  8189     "Answer true if the receiver is a unary selector.
       
  8190      That is not a check for being a valid selector, but instead relies on
       
  8191      the selector being valid."
       
  8192 
       
  8193     ^ self isUnarySelector
       
  8194 !
       
  8195 
  8155 isUnarySelector
  8196 isUnarySelector
  8156     "Answer true if the receiver contains only chars in an ANSI unary method selector, false otherwise."
  8197     "Answer true if the receiver contains only chars in an ANSI unary method selector, false otherwise."
  8157 
  8198 
  8158     ^ (self first isLetterOrUnderline)
  8199     ^ (self first isLetterOrUnderline)
  8159       and:[ self conform: [ :chr | chr isLetterOrDigit or:[chr == $_] ]]
  8200       and:[ self conform: [ :chr | chr isLetterOrDigit or:[chr == $_] ]]
  8276     "dispatch for visitor pattern; send #visitString:with: to aVisitor"
  8317     "dispatch for visitor pattern; send #visitString:with: to aVisitor"
  8277 
  8318 
  8278     ^ aVisitor visitString:self with:aParameter
  8319     ^ aVisitor visitString:self with:aParameter
  8279 ! !
  8320 ! !
  8280 
  8321 
  8281 
       
  8282 !CharacterArray class methodsFor:'documentation'!
  8322 !CharacterArray class methodsFor:'documentation'!
  8283 
  8323 
  8284 version
  8324 version
  8285     ^ '$Header$'
  8325     ^ '$Header$'
  8286 !
  8326 !