javax.websocket.Decoder.Text Java Examples

The following examples show how to use javax.websocket.Decoder.Text. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PojoMessageHandlerWholeText.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@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;
}
 
Example #2
Source File: PojoMessageHandlerWholeText.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #3
Source File: PojoMessageHandlerWholeText.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #4
Source File: Util.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public DecoderMatch(Class<?> target, List<DecoderEntry> decoderEntries) {
    this.target = target;
    for (DecoderEntry decoderEntry : decoderEntries) {
        if (decoderEntry.getClazz().isAssignableFrom(target)) {
            if (Binary.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                binaryDecoders.add(decoderEntry.getDecoderClazz());
                // willDecode() method means this decoder may or may not
                // decode a message so need to carry on checking for
                // other matches
            } else if (BinaryStream.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                binaryDecoders.add(decoderEntry.getDecoderClazz());
                // Stream decoders have to process the message so no
                // more decoders can be matched
                break;
            } else if (Text.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                textDecoders.add(decoderEntry.getDecoderClazz());
                // willDecode() method means this decoder may or may not
                // decode a message so need to carry on checking for
                // other matches
            } else if (TextStream.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                textDecoders.add(decoderEntry.getDecoderClazz());
                // Stream decoders have to process the message so no
                // more decoders can be matched
                break;
            } else {
                throw new IllegalArgumentException(
                        sm.getString("util.unknownDecoderType"));
            }
        }
    }
}
 
Example #5
Source File: Util.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public DecoderMatch(Class<?> target, List<DecoderEntry> decoderEntries) {
    this.target = target;
    for (DecoderEntry decoderEntry : decoderEntries) {
        if (decoderEntry.getClazz().isAssignableFrom(target)) {
            if (Binary.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                binaryDecoders.add(decoderEntry.getDecoderClazz());
                // willDecode() method means this decoder may or may not
                // decode a message so need to carry on checking for
                // other matches
            } else if (BinaryStream.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                binaryDecoders.add(decoderEntry.getDecoderClazz());
                // Stream decoders have to process the message so no
                // more decoders can be matched
                break;
            } else if (Text.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                textDecoders.add(decoderEntry.getDecoderClazz());
                // willDecode() method means this decoder may or may not
                // decode a message so need to carry on checking for
                // other matches
            } else if (TextStream.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                textDecoders.add(decoderEntry.getDecoderClazz());
                // Stream decoders have to process the message so no
                // more decoders can be matched
                break;
            } else {
                throw new IllegalArgumentException(
                        sm.getString("util.unknownDecoderType"));
            }
        }
    }
}
 
Example #6
Source File: Util.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public DecoderMatch(Class<?> target, List<DecoderEntry> decoderEntries) {
    this.target = target;
    for (DecoderEntry decoderEntry : decoderEntries) {
        if (decoderEntry.getClazz().isAssignableFrom(target)) {
            if (Binary.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                binaryDecoders.add(decoderEntry.getDecoderClazz());
                // willDecode() method means this decoder may or may not
                // decode a message so need to carry on checking for
                // other matches
            } else if (BinaryStream.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                binaryDecoders.add(decoderEntry.getDecoderClazz());
                // Stream decoders have to process the message so no
                // more decoders can be matched
                break;
            } else if (Text.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                textDecoders.add(decoderEntry.getDecoderClazz());
                // willDecode() method means this decoder may or may not
                // decode a message so need to carry on checking for
                // other matches
            } else if (TextStream.class.isAssignableFrom(
                    decoderEntry.getDecoderClazz())) {
                textDecoders.add(decoderEntry.getDecoderClazz());
                // Stream decoders have to process the message so no
                // more decoders can be matched
                break;
            } else {
                throw new IllegalArgumentException(
                        sm.getString("util.unknownDecoderType"));
            }
        }
    }
}