本文整理了Java中org.snmp4j.smi.OID.leftMostCompare()
方法的一些代码示例,展示了OID.leftMostCompare()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OID.leftMostCompare()
方法的具体详情如下:
包路径:org.snmp4j.smi.OID
类名称:OID
方法名:leftMostCompare
[英]Compares the n leftmost sub-identifiers with the given OIDin left-to-right direction.
[中]将n个最左边的子标识符与从左到右的给定OID进行比较。
代码示例来源:origin: org.snmp4j/snmp4j
/**
* 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);
}
代码示例来源:origin: org.kaazing/snmp4j
/**
* 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);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j
/**
* 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);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j
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());
}
代码示例来源:origin: org.kaazing/snmp4j
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());
}
代码示例来源:origin: org.snmp4j/snmp4j
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());
}
代码示例来源:origin: org.snmp4j/snmp4j
/**
* 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;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j
/**
* 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;
}
代码示例来源:origin: org.kaazing/snmp4j
/**
* 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;
}
代码示例来源:origin: org.snmp4j/snmp4j
/**
* 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;
}
代码示例来源:origin: org.kaazing/snmp4j-agent
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);
代码示例来源:origin: com.github.kaitoy.sneo/sneo-core
/**
* 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());
}
}
}
}
代码示例来源:origin: org.kaazing/snmp4j-agent
/**
* 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());
}
}
}
}
代码示例来源:origin: org.snmp4j/snmp4j-agent
/**
* 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());
}
}
}
}
代码示例来源:origin: org.snmp4j/snmp4j-agent
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);
代码示例来源:origin: org.snmp4j/snmp4j
if ((vb.getOid() == null) ||
(vb.getOid().size() < rootOIDs[r].size()) ||
(rootOIDs[r].leftMostCompare(rootOIDs[r].size(), vb.getOid()) != 0)) {
finished = true;
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j
if ((vb.getOid() == null) ||
(vb.getOid().size() < rootOIDs[r].size()) ||
(rootOIDs[r].leftMostCompare(rootOIDs[r].size(), vb.getOid()) != 0)) {
finished = true;
代码示例来源:origin: org.kaazing/snmp4j
if ((vb.getOid() == null) ||
(vb.getOid().size() < rootOID.size()) ||
(rootOID.leftMostCompare(rootOID.size(), vb.getOid()) != 0)) {
finished = true;
内容来源于网络,如有侵权,请联系作者删除!