javax.websocket.DecodeException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中javax.websocket.DecodeException.<init>()方法的一些代码示例,展示了DecodeException.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DecodeException.<init>()方法的具体详情如下:
包路径:javax.websocket.DecodeException
类名称:DecodeException
方法名:<init>

DecodeException.<init>介绍

[英]Constructs a DecodedException with the given encoded string that cannot be decoded, and reason why. The encoded string may represent the whole message, or the part of the message most relevant to the decoding error, depending whether the application is using one of the streaming methods or not.
[中]使用无法解码的给定编码字符串构造DecodedException,并说明原因。编码字符串可以表示整个消息,或者与解码错误最相关的消息部分,这取决于应用程序是否使用流方法之一。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Decode the a message into an object.
 * @see javax.websocket.Decoder.Text#decode(String)
 * @see javax.websocket.Decoder.Binary#decode(ByteBuffer)
 */
@SuppressWarnings("unchecked")
@Nullable
public T decode(M message) throws DecodeException {
  try {
    return (T) getConversionService().convert(message, getMessageType(), getType());
  }
  catch (ConversionException ex) {
    if (message instanceof String) {
      throw new DecodeException((String) message,
          "Unable to decode websocket message using ConversionService", ex);
    }
    if (message instanceof ByteBuffer) {
      throw new DecodeException((ByteBuffer) message,
          "Unable to decode websocket message using ConversionService", ex);
    }
    throw ex;
  }
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

@Override
  public Byte decode(String s) throws DecodeException {
    Byte result;
    try {
      result = Byte.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

@Override
  public Boolean decode(String s) throws DecodeException {
    Boolean result;
    try {
      result = Boolean.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

@Override
  public Float decode(String s) throws DecodeException {
    Float result;
    try {
      result = Float.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

@Override
  public Integer decode(String s) throws DecodeException {
    Integer result;
    try {
      result = Integer.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

@Override
  public Short decode(String s) throws DecodeException {
    Short result;
    try {
      result = Short.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: com.powsybl/powsybl-afs-ws-utils

@Override
public T decode(String s) throws DecodeException {
  try {
    return objectMapper.readValue(s, type);
  } catch (IOException e) {
    throw new DecodeException(s, "Decoding error", e);
  }
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

@Override
  public Double decode(String s) throws DecodeException {
    Double result;
    try {
      result = Double.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

@Override
  public Long decode(String s) throws DecodeException {
    Long result;
    try {
      result = Long.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

@Override
  public Character decode(String s) throws DecodeException {
    Character result;
    try {
      result = s.charAt(0);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: eclipse-ee4j/tyrus

@Override
  public Long decode(String s) throws DecodeException {
    Long result;
    try {
      result = Long.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: eclipse-ee4j/tyrus

@Override
  public Character decode(String s) throws DecodeException {
    Character result;
    try {
      result = s.charAt(0);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: eclipse-ee4j/tyrus

@Override
  public Double decode(String s) throws DecodeException {
    Double result;
    try {
      result = Double.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: eclipse-ee4j/tyrus

@Override
  public Integer decode(String s) throws DecodeException {
    Integer result;
    try {
      result = Integer.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: eclipse-ee4j/tyrus

@Override
  public Byte decode(String s) throws DecodeException {
    Byte result;
    try {
      result = Byte.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: eclipse-ee4j/tyrus

@Override
  public Short decode(String s) throws DecodeException {
    Short result;
    try {
      result = Short.valueOf(s);
    } catch (Exception e) {
      throw new DecodeException(s, "Decoding failed", e);
    }
    return result;
  }
}

代码示例来源:origin: Apicurio/apicurio-studio

@Override
public JsonNode decode(String value) throws DecodeException {
  try {
    return mapper.readTree(value);
  } catch (IOException e) {
    throw new DecodeException(value, e.getMessage());
  }
}

代码示例来源:origin: io.apicurio/apicurio-studio-be-hub-editing

@Override
public JsonNode decode(String value) throws DecodeException {
  try {
    return mapper.readTree(value);
  } catch (IOException e) {
    throw new DecodeException(value, e.getMessage());
  }
}

代码示例来源:origin: rocks.xmpp/xmpp-websocket-common

@Override
public final StreamElement decode(final String s) throws DecodeException {
  try (StringReader reader = new StringReader(s)) {
    StreamElement streamElement = (StreamElement) unmarshaller.get().unmarshal(reader);
    if (onRead != null) {
      onRead.accept(s, streamElement);
    }
    return streamElement;
  } catch (JAXBException e) {
    throw new DecodeException(s, e.getMessage(), e);
  }
}

代码示例来源:origin: icode/ameba

@Override
public T decode(ByteBuffer bytes) throws DecodeException {
  try {
    return mapper.readValue(new ByteBufferBackedInputStream(bytes), objectClass);
  } catch (IOException e) {
    throw new DecodeException(bytes, "decode json error", e);
  }
}

相关文章

微信公众号

最新文章

更多

DecodeException类方法