Package org.apache.tomcat.websocket
Class Util
- java.lang.Object
-
- org.apache.tomcat.websocket.Util
-
public class Util extends java.lang.ObjectUtility class for internal use only within theorg.apache.tomcat.websocketpackage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUtil.DecoderMatchHolds the result of matching decoders against a target type.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ObjectcoerceToType(java.lang.Class<?> type, java.lang.String value)Coerces a string value to the specified type.static java.util.List<DecoderEntry>getDecoders(java.util.List<java.lang.Class<? extends Decoder>> decoderClazzes, InstanceManager instanceManager)Build the list of decoder entries from a set of decoder implementations.static booleanisPrimitive(java.lang.Class<?> clazz)Returns whether the given class is a primitive type or its wrapper class.static voidparseExtensionHeader(java.util.List<Extension> extensions, java.lang.String header)Parses a Sec-WebSocket-Extensions header value and populates the given list with the parsed extensions.
-
-
-
Method Detail
-
isPrimitive
public static boolean isPrimitive(java.lang.Class<?> clazz)
Returns whether the given class is a primitive type or its wrapper class.- Parameters:
clazz- The class to check- Returns:
trueif the class is a primitive or wrapper type,falseotherwise
-
coerceToType
public static java.lang.Object coerceToType(java.lang.Class<?> type, java.lang.String value)Coerces a string value to the specified type.- Parameters:
type- The target typevalue- The string value to coerce- Returns:
- The coerced value
- Throws:
java.lang.IllegalArgumentException- If the type is not supported
-
getDecoders
public static java.util.List<DecoderEntry> getDecoders(java.util.List<java.lang.Class<? extends Decoder>> decoderClazzes, InstanceManager instanceManager) throws DeploymentException
Build the list of decoder entries from a set of decoder implementations.- Parameters:
decoderClazzes- Decoder implementation classesinstanceManager- Instance manager to use to create Decoder instances- Returns:
- List of mappings from target type to associated decoder
- Throws:
DeploymentException- If a provided decoder class is not valid
-
parseExtensionHeader
public static void parseExtensionHeader(java.util.List<Extension> extensions, java.lang.String header)
Parses a Sec-WebSocket-Extensions header value and populates the given list with the parsed extensions.- Parameters:
extensions- The list to populate with parsed extensionsheader- The header value to parse- Throws:
java.lang.IllegalArgumentException- If the header contains invalid tokens or values
-
-