• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Util类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: decode

import org.apache.tomcat.websocket.Util; //导入依赖的package包/类
@Override
protected Object decode(String message) throws DecodeException {
    // Handle primitives
    if (primitiveType != null) {
        return Util.coerceToType(primitiveType, message);
    }
    // Handle full decoders
    for (Decoder decoder : decoders) {
        if (decoder instanceof Text) {
            if (((Text<?>) decoder).willDecode(message)) {
                return ((Text<?>) decoder).decode(message);
            }
        } else {
            StringReader r = new StringReader(message);
            try {
                return ((TextStream<?>) decoder).decode(r);
            } catch (IOException ioe) {
                throw new DecodeException(message, sm.getString(
                        "pojoMessageHandlerWhole.decodeIoFail"), ioe);
            }
        }
    }
    return null;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:25,代码来源:PojoMessageHandlerWholeText.java


示例2: decode

import org.apache.tomcat.websocket.Util; //导入依赖的package包/类
@Override
protected Object decode(String message) throws DecodeException {
	// Handle primitives
	if (primitiveType != null) {
		return Util.coerceToType(primitiveType, message);
	}
	// Handle full decoders
	for (Decoder decoder : decoders) {
		if (decoder instanceof Text) {
			if (((Text<?>) decoder).willDecode(message)) {
				return ((Text<?>) decoder).decode(message);
			}
		} else {
			StringReader r = new StringReader(message);
			try {
				return ((TextStream<?>) decoder).decode(r);
			} catch (IOException ioe) {
				throw new DecodeException(message, sm.getString("pojoMessageHandlerWhole.decodeIoFail"), ioe);
			}
		}
	}
	return null;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:24,代码来源:PojoMessageHandlerWholeText.java


示例3: buildArgs

import org.apache.tomcat.websocket.Util; //导入依赖的package包/类
private static Object[] buildArgs(PojoPathParam[] pathParams,
        Map<String,String> pathParameters, Session session,
        EndpointConfig config, Throwable throwable, CloseReason closeReason)
        throws DecodeException {
    Object[] result = new Object[pathParams.length];
    for (int i = 0; i < pathParams.length; i++) {
        Class<?> type = pathParams[i].getType();
        if (type.equals(Session.class)) {
            result[i] = session;
        } else if (type.equals(EndpointConfig.class)) {
            result[i] = config;
        } else if (type.equals(Throwable.class)) {
            result[i] = throwable;
        } else if (type.equals(CloseReason.class)) {
            result[i] = closeReason;
        } else {
            String name = pathParams[i].getName();
            String value = pathParameters.get(name);
            try {
                result[i] = Util.coerceToType(type, value);
            } catch (Exception e) {
                throw new DecodeException(value, sm.getString(
                        "pojoMethodMapping.decodePathParamFail",
                        value, type), e);
            }
        }
    }
    return result;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:30,代码来源:PojoMethodMapping.java


示例4: buildArgs

import org.apache.tomcat.websocket.Util; //导入依赖的package包/类
private static Object[] buildArgs(PojoPathParam[] pathParams, Map<String, String> pathParameters, Session session,
		EndpointConfig config, Throwable throwable, CloseReason closeReason) throws DecodeException {
	Object[] result = new Object[pathParams.length];
	for (int i = 0; i < pathParams.length; i++) {
		Class<?> type = pathParams[i].getType();
		if (type.equals(Session.class)) {
			result[i] = session;
		} else if (type.equals(EndpointConfig.class)) {
			result[i] = config;
		} else if (type.equals(Throwable.class)) {
			result[i] = throwable;
		} else if (type.equals(CloseReason.class)) {
			result[i] = closeReason;
		} else {
			String name = pathParams[i].getName();
			String value = pathParameters.get(name);
			try {
				result[i] = Util.coerceToType(type, value);
			} catch (Exception e) {
				throw new DecodeException(value, sm.getString("pojoMethodMapping.decodePathParamFail", value, type),
						e);
			}
		}
	}
	return result;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:PojoMethodMapping.java


示例5: getPathParams

import org.apache.tomcat.websocket.Util; //导入依赖的package包/类
private static PojoPathParam[] getPathParams(Method m,
        MethodType methodType) throws DeploymentException {
    if (m == null) {
        return new PojoPathParam[0];
    }
    boolean foundThrowable = false;
    Class<?>[] types = m.getParameterTypes();
    Annotation[][] paramsAnnotations = m.getParameterAnnotations();
    PojoPathParam[] result = new PojoPathParam[types.length];
    for (int i = 0; i < types.length; i++) {
        Class<?> type = types[i];
        if (type.equals(Session.class)) {
            result[i] = new PojoPathParam(type, null);
        } else if (methodType == MethodType.ON_OPEN &&
                type.equals(EndpointConfig.class)) {
            result[i] = new PojoPathParam(type, null);
        } else if (methodType == MethodType.ON_ERROR
                && type.equals(Throwable.class)) {
            foundThrowable = true;
            result[i] = new PojoPathParam(type, null);
        } else if (methodType == MethodType.ON_CLOSE &&
                type.equals(CloseReason.class)) {
            result[i] = new PojoPathParam(type, null);
        } else {
            Annotation[] paramAnnotations = paramsAnnotations[i];
            for (Annotation paramAnnotation : paramAnnotations) {
                if (paramAnnotation.annotationType().equals(
                        PathParam.class)) {
                    // Check that the type is valid. "0" coerces to every
                    // valid type
                    try {
                        Util.coerceToType(type, "0");
                    } catch (IllegalArgumentException iae) {
                        throw new DeploymentException(sm.getString(
                                "pojoMethodMapping.invalidPathParamType"),
                                iae);
                    }
                    result[i] = new PojoPathParam(type,
                            ((PathParam) paramAnnotation).value());
                    break;
                }
            }
            // Parameters without annotations are not permitted
            if (result[i] == null) {
                throw new DeploymentException(sm.getString(
                        "pojoMethodMapping.paramWithoutAnnotation",
                        type, m.getName(), m.getClass().getName()));
            }
        }
    }
    if (methodType == MethodType.ON_ERROR && !foundThrowable) {
        throw new DeploymentException(sm.getString(
                "pojoMethodMapping.onErrorNoThrowable",
                m.getName(), m.getDeclaringClass().getName()));
    }
    return result;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:58,代码来源:PojoMethodMapping.java


示例6: getPathParams

import org.apache.tomcat.websocket.Util; //导入依赖的package包/类
private static PojoPathParam[] getPathParams(Method m, MethodType methodType) throws DeploymentException {
	if (m == null) {
		return new PojoPathParam[0];
	}
	boolean foundThrowable = false;
	Class<?>[] types = m.getParameterTypes();
	Annotation[][] paramsAnnotations = m.getParameterAnnotations();
	PojoPathParam[] result = new PojoPathParam[types.length];
	for (int i = 0; i < types.length; i++) {
		Class<?> type = types[i];
		if (type.equals(Session.class)) {
			result[i] = new PojoPathParam(type, null);
		} else if (methodType == MethodType.ON_OPEN && type.equals(EndpointConfig.class)) {
			result[i] = new PojoPathParam(type, null);
		} else if (methodType == MethodType.ON_ERROR && type.equals(Throwable.class)) {
			foundThrowable = true;
			result[i] = new PojoPathParam(type, null);
		} else if (methodType == MethodType.ON_CLOSE && type.equals(CloseReason.class)) {
			result[i] = new PojoPathParam(type, null);
		} else {
			Annotation[] paramAnnotations = paramsAnnotations[i];
			for (Annotation paramAnnotation : paramAnnotations) {
				if (paramAnnotation.annotationType().equals(PathParam.class)) {
					// Check that the type is valid. "0" coerces to every
					// valid type
					try {
						Util.coerceToType(type, "0");
					} catch (IllegalArgumentException iae) {
						throw new DeploymentException(sm.getString("pojoMethodMapping.invalidPathParamType"), iae);
					}
					result[i] = new PojoPathParam(type, ((PathParam) paramAnnotation).value());
					break;
				}
			}
			// Parameters without annotations are not permitted
			if (result[i] == null) {
				throw new DeploymentException(sm.getString("pojoMethodMapping.paramWithoutAnnotation", type,
						m.getName(), m.getClass().getName()));
			}
		}
	}
	if (methodType == MethodType.ON_ERROR && !foundThrowable) {
		throw new DeploymentException(
				sm.getString("pojoMethodMapping.onErrorNoThrowable", m.getName(), m.getDeclaringClass().getName()));
	}
	return result;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:48,代码来源:PojoMethodMapping.java


示例7: PojoMethodMapping

import org.apache.tomcat.websocket.Util; //导入依赖的package包/类
public PojoMethodMapping(Class<?> clazzPojo,
        Class<? extends Decoder>[] decoderClazzes, String wsPath)
                throws DeploymentException {

    this.wsPath = wsPath;

    List<DecoderEntry> decoders = Util.getDecoders(decoderClazzes);
    Method open = null;
    Method close = null;
    Method error = null;
    for (Method method : clazzPojo.getDeclaredMethods()) {
        if (method.getAnnotation(OnOpen.class) != null) {
            checkPublic(method);
            if (open == null) {
                open = method;
            } else {
                // Duplicate annotation
                throw new DeploymentException(sm.getString(
                        "pojoMethodMapping.duplicateAnnotation",
                        OnOpen.class, clazzPojo));
            }
        } else if (method.getAnnotation(OnClose.class) != null) {
            checkPublic(method);
            if (close == null) {
                close = method;
            } else {
                // Duplicate annotation
                throw new DeploymentException(sm.getString(
                        "pojoMethodMapping.duplicateAnnotation",
                        OnClose.class, clazzPojo));
            }
        } else if (method.getAnnotation(OnError.class) != null) {
            checkPublic(method);
            if (error == null) {
                error = method;
            } else {
                // Duplicate annotation
                throw new DeploymentException(sm.getString(
                        "pojoMethodMapping.duplicateAnnotation",
                        OnError.class, clazzPojo));
            }
        } else if (method.getAnnotation(OnMessage.class) != null) {
            checkPublic(method);
            onMessage.add(new MessageHandlerInfo(method, decoders));
        } else {
            // Method not annotated
        }
    }
    this.onOpen = open;
    this.onClose = close;
    this.onError = error;
    onOpenParams = getPathParams(onOpen, MethodType.ON_OPEN);
    onCloseParams = getPathParams(onClose, MethodType.ON_CLOSE);
    onErrorParams = getPathParams(onError, MethodType.ON_ERROR);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:56,代码来源:PojoMethodMapping.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InstantiateTransformer类代码示例发布时间:2022-05-22
下一篇:
Java CryptoUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap