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


Java Bind类代码示例

本文整理汇总了Java中org.jnetpcap.packet.annotate.Bind的典型用法代码示例。如果您正苦于以下问题:Java Bind类的具体用法?Java Bind怎么用?Java Bind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Bind类属于org.jnetpcap.packet.annotate包,在下文中一共展示了Bind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bind2Http

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
/**
 * Bind2 http.
 * 
 * @param packet
 *          the packet
 * @param http
 *          the http
 * @return true, if successful
 */
@Bind(to = Http.class)
public static boolean bind2Http(JPacket packet, Http http) {
	Http.ContentType type = http.contentTypeEnum();
	switch (type) {
		case JPEG:
		case PNG:
		case GIF:
			return true;

		default:
			return false;
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:23,代码来源:WebImage.java

示例2: checkSignature

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
/**
 * Check signature.
 * 
 * @param method
 *          the method
 */
private static void checkSignature(final Method method) {

	final Class<?> declaringClass = method.getDeclaringClass();

	if (method.isAnnotationPresent(Bind.class) == false) {
		throw new AnnotatedMethodException(declaringClass,
		    "@Bind annotation missing for " + method.getName() + "()");
	}

	/*
	 * Now make sure it has the right signature of: <code>static int
	 * name(JBuffer, int)</code.
	 */
	final Class<?>[] sig = method.getParameterTypes();
	if (sig.length != 2 || sig[0] != JPacket.class
	    || sig[1].isAssignableFrom(JHeader.class)) {
		throw new AnnotatedMethodException(declaringClass,
		    "Invalid signature for " + method.getName() + "()");
	}

	if ((method.getModifiers() & Modifier.STATIC) == 0) {
		throw new AnnotatedMethodException(declaringClass, method.getName()
		    + "()" + " must be declared static");
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:32,代码来源:AnnotatedBindMethod.java

示例3: checkNonStaticSignature

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
/**
 * Check non static signature.
 * 
 * @param method
 *          the method
 */
private static void checkNonStaticSignature(final Method method) {

	final Class<?> declaringClass = method.getDeclaringClass();

	if (method.isAnnotationPresent(Bind.class) == false) {
		throw new AnnotatedMethodException(declaringClass,
		    "@Bind annotation missing for " + method.getName() + "()");
	}

	/*
	 * Now make sure it has the right signature of: <code>static int
	 * name(JBuffer, int)</code.
	 */
	final Class<?>[] sig = method.getParameterTypes();
	if (sig.length != 2 || sig[0] != JPacket.class
	    || sig[1].isAssignableFrom(JHeader.class)) {
		throw new AnnotatedMethodException(declaringClass,
		    "Invalid signature for " + method.getName() + "()");
	}

	if ((method.getModifiers() & Modifier.STATIC) != 0) {
		throw new AnnotatedMethodException(declaringClass, method.getName()
		    + "()" + " can not be declared static");
	}
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:32,代码来源:AnnotatedBindMethod.java

示例4: bind2Udp

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
@Bind(to = Udp.class)
public static boolean bind2Udp(JPacket packet, Udp udp) {
	return udp.destination() == 1812 || udp.source() == 1812 // Server
			|| udp.destination() == 1813 || udp.source() == 1813 // Accounting
			|| udp.destination() == 3799 || udp.source() == 3799 // Authorization
			|| udp.destination() == 1646 || udp.source() == 1646; // Obsolete
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:8,代码来源:Radius.java

示例5: 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

示例6: 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

示例7: 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

示例8: testRegistryDump

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
/**
 * Test registry dump.
 * 
 * @throws RegistryHeaderErrors
 *             the registry header errors
 */
public void testRegistryDump() throws RegistryHeaderErrors {
	JRegistry.register(MyHeader.class);

	JRegistry.lookupId(MyHeader.class);

	Object o = new Object() {

		@SuppressWarnings("unused")
		@Bind(from = Ip4.class, to = MyHeader.class)
		public boolean bindIp4ToMyHeader(JPacket packet, MyHeader my) {
			return my.type() == 0x800;
		}

		@SuppressWarnings("unused")
		@Scanner(Ip4.class)
		public void scanIp4(JScan scan) {

		}
	};

	JRegistry.addBindings(o);
	JRegistry.setScanners(o);
	System.out.println(JRegistry.toDebugString());

	JRegistry.clearScanners(o);
	System.out.println(JRegistry.toDebugString());
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:34,代码来源:TestJRegistry.java

示例9: bindToIp4

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
@Bind(to = Ip4.class)
public static boolean bindToIp4(JBuffer buffer, Ip4 ip) {
	return ip.type() == GRE_IP_TYPE; // GRE ip.type
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:5,代码来源:GRE.java

示例10: 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

示例11: 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

示例12: bindToTcp

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
@Bind(to = SctpData.class)
public static boolean bindToTcp(JPacket packet, SctpData data) {
	final Sctp sctp = local.get();
	return packet.hasHeader(sctp)
			&& (sctp.destination() == 3868 || sctp.source() == 3868);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:7,代码来源:Diameter.java

示例13: bindToUdp

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
/**
 * Bind to UDP port 520 which is the default for RIP.
 * 
 * @param packet
 *          current packet
 * @param udp
 *          udp header within this packet
 * @return true if binding succeeded or false if failed
 */
@Bind(to = Udp.class)
public static boolean bindToUdp(final JPacket packet,
		final org.jnetpcap.protocol.tcpip.Udp udp) {
	return (udp.destination() == 520) || (udp.source() == 520);
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:15,代码来源:Rip.java

示例14: bind2Http

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
/**
 * Bind2 http.
 * 
 * @param packet
 *          the packet
 * @param http
 *          the http
 * @return true, if successful
 */
@Bind(to = Http.class, stringValue = "text/html")
public static boolean bind2Http(JPacket packet, Http http) {
	return http.hasContentType() && http.contentType().startsWith("text/html;");
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:Html.java

示例15: bind2HttpAsCSS

import org.jnetpcap.packet.annotate.Bind; //导入依赖的package包/类
/**
 * Bind2 http as css.
 * 
 * @param packet
 *          the packet
 * @param http
 *          the http
 * @return true, if successful
 */
@Bind(to = Http.class, stringValue = "text/css")
public static boolean bind2HttpAsCSS(JPacket packet, Http http) {
	return http.hasContentType() && http.contentType().startsWith("text/css;");
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:14,代码来源:Html.java


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