当前位置: 首页>>代码示例>>Java>>正文


Java Bind.from方法代码示例

本文整理汇总了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;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:43,代码来源:AnnotatedBinding.java

示例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;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:57,代码来源:AnnotatedBindMethod.java


注:本文中的org.jnetpcap.packet.annotate.Bind.from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。