Coverage Report - org.apache.commons.events.observable.ModificationEventType
 
Classes in this File Line Coverage Branch Coverage Complexity
ModificationEventType
0%
0/20
0%
0/17
17
 
 1  
 /*
 2  
  * Copyright 2003-2004 The Apache Software Foundation
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.commons.events.observable;
 17  
 
 18  
 /**
 19  
  * Defines event constants for event handling and matching.
 20  
  * <p>
 21  
  * The constants in this class are of two types:
 22  
  * <ol>
 23  
  * <li>Methods - the base definitions (unique bits)
 24  
  * <li>Groups - combination definitions (method bits combined)
 25  
  * </ol>
 26  
  * <p>
 27  
  * Only a method constant may be compared using == to an event type.
 28  
  * This can include use in a switch statement
 29  
  * <p>
 30  
  * Any constant may be used for filtering.
 31  
  * They may combined using the bitwise OR, <code>|</code>.
 32  
  * They may negated using the bitwise NOT, <code>~</code>.
 33  
  *
 34  
  * @since Commons Events 1.0
 35  
  * @version $Revision: 155443 $ $Date: 2005-02-26 13:19:51 +0000 (Sat, 26 Feb 2005) $
 36  
  * 
 37  
  * @author Stephen Colebourne
 38  
  */
 39  
 public class ModificationEventType {
 40  
     
 41  
     /** The method add(Object) */
 42  
     public static final int ADD =           0x00000001;
 43  
     /** The method add(int,Object) */
 44  
     public static final int ADD_INDEXED =   0x00000002;
 45  
     /** The method add(Object,int) */
 46  
     public static final int ADD_NCOPIES =   0x00000004;
 47  
     /** The method iterator.add(Object) */
 48  
     public static final int ADD_ITERATED =  0x00000008;
 49  
     
 50  
     /** The method addAll(Collection) */
 51  
     public static final int ADD_ALL =       0x00000010;
 52  
     /** The method addAll(int,Collection) */
 53  
     public static final int ADD_ALL_INDEXED=0x00000020;
 54  
     
 55  
     /** The method remove(Object) */
 56  
     public static final int REMOVE =        0x00000100;
 57  
     /** The method remove(int) */
 58  
     public static final int REMOVE_INDEXED =0x00000200;
 59  
     /** The method remove(Object,int) */
 60  
     public static final int REMOVE_NCOPIES =0x00000400;
 61  
     /** The method remove() */
 62  
     public static final int REMOVE_NEXT    =0x00000800;
 63  
     /** The method iterator.remove() */
 64  
     public static final int REMOVE_ITERATED=0x00001000;
 65  
     
 66  
     /** The method removeAll(Collection) */
 67  
     public static final int REMOVE_ALL =    0x00002000;
 68  
     /** The method retainAll(Collection) */
 69  
     public static final int RETAIN_ALL =    0x00004000;
 70  
     /** The method clear() */
 71  
     public static final int CLEAR =         0x00008000;
 72  
     
 73  
     /** The method set(int,Object) */
 74  
     public static final int SET_INDEXED =   0x00010000;
 75  
     /** The method iterator.set(Object) */
 76  
     public static final int SET_ITERATED =  0x00020000;
 77  
 
 78  
     /** All add methods */
 79  
     public static final int GROUP_ADD = ADD | ADD_INDEXED | ADD_NCOPIES | ADD_ITERATED | ADD_ALL | ADD_ALL_INDEXED;
 80  
     /** All methods that change without structure modification */
 81  
     public static final int GROUP_CHANGE = SET_INDEXED | SET_ITERATED;
 82  
     /** All remove methods */
 83  
     public static final int GROUP_REMOVE = REMOVE | REMOVE_INDEXED | REMOVE_NCOPIES | REMOVE_ITERATED | REMOVE_NEXT | REMOVE_ALL;
 84  
     /** All retain methods */
 85  
     public static final int GROUP_RETAIN = RETAIN_ALL;
 86  
     /** All clear methods */
 87  
     public static final int GROUP_CLEAR = CLEAR;
 88  
     /** All reducing methods (remove, retain and clear) */
 89  
     public static final int GROUP_REDUCE = GROUP_REMOVE | GROUP_CLEAR | GROUP_RETAIN;
 90  
 
 91  
     /** All indexed methods */
 92  
     public static final int GROUP_INDEXED = ADD_INDEXED | ADD_ALL_INDEXED | REMOVE_INDEXED | SET_INDEXED;
 93  
     /** All ncopies methods */
 94  
     public static final int GROUP_NCOPIES = ADD_NCOPIES | REMOVE_NCOPIES;
 95  
     /** All iterated methods */
 96  
     public static final int GROUP_ITERATED = ADD_ITERATED | REMOVE_ITERATED | SET_ITERATED;
 97  
     /** All 'next' methods */
 98  
     public static final int GROUP_NEXT = REMOVE_NEXT;
 99  
     /** All bulk methods (xxxAll, clear) */
 100  
     public static final int GROUP_BULK =  ADD_ALL | ADD_ALL_INDEXED | REMOVE_ALL | RETAIN_ALL | CLEAR;
 101  
     /** All methods that modify the structure */
 102  
     public static final int GROUP_STRUCTURE_MODIFIED = GROUP_ADD | GROUP_REDUCE;
 103  
 
 104  
     /** All methods sent by a Collection */
 105  
     public static final int GROUP_FROM_COLLECTION = ADD | ADD_ALL | REMOVE | REMOVE_ALL | RETAIN_ALL | CLEAR;
 106  
     /** All methods sent by a Set */
 107  
     public static final int GROUP_FROM_SET = GROUP_FROM_COLLECTION;
 108  
     /** All methods sent by a List */
 109  
     public static final int GROUP_FROM_LIST = GROUP_FROM_COLLECTION | ADD_INDEXED | ADD_ALL_INDEXED | REMOVE_INDEXED | SET_INDEXED;
 110  
     /** All methods sent by a Bag */
 111  
     public static final int GROUP_FROM_BAG = GROUP_FROM_COLLECTION | ADD_NCOPIES | REMOVE_NCOPIES;
 112  
     /** All methods sent by a Buffer */
 113  
     public static final int GROUP_FROM_BUFFER = GROUP_FROM_COLLECTION | REMOVE_NEXT;
 114  
 
 115  
     /** No methods */
 116  
     public static final int GROUP_NONE = 0x00000000;
 117  
     /** All methods */
 118  
     public static final int GROUP_ALL = 0xFFFFFFFF;
 119  
 
 120  
     /**
 121  
      * Constructor.
 122  
      */
 123  
     protected ModificationEventType() {
 124  0
         super();
 125  0
     }
 126  
     
 127  
     /**
 128  
      * Gets a string version of a method event type.
 129  
      * 
 130  
      * @param methodType  the method event type constant
 131  
      * @return a string description
 132  
      */
 133  
     public static String toString(final int methodType) {
 134  0
         switch (methodType) {
 135  
             case ADD:
 136  0
             return "Add";
 137  
             case ADD_INDEXED:
 138  0
             return "AddIndexed";
 139  
             case ADD_NCOPIES:
 140  0
             return "AddNCopies";
 141  
             case ADD_ITERATED:
 142  0
             return "AddIterated";
 143  
             case ADD_ALL:
 144  0
             return "AddAll";
 145  
             case ADD_ALL_INDEXED:
 146  0
             return "AddAllIndexed";
 147  
             case REMOVE:
 148  0
             return "Remove";
 149  
             case REMOVE_NCOPIES:
 150  0
             return "RemoveNCopies";
 151  
             case REMOVE_INDEXED:
 152  0
             return "RemoveIndexed";
 153  
             case REMOVE_ITERATED:
 154  0
             return "RemoveIterated";
 155  
             case REMOVE_NEXT:
 156  0
             return "RemoveNext";
 157  
             case REMOVE_ALL:
 158  0
             return "RemoveAll";
 159  
             case RETAIN_ALL:
 160  0
             return "RetainAll";
 161  
             case CLEAR:
 162  0
             return "Clear";
 163  
             case SET_INDEXED:
 164  0
             return "SetIndexed";
 165  
             case SET_ITERATED:
 166  0
             return "SetIterated";
 167  
             default:
 168  0
             return "Unknown";
 169  
         }
 170  
     }
 171  
 
 172  
 }