當前位置: 首頁>>代碼示例>>Java>>正文


Java Bind.to方法代碼示例

本文整理匯總了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;
}
 
開發者ID:pvenne,項目名稱:jgoose,代碼行數:43,代碼來源:AnnotatedBinding.java

示例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;
}
 
開發者ID:pvenne,項目名稱:jgoose,代碼行數:48,代碼來源:AnnotatedBinding.java

示例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;
}
 
開發者ID:pvenne,項目名稱:jgoose,代碼行數:50,代碼來源:AnnotatedBindMethod.java

示例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;
}
 
開發者ID:pvenne,項目名稱:jgoose,代碼行數:57,代碼來源:AnnotatedBindMethod.java


注:本文中的org.jnetpcap.packet.annotate.Bind.to方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。