本文整理汇总了Java中org.jnetpcap.packet.structure.JField.longValue方法的典型用法代码示例。如果您正苦于以下问题:Java JField.longValue方法的具体用法?Java JField.longValue怎么用?Java JField.longValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jnetpcap.packet.structure.JField
的用法示例。
在下文中一共展示了JField.longValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stylizeBitField
import org.jnetpcap.packet.structure.JField; //导入方法依赖的package包/类
/**
* Stylize bit field.
*
* @param header
* the header
* @param field
* the field
* @param value
* the value
* @return the string
*/
private String stylizeBitField(JHeader header, JField field, Object value) {
StringBuilder b = new StringBuilder();
final JField parent = field.getParent();
final int plen = parent.getLength(header);
// final int p = parent.getValue(int.class, header);
final long pmask = parent.getMask(header);
long v = field.longValue(header);
final int offset = field.getOffset(header);
final int length = field.getLength(header);
final int end = (offset + length);
final int start = offset;
for (int i = plen; i > end; i--) {
if ((pmask & (1L << (i - 1))) == 0) {
continue;
}
b.append(((i - 1) % 4) == 0 ? ". " : '.');
}
for (int i = end; i > start; i--) {
if ((pmask & (1L << (i - 1))) == 0) {
continue;
}
if ((v & (1L << (i - start - 1))) == 0) {
b.append('0');
} else {
b.append('1');
}
if (((i - 1) % 4) == 0) {
b.append(' ');
}
}
for (int i = start; i > 0; i--) {
if ((pmask & (1L << (i - 1))) == 0) {
continue;
}
b.append(((i - 1) % 4) == 0 ? ". " : '.');
}
/*
* Hack since we always append 1 too many ' ' chars.
*/
b.setLength(b.length() - 1);
// for (int i = plen - 1; i >= 0; i--) {
//
// if (i >= start && i < end) {
// b.append('0');
// } else {
// b.append('.');
// }
//
// if ((i % 4) == 0) {
// b.append(' ');
// }
// }
return b.toString();
}
示例2: stylizeBitField
import org.jnetpcap.packet.structure.JField; //导入方法依赖的package包/类
/**
* Stylize bit field.
*
* @param header
* the header
* @param field
* the field
* @param value
* the value
* @return the string
*/
private String stylizeBitField(JHeader header, JField field, Object value) {
StringBuilder b = new StringBuilder();
final JField parent = field.getParent();
final int plen = parent.getLength(header);
// final int p = parent.getValue(int.class, header);
final long pmask = parent.getMask(header);
long v = field.longValue(header);
final int offset = field.getOffset(header);
final int length = field.getLength(header);
final int end = (offset + length);
final int start = offset;
for (int i = plen; i > end; i--) {
if ((pmask & (1L << (i - 1))) == 0) {
continue;
}
b.append(((i - 1) % 4) == 0 ? ". " : '.');
}
for (int i = end; i > start; i--) {
if ((pmask & (1L << (i - 1))) == 0) {
continue;
}
if ((v & (1L << (i - start - 1))) == 0) {
b.append('0');
} else {
b.append('1');
}
if (((i - 1) % 4) == 0) {
b.append(' ');
}
}
for (int i = start; i > 0; i--) {
if ((pmask & (1L << (i - 1))) == 0) {
continue;
}
b.append(((i - 1) % 4) == 0 ? ". " : '.');
}
/*
* Hack since we always append 1 too many ' ' chars.
*/
b.setLength(b.length() - 1);
// for (int i = plen - 1; i >= 0; i--) {
//
// if (i >= start && i < end) {
// b.append('0');
// } else {
// b.append('.');
// }
//
// if ((i % 4) == 0) {
// b.append(' ');
// }
// }
return b.toString();
}