ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
Status
scanned
Type
file
Name
PojoMessageHandlerWholeText.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
4712 (4.6 KB)
MD5
bccbe3e031bea69f1217b801b61fa45c
SHA1
4d5df938af07f25866b8dd0f393a9483562b13b6
SHA256
a96154072579d35cc2c34046d0eb4c4c710b924789ce4adef477acb5f3178428
SHA512

      
    
SHA1_git
f06aac07416c78c2b8cfa2c07ba347007e062e4f
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
PojoMessageHandlerWholeText.java | 4.6 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.websocket.pojo; import java.io.IOException; import java.io.StringReader; import java.lang.reflect.Method; import java.util.List; import javax.naming.NamingException; import jakarta.websocket.DecodeException; import jakarta.websocket.Decoder; import jakarta.websocket.Decoder.Text; import jakarta.websocket.Decoder.TextStream; import jakarta.websocket.EndpointConfig; import jakarta.websocket.Session; import org.apache.tomcat.util.res.StringManager; import org.apache.tomcat.websocket.Util; /** * Text specific concrete implementation for handling whole messages. */ public class PojoMessageHandlerWholeText extends PojoMessageHandlerWholeBase<String> { private static final StringManager sm = StringManager.getManager(PojoMessageHandlerWholeText.class); private final Class<?> primitiveType; public PojoMessageHandlerWholeText(Object pojo, Method method, Session session, EndpointConfig config, List<Class<? extends Decoder>> decoderClazzes, Object[] params, int indexPayload, boolean convert, int indexSession, long maxMessageSize) { super(pojo, method, session, params, indexPayload, convert, indexSession, maxMessageSize); // Update max text size handled by session if (maxMessageSize > -1 && maxMessageSize > session.getMaxTextMessageBufferSize()) { if (maxMessageSize > Integer.MAX_VALUE) { throw new IllegalArgumentException(sm.getString("pojoMessageHandlerWhole.maxBufferSize")); } session.setMaxTextMessageBufferSize((int) maxMessageSize); } // Check for primitives Class<?> type = method.getParameterTypes()[indexPayload]; if (Util.isPrimitive(type)) { primitiveType = type; return; } else { primitiveType = null; } try { if (decoderClazzes != null) { for (Class<? extends Decoder> decoderClazz : decoderClazzes) { if (Text.class.isAssignableFrom(decoderClazz)) { Text<?> decoder = (Text<?>) createDecoderInstance(decoderClazz); decoder.init(config); decoders.add(decoder); } else if (TextStream.class.isAssignableFrom(decoderClazz)) { TextStream<?> decoder = (TextStream<?>) createDecoderInstance(decoderClazz); decoder.init(config); decoders.add(decoder); } else { // Binary decoder - ignore it } } } } catch (ReflectiveOperationException | NamingException e) { throw new IllegalArgumentException(e); } } @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; } @Override protected Object convert(String message) { return new StringReader(message); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
28.61
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9