本文整理汇总了Java中org.jnetpcap.packet.annotate.Bind.from方法的典型用法代码示例。如果您正苦于以下问题:Java Bind.from方法的具体用法?Java Bind.from怎么用?Java Bind.from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jnetpcap.packet.annotate.Bind
的用法示例。
在下文中一共展示了Bind.from方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBindings
import org.jnetpcap.packet.annotate.Bind; //导入方法依赖的package包/类
/**
* Creates the bindings.
*
* @param c
* the c
* @param bindMethods
* the bind methods
* @param errors
* the errors
* @return the j binding[]
*/
private static JBinding[] createBindings(
Class<?> c,
AnnotatedBindMethod[] bindMethods,
List<HeaderDefinitionError> errors) {
List<JBinding> list = new ArrayList<JBinding>();
Class<? extends JHeader> target = null;
for (AnnotatedBindMethod boundMethod : bindMethods) {
try {
Bind bind = boundMethod.getMethod().getAnnotation(Bind.class);
target = bind.to();
Class<? extends JHeader> source = bind.from();
Class<? extends JHeader>[] dependencies = bind.dependencies();
list.add(new AnnotatedBinding(c, source, target, boundMethod,
dependencies));
} catch (AnnotatedMethodException e) {
errors.add(e);
}
}
JBinding[] bindings = list.toArray(new JBinding[list.size()]);
cache.put(c, bindings);
return bindings;
}
示例2: inspectClass
import org.jnetpcap.packet.annotate.Bind; //导入方法依赖的package包/类
/**
* Inspect class.
*
* @param c
* the c
* @param errors
* the errors
* @return the annotated bind method[]
*/
public static AnnotatedBindMethod[] inspectClass(
final Class<?> c,
final List<HeaderDefinitionError> errors) {
if (cache.containsKey(c)) {
return cache.get(c);
}
/*
* We use a linked list as the normal Array.asList comes up with a version
* that doesn't support the Iterator.remove() method. ArrayList and LinkList
* both do.
*/
AnnotatedBindMethod[] unchecked = inspectAnyClass(c, errors);
final List<AnnotatedBindMethod> list =
new LinkedList<AnnotatedBindMethod>(Arrays.asList(unchecked));
for (final Iterator<AnnotatedBindMethod> i = list.iterator(); i.hasNext();) {
final AnnotatedBindMethod b = i.next();
/*
* Also need to check and make sure that for general classes, there is
* also a "from" parameter, which does not have to be present int JHeader
* declaring class case.
*/
final Bind bind = b.getMethod().getAnnotation(Bind.class);
final Class<? extends JHeader> source = bind.from();
if (source == JHeader.class) {
errors.add(new HeaderDefinitionError(c,
"missing annotated 'from' declaration for method "
+ b.getMethod().getName() + "()"));
i.remove();
}
}
/*
* Now update cache after our check since removed values may have also been
* cached.
*/
final AnnotatedBindMethod[] bounds =
list.toArray(new AnnotatedBindMethod[list.size()]);
cache.put(c, bounds);
return bounds;
}