comparison src/org/dancres/blitz/stats/OpSwitch.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
1 package org.dancres.blitz.stats;
2
3 /**
4 Controls the tracking of a particular operation type against a particular
5 type.
6 */
7 public class OpSwitch implements Switch {
8 public static final int TAKE_OPS = 1;
9 public static final int WRITE_OPS = 2;
10 public static final int READ_OPS = 4;
11
12 public static final String ALL_TYPES = "*";
13
14 private String theType;
15 private int theOp;
16 private boolean isEnabled;
17 /**
18 @param aType specifies a particular entry classname or the wildcard
19 ALL_TYPES
20 @param anOp should be an OR'd combination of TAKE_OPS, WRITE_OPS and
21 READ_OPS
22 */
23 public OpSwitch(String aType, int anOp, boolean enable) {
24 theType = aType;
25 theOp = anOp;
26 isEnabled = enable;
27 }
28
29 public String getType() {
30 return theType;
31 }
32
33 public int getOp() {
34 return theOp;
35 }
36
37 public boolean isEnabled() {
38 return isEnabled;
39 }
40
41 public boolean isWildcard() {
42 return theType.equals(ALL_TYPES);
43 }
44
45 /**
46 Equal if the switch is an OpSwitch and it has the same type and
47 operation.
48 */
49 public boolean equals(Object anObject) {
50 if (anObject instanceof OpSwitch) {
51 OpSwitch myOther = (OpSwitch) anObject;
52
53 if (myOther.theType.equals(theType)) {
54 return (myOther.theOp == theOp);
55 }
56 }
57
58 return false;
59 }
60 }