javax.websocket.Decoder.Binary Java Examples
The following examples show how to use
javax.websocket.Decoder.Binary.
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: PojoMessageHandlerWholeBinary.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override protected Object decode(ByteBuffer message) throws DecodeException { for (Decoder decoder : decoders) { if (decoder instanceof Binary) { if (((Binary<?>) decoder).willDecode(message)) { return ((Binary<?>) decoder).decode(message); } } else { byte[] array = new byte[message.limit() - message.position()]; message.get(array); ByteArrayInputStream bais = new ByteArrayInputStream(array); try { return ((BinaryStream<?>) decoder).decode(bais); } catch (IOException ioe) { throw new DecodeException(message, sm.getString( "pojoMessageHandlerWhole.decodeIoFail"), ioe); } } } return null; }
Example #2
Source File: PojoMessageHandlerWholeBinary.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override protected Object decode(ByteBuffer message) throws DecodeException { for (Decoder decoder : decoders) { if (decoder instanceof Binary) { if (((Binary<?>) decoder).willDecode(message)) { return ((Binary<?>) decoder).decode(message); } } else { byte[] array = new byte[message.limit() - message.position()]; message.get(array); ByteArrayInputStream bais = new ByteArrayInputStream(array); try { return ((BinaryStream<?>) decoder).decode(bais); } catch (IOException ioe) { throw new DecodeException(message, sm.getString( "pojoMessageHandlerWhole.decodeIoFail"), ioe); } } } return null; }
Example #3
Source File: PojoMessageHandlerWholeBinary.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override protected Object decode(ByteBuffer message) throws DecodeException { for (Decoder decoder : decoders) { if (decoder instanceof Binary) { if (((Binary<?>) decoder).willDecode(message)) { return ((Binary<?>) decoder).decode(message); } } else { byte[] array = new byte[message.limit() - message.position()]; message.get(array); ByteArrayInputStream bais = new ByteArrayInputStream(array); try { return ((BinaryStream<?>) decoder).decode(bais); } 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 |
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 |
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 |
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")); } } } }