本文整理汇总了Java中org.jnetpcap.packet.annotate.Bind.to方法的典型用法代码示例。如果您正苦于以下问题:Java Bind.to方法的具体用法?Java Bind.to怎么用?Java Bind.to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jnetpcap.packet.annotate.Bind
的用法示例。
在下文中一共展示了Bind.to方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: inspectJHeaderClass
import org.jnetpcap.packet.annotate.Bind; //导入方法依赖的package包/类
/**
* Inspect j header class.
*
* @param <T>
* the generic type
* @param c
* the c
* @param errors
* the errors
* @return the j binding[]
*/
public static <T extends JHeader> JBinding[] inspectJHeaderClass(
Class<T> c,
List<HeaderDefinitionError> errors) {
if (cache.containsKey(c)) {
return cache.get(c);
}
AnnotatedBindMethod[] bindMethods =
AnnotatedBindMethod.inspectJHeaderClass(c, errors);
Class<T> source = c;
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>[] 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;
}
示例3: inspectAnyClass
import org.jnetpcap.packet.annotate.Bind; //导入方法依赖的package包/类
/**
* Inspect any class.
*
* @param <T>
* the generic type
* @param c
* the c
* @param errors
* the errors
* @return the annotated bind method[]
*/
private static <T extends JHeader> AnnotatedBindMethod[] inspectAnyClass(
final Class<?> c,
final List<HeaderDefinitionError> errors) {
if (cache.containsKey(c)) {
return cache.get(c);
}
final List<AnnotatedBindMethod> list = new ArrayList<AnnotatedBindMethod>();
Class<? extends JHeader> target = null;
for (final Method method : c.getMethods()) {
try {
if (method.isAnnotationPresent(Bind.class)) {
checkSignature(method);
final Bind bind = method.getAnnotation(Bind.class);
target = bind.to();
final AnnotatedBindMethod boundMethod =
new AnnotatedBindMethod(target, method);
list.add(boundMethod);
}
} catch (final AnnotatedMethodException e) {
errors.add(e);
}
}
final AnnotatedBindMethod[] isBounds =
list.toArray(new AnnotatedBindMethod[list.size()]);
cache.put(c, isBounds);
return isBounds;
}
示例4: inspectObject
import org.jnetpcap.packet.annotate.Bind; //导入方法依赖的package包/类
/**
* Inspect object.
*
* @param object
* the object
* @param errors
* the errors
* @return the annotated bind method[]
*/
public static AnnotatedBindMethod[] inspectObject(
final Object object,
final List<HeaderDefinitionError> errors) {
Class<?> c = object.getClass();
if (cache.containsKey(c)) {
return cache.get(c);
}
final List<AnnotatedBindMethod> list = new ArrayList<AnnotatedBindMethod>();
Class<? extends JHeader> target = null;
if (c.getSuperclass() != Object.class) {
errors.add(new AnnotatedMethodException(
"bindings using annonymous classes can only extend Object class"));
return new AnnotatedBindMethod[0];
}
for (final Method method : c.getMethods()) {
try {
if (method.isAnnotationPresent(Bind.class)) {
checkNonStaticSignature(method);
final Bind bind = method.getAnnotation(Bind.class);
target = bind.to();
final AnnotatedBindMethod boundMethod =
new AnnotatedBindMethod(target, method, object);
list.add(boundMethod);
}
} catch (final AnnotatedMethodException e) {
errors.add(e);
}
}
final AnnotatedBindMethod[] binds =
list.toArray(new AnnotatedBindMethod[list.size()]);
cache.put(c, binds);
return binds;
}