ooRexx logo
   1: /* ---------------------------------------------------------------- */
   2: /*  An .Array mixinclass to restrict membership of an inheriting    */
   3: /*  class, which should be an .Array itself or a subclass of .Array */
   4: /*                                                                  */
   5: /*  Note: Check if the mixinclass could be for OrderedCollection.   */
   6: /*                                                                  */
   7: /*  The inheriting class has to only implement an "isAllowed"       */
   8: /*  method, that returns .true if allowed and .false if denied.     */
   9: /*                                                                  */
  10: /* ---------------------------------------------------------------- */
  11: /*                                                                  */
  12: /* Originally by Ruurd J. Idenburg                                  */
  13: /*                                                                  */
  14: /* No copyright, no licence, no guarantees or warrantees, be it     */
  15: /* explicit, implicit or whatever. Usage is totally and completely  */
  16: /* at the users own risk, the author shall not be liable for any    */
  17: /* damages whatsoever, for any reason whatsoever.                   */
  18: /*                                                                  */
  19: /* Please keep this comment block intact when modifying this code   */
  20: /* and add a note with date and a description.                      */
  21: /*                                                                  */
  22: /* ---------------------------------------------------------------- */
  23: /* 2014/01/26 - Initial version approximately                       */
  24: /* ---------------------------------------------------------------- */
  25: 
  26: ::class restrictable public mixinclass array
  27: -- I think I covered all the "set" methods
  28: ::method "[]="
  29:   self~checkIt("[]=",arg(1,'A'))
  30: 
  31: ::method append
  32:   self~checkIt(append,arg(1,'A'))
  33: 
  34: ::method appendAll
  35:   self~checkIt(appendAll,arg(1,'A'))
  36: 
  37: ::method fill
  38:   self~checkIt(fill,arg(1,'A'))
  39: 
  40: ::method insert
  41:   self~checkIt(insert,arg(1,'A'))
  42: 
  43: ::method put
  44:   self~checkIt(put,arg(1,'A'))
  45: 
  46: ::method checkIt private
  47:   use arg msg                 -- argument 1 is the original method invoked
  48:   item = arg(2)[1]            -- argument 2 is an array of original arguments
  49:   if \self~isAllowed(item)    -- the potential member is the first item in the args array
  50:     then raise syntax 93.900 array(self~syntaxMsg(item)) 
  51:   forward class (super) message(msg) arguments (arg(2)) -- forward original method and args
  52: 
  53: ::method syntaxMsg private
  54:   use arg object
  55:   msg = 'The "'self~class~id'" class does not allow a "'object~class~id'" object as a collection member'
  56:   return msg
  57: 
All content © Ruurd Idenburg, 2007–2025, except where marked otherwise. All rights reserved. This page is primarily for non-commercial use only. The Idenburg website records no personal information and sets no ‘cookies’. This site is hosted on my on server at my home, falling under Dutch (privacy) laws.

This page updated on Wed, 28 May 2025 10:38:18 +0200.