/** * Check if the OID starts with the given OID. * * @param other the OID to compare to * @return false if the sub-identifiers do not match. */ public boolean startsWith(OID other) { if (other.value.length > value.length) { return false; } int min = Math.min(value.length, other.value.length); return (leftMostCompare(min, other) == 0); }
/** * Check if the OID starts with the given OID. * * @param other * the OID to compare to * @return * false if the sub-identifiers do not match. */ public boolean startsWith(OID other) { if (other.value.length > value.length) { return false; } int min = Math.min(value.length, other.value.length); return (leftMostCompare(min, other) == 0); }
/** * Check if the OID starts with the given OID. * * @param other * the OID to compare to * @return * false if the sub-identifiers do not match. */ public boolean startsWith(OID other) { if (other.value.length > value.length) { return false; } int min = Math.min(value.length, other.value.length); return (leftMostCompare(min, other) == 0); }
public final int compareTo(Variable o) { if (o instanceof OID) { OID other = (OID)o; int min = Math.min(value.length, other.value.length); int result = leftMostCompare(min, other); if (result == 0) { return (value.length - other.value.length); } return result; } throw new ClassCastException(o.getClass().getName()); }
public final int compareTo(Object o) { if (o instanceof OID) { OID other = (OID)o; int min = Math.min(value.length, other.value.length); int result = leftMostCompare(min, other); if (result == 0) { return (value.length - other.value.length); } return result; } throw new ClassCastException(o.getClass().getName()); }
public final int compareTo(Variable o) { if (o instanceof OID) { OID other = (OID) o; int min = Math.min(value.length, other.value.length); int result = leftMostCompare(min, other); if (result == 0) { return (value.length - other.value.length); } return result; } throw new ClassCastException(o.getClass().getName()); }
/** * Get the suffix of this OID that exceeds the given OID. This operation can be used to determine the row index * of a table cell. For example {@link #getSuffix(OID)} on the OID {@code ifDescr.2} with the prefix * parameter {@code ifDescr} will return the OID 2. * Likewise, {@link #getSuffix(OID)} on the OID {@code 1.3.6.1.4} with prefix parameter {@code 1.3.6} will return * {@code 1.4}. * * @param prefix the prefix to left-most trim from this OID to form the result. This OID will not be modified though. * @return If this OID does not start with prefix, {@code null} is returned. Otherwise, the suffix that extends this * OID compared with {@code prefix} is returned. If both OIDs equal, a zero length OID is returned. * @since 3.0 */ public OID getSuffix(OID prefix) { int prefixSize = prefix.size(); if (leftMostCompare(prefixSize, prefix) == 0) { int[] suffix = new int[size() - prefixSize]; System.arraycopy(value, prefixSize, suffix, 0, size() - prefixSize); return new OID(suffix); } return null; } }
/** * Gets the generic trap ID from a notification OID. * @param oid * an OID. * @return * -1 if the supplied OID is not a generic trap, otherwise a zero or positive value * will be returned that denotes the generic trap ID. */ public static int getGenericTrapID(OID oid) { if ((oid == null) || (oid.size() != snmpTraps.size()+1)) { return -1; } if (oid.leftMostCompare(snmpTraps.size(), snmpTraps) == 0) { return oid.get(oid.size() - 1) - 1; } return -1; }
/** * Gets the generic trap ID from a notification OID. * @param oid * an OID. * @return * -1 if the supplied OID is not a generic trap, otherwise a value >= 0 * will be returned that denotes the generic trap ID. */ public static int getGenericTrapID(OID oid) { if ((oid == null) || (oid.size() != snmpTraps.size()+1)) { return -1; } if (oid.leftMostCompare(snmpTraps.size(), snmpTraps) == 0) { return oid.get(oid.size() - 1) - 1; } return -1; }
/** * Gets the generic trap ID from a notification OID. * @param oid * an OID. * @return * -1 if the supplied OID is not a generic trap, otherwise a zero or positive value * will be returned that denotes the generic trap ID. */ public static int getGenericTrapID(OID oid) { if ((oid == null) || (oid.size() != snmpTraps.size()+1)) { return -1; } if (oid.leftMostCompare(snmpTraps.size(), snmpTraps) == 0) { return oid.get(oid.size() - 1) - 1; } return -1; }
int min = Math.min(vb.getOid().size(), last.size()); while (min > 0) { if (vb.getOid().leftMostCompare(min, last) == 0) { OID root = new OID(last.getValue(), 0, min); roots.put(root, root); VariableBinding vb = (VariableBinding) vit.next(); if (vb.getOid().size() >= root.size()) { if (vb.getOid().leftMostCompare(root.size(), root) == 0) { subtree.add(vb);
/** * Creates a static managed object group for the sub-tree with the specified * root OID. * @param root * the root OID of the sub-tree to be registered by this managed object. * @param vbs * the variable bindings to be returned in this sub-tree. */ public MutableStaticMOGroup(OID root, VariableBinding[] vbs) { this.root = root; this.scope = new DefaultMOScope(root, true, root.nextPeer(), false); variableBindings = new TreeMap<OID, Variable>(); for (int i = 0; i < vbs.length; i++) { if ((vbs[i].getOid() != null) && (vbs[i].getVariable() != null)) { if ( (vbs[i].getOid().size() >= root.size()) && (vbs[i].getOid().leftMostCompare(root.size(), root) == 0) ) { this.variableBindings.put(vbs[i].getOid(), vbs[i].getVariable()); } } } }
/** * Creates a static managed object group for the sub-tree with the specified * root OID. * @param root * the root OID of the sub-tree to be registered by this managed object. * @param vbs * the variable bindings to be returned in this sub-tree. */ public StaticMOGroup(OID root, VariableBinding[] vbs) { this.root = root; this.scope = new DefaultMOScope(root, true, root.nextPeer(), false); for (int i=0; i<vbs.length; i++) { if ((vbs[i].getOid() != null) && (vbs[i].getVariable() != null)) { if ((vbs[i].getOid().size() >= root.size()) && (vbs[i].getOid().leftMostCompare(root.size(), root) == 0)) { this.vbs.put(vbs[i].getOid(), vbs[i].getVariable()); } } } }
/** * Creates a static managed object group for the sub-tree with the specified * root OID. * @param root * the root OID of the sub-tree to be registered by this managed object. * @param vbs * the variable bindings to be returned in this sub-tree. */ public StaticMOGroup(OID root, VariableBinding[] vbs) { this.root = root; this.scope = new DefaultMOScope(root, true, root.nextPeer(), false); for (VariableBinding vb : vbs) { if ((vb.getOid() != null) && (vb.getVariable() != null)) { if ((vb.getOid().size() >= root.size()) && (vb.getOid().leftMostCompare(root.size(), root) == 0)) { this.vbs.put(vb.getOid(), vb.getVariable()); } } } }
int min = Math.min(vb.getOid().size(), last.size()); while (min > 0) { if (vb.getOid().leftMostCompare(min, last) == 0) { OID root = new OID(last.getValue(), 0, min); roots.put(root, root); for (VariableBinding vb : l) { if (vb.getOid().size() >= root.size()) { if (vb.getOid().leftMostCompare(root.size(), root) == 0) { subtree.add(vb);
if ((vb.getOid() == null) || (vb.getOid().size() < rootOIDs[r].size()) || (rootOIDs[r].leftMostCompare(rootOIDs[r].size(), vb.getOid()) != 0)) { finished = true;
if ((vb.getOid() == null) || (vb.getOid().size() < rootOIDs[r].size()) || (rootOIDs[r].leftMostCompare(rootOIDs[r].size(), vb.getOid()) != 0)) { finished = true;
if ((vb.getOid() == null) || (vb.getOid().size() < rootOID.size()) || (rootOID.leftMostCompare(rootOID.size(), vb.getOid()) != 0)) { finished = true;