Class Util
java.lang.Object
org.apache.tomcat.websocket.Util
Utility class for internal use only within the
org.apache.tomcat.websocket package.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHolds the result of matching decoders against a target type. -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectcoerceToType(Class<?> type, String value) Coerces a string value to the specified type.static List<DecoderEntry> getDecoders(List<Class<? extends Decoder>> decoderClazzes, InstanceManager instanceManager) Build the list of decoder entries from a set of decoder implementations.static booleanisPrimitive(Class<?> clazz) Returns whether the given class is a primitive type or its wrapper class.static voidparseExtensionHeader(List<Extension> extensions, String header) Parses a Sec-WebSocket-Extensions header value and populates the given list with the parsed extensions.
-
Method Details
-
isPrimitive
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
Coerces a string value to the specified type.- Parameters:
type- The target typevalue- The string value to coerce- Returns:
- The coerced value
- Throws:
IllegalArgumentException- If the type is not supported
-
getDecoders
public static List<DecoderEntry> getDecoders(List<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
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:
IllegalArgumentException- If the header contains invalid tokens or values
-