本文整理匯總了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;
}