home *** CD-ROM | disk | FTP | other *** search
- package javax.management;
-
- class InQueryExp extends QueryEval implements QueryExp {
- private static final long serialVersionUID = -5801329450358952434L;
- private ValueExp val;
- private ValueExp[] valueList;
-
- InQueryExp(ValueExp val, ValueExp[] valueList) {
- this.val = val;
- this.valueList = valueList;
- }
-
- public void setMBeanServer(MBeanServer server) {
- super.setMBeanServer(server);
- if (this.val != null) {
- this.val.setMBeanServer(server);
- }
-
- if (this.valueList != null) {
- for(int i = 0; i < this.valueList.length; ++i) {
- ValueExp v = this.valueList[i];
- if (v != null) {
- v.setMBeanServer(server);
- }
- }
- }
-
- }
-
- public boolean apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException {
- if (this.val != null && this.valueList != null) {
- ValueExp valueExp = this.val.apply(name);
- if (valueExp instanceof NumericValueExp) {
- NumericValueExp numExp = (NumericValueExp)valueExp;
- if (numExp.isDouble()) {
- for(int i = 0; i < this.valueList.length; ++i) {
- ValueExp exp = this.valueList[i];
- if (exp instanceof NumericValueExp && ((NumericValueExp)exp).doubleValue() == numExp.doubleValue()) {
- return true;
- }
- }
- } else {
- for(int i = 0; i < this.valueList.length; ++i) {
- ValueExp exp = this.valueList[i];
- if (exp instanceof NumericValueExp && ((NumericValueExp)exp).longValue() == numExp.longValue()) {
- return true;
- }
- }
- }
- } else if (valueExp instanceof StringValueExp) {
- String s1 = ((StringValueExp)valueExp).getValue();
-
- for(int i = 0; i < this.valueList.length; ++i) {
- ValueExp exp = this.valueList[i];
- if (exp instanceof StringValueExp) {
- String s2 = ((StringValueExp)exp).getValue();
- if (s1 == null && s2 == null) {
- return true;
- }
-
- if (s1 != null && s2 != null && s1.equals(s2)) {
- return true;
- }
- }
- }
- }
- }
-
- return false;
- }
- }
-