01: /*
02: * BEGIN_HEADER - DO NOT EDIT
03: *
04: * The contents of this file are subject to the terms
05: * of the Common Development and Distribution License
06: * (the "License"). You may not use this file except
07: * in compliance with the License.
08: *
09: * You can obtain a copy of the license at
10: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
11: * See the License for the specific language governing
12: * permissions and limitations under the License.
13: *
14: * When distributing Covered Code, include this CDDL
15: * HEADER in each file and include the License file at
16: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
17: * If applicable add the following below this CDDL HEADER,
18: * with the fields enclosed by brackets "[]" replaced with
19: * your own identifying information: Portions Copyright
20: * [year] [name of copyright owner]
21: */
22:
23: /*
24: * @(#)Select.java
25: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
26: *
27: * END_HEADER - DO NOT EDIT
28: */
29: package com.sun.jbi.binding.proxy.stats;
30:
31: import com.sun.jbi.binding.proxy.ExchangeEntry;
32:
33: public class Select extends StatBase implements java.lang.Cloneable {
34: int mField;
35: int mOperation;
36: public final static int OP_EQ = 1;
37: public final static int OP_NE = 2;
38: public final static int OP_LE = 4;
39: public final static int OP_LT = 8;
40: public final static int OP_GT = 16;
41: public final static int OP_GE = 32;
42: Object mValue;
43:
44: Select(int field, int operation, long value) {
45: mField = field;
46: mOperation = operation;
47: mValue = new Long(value);
48: }
49:
50: Select(int field, int operation, String value) {
51: mField = field;
52: mOperation = operation;
53: mValue = value;
54: }
55:
56: public void apply(ExchangeEntry entry) {
57: Comparable value = (Comparable) entry.getField(mField);
58: int result;
59:
60: result = value.compareTo(mValue);
61: if ((result < 0 && (mOperation & (OP_LE | OP_LT | OP_NE)) != 0)
62: || (result == 0 && (mOperation & (OP_EQ | OP_LE | OP_GE)) != 0)
63: || (result > 0 && (mOperation & (OP_GT | OP_GE | OP_NE)) != 0)) {
64: super .apply(entry);
65: }
66: }
67:
68: public String report(int depth) {
69: StringBuffer sb = new StringBuffer();
70:
71: if (mChild != null) {
72: sb.append(mChild.report(depth + 1));
73: }
74: if (mPeer != null) {
75: sb.append(mPeer.report(depth));
76: }
77: return (sb.toString());
78: }
79:
80: }
|