1 20 21 22 package org.snmp4j.agent; 23 24 import org.snmp4j.agent.request.Request; 26 27 35 public class DefaultMOQuery implements MOQuery { 36 37 private MOContextScope scope; 38 private boolean writeAccessQuery; 39 private Object source; 40 41 47 public DefaultMOQuery(MOContextScope scope) { 48 this.scope = scope; 49 } 50 51 61 public DefaultMOQuery(MOContextScope scope, boolean isWriteAccessIntended) { 62 this(scope); 63 this.writeAccessQuery = isWriteAccessIntended; 64 } 65 66 76 public DefaultMOQuery(MOContextScope scope, boolean isWriteAccessIntended, 77 Object source) { 78 this(scope, isWriteAccessIntended); 79 this.source = source; 80 } 81 82 88 public MOContextScope getScope() { 89 return scope; 90 } 91 92 100 public boolean matchesQuery(ManagedObject managedObject) { 101 return true; 102 } 103 104 public void substractScope(MOScope scope) { 105 if (this.scope instanceof MutableMOScope) { 106 ((MutableMOScope)this.scope).substractScope(scope); 107 } 108 else { 109 throw new UnsupportedOperationException (); 110 } 111 } 112 113 public String toString() { 114 return getClass().getName()+"["+getScope().getContext()+"]="+ 115 getScope().getLowerBound()+"<"+ 116 (getScope().isLowerIncluded() ? "=" : "")+" x <"+ 117 (getScope().isUpperIncluded() ? "=" : "")+ 118 getScope().getUpperBound(); 119 } 120 121 public boolean isWriteAccessQuery() { 122 return writeAccessQuery; 123 } 124 125 137 public Object getSource() { 138 return source; 139 } 140 141 156 public static boolean isSameSource(MOQuery query, Object source) { 157 if (query instanceof DefaultMOQuery) { 158 return ((source != null) && 159 (((DefaultMOQuery)query).getSource() == source)); 160 } 161 return false; 162 } 163 } 164 | Popular Tags |