本文整理汇总了Java中org.apache.commons.codec.DecoderException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java DecoderException.getMessage方法的具体用法?Java DecoderException.getMessage怎么用?Java DecoderException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.codec.DecoderException
的用法示例。
在下文中一共展示了DecoderException.getMessage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unhex
import org.apache.commons.codec.DecoderException; //导入方法依赖的package包/类
public Encoder unhex() {
try {
data = new Hex().decode(data);
return this;
} catch (DecoderException e) {
throw new BaseException(e, "Failed to convert data from hex: %s", e.getMessage());
}
}
示例2: compute
import org.apache.commons.codec.DecoderException; //导入方法依赖的package包/类
public Checksum compute(final String data, final TransferStatus status) throws ChecksumException {
try {
return this.compute(new ByteArrayInputStream(Hex.decodeHex(data.toCharArray())), status);
}
catch(DecoderException e) {
throw new ChecksumException(LocaleFactory.localizedString("Checksum failure", "Error"), e.getMessage(), e);
}
}
示例3: decode
import org.apache.commons.codec.DecoderException; //导入方法依赖的package包/类
/**
* Unescape and decode a given string regarded as an escaped string with the
* default protocol charset.
*
* @param escaped a string
* @return the unescaped string
* @throws HttpException if the string cannot be decoded (invalid)
*/
public static String decode(String escaped) throws HttpException {
try {
byte[] rawdata = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(escaped));
return EncodingUtils.getString(rawdata, UTF8_CHARSET_NAME);
} catch (DecoderException e) {
throw new HttpException(e.getMessage());
}
}
示例4: decode
import org.apache.commons.codec.DecoderException; //导入方法依赖的package包/类
public static byte[] decode(String hexString){
try {
return Hex.decodeHex(hexString.toCharArray());
} catch (DecoderException e) {
throw new DataDecodeException(e.getMessage(), e);
}
}
示例5: handle
import org.apache.commons.codec.DecoderException; //导入方法依赖的package包/类
@Override
public void handle(HttpExchange t) throws IOException {
try {
InputStream is = t.getRequestBody();
StringWriter writer = new StringWriter();
IOUtils.copy(is, writer, "UTF-8");
String theString = writer.toString();
List<NameValuePair> params = URLEncodedUtils.parse(theString, Charset.forName("UTF-8"));
IridiumMessage message = new IridiumMessage(params);
logger.debug(message);
if (message.data == null || message.data.isEmpty()) {
logger.info(MessageFormat.format("Empty MO message received ''{0}''.", message.toString()));
} else if (message.imei.equalsIgnoreCase(imei)) {
MAVLinkPacket packet = message.getPacket();
if (packet != null) {
MAVLinkLogger.log(Level.INFO, "MO", packet);
dst.sendMessage(packet);
} else {
logger.warn(MessageFormat.format("Invalid MAVLink message ''{0}''.", message.toString()));
}
} else {
logger.warn(MessageFormat.format("Invalid IMEI ''{0}''.", message.imei));
}
//Send response
String response = "";
t.sendResponseHeaders(200, response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
} catch (DecoderException e) {
logger.error(e.getMessage());
throw new IOException(e.getMessage());
}
}
示例6: decode
import org.apache.commons.codec.DecoderException; //导入方法依赖的package包/类
/**
* Decodes URI encoded string.
* <p/>
* This is a two mapping, one from URI characters to octets, and
* subsequently a second from octets to original characters:
* <p><blockquote><pre>
* URI character sequence->octet sequence->original character sequence
* </pre></blockquote><p>
* <p/>
* A URI must be separated into its components before the escaped
* characters within those components can be allowedly decoded.
* <p/>
* Notice that there is a chance that URI characters that are non UTF-8
* may be parsed as valid UTF-8. A recent non-scientific analysis found
* that EUC encoded Japanese words had a 2.7% false reading; SJIS had a
* 0.0005% false reading; other encoding such as ASCII or KOI-8 have a 0%
* false reading.
* <p/>
* The percent "%" character always has the reserved purpose of being
* the escape indicator, it must be escaped as "%25" in order to be used
* as data within a URI.
* <p/>
* The unescape method is internally performed within this method.
*
* @param component the URI character sequence
* @param charset the protocol charset
* @return original character sequence
* @throws HttpException incomplete trailing escape pattern or unsupported
* character encoding
* @since 3.0
*/
protected static String decode(String component, String charset)
throws HttpException {
if (component == null) {
throw new IllegalArgumentException("Component array of chars may not be null");
}
byte[] rawData;
try {
rawData = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(component));
} catch (DecoderException e) {
throw new HttpException(e.getMessage());
}
return EncodingUtils.getString(rawData, charset);
}
示例7: decode
import org.apache.commons.codec.DecoderException; //导入方法依赖的package包/类
/**
* Unescape and decode a given string regarded as an escaped string with the
* default protocol charset.
*
* @param escaped a string
* @return the unescaped string
*
* @throws URIException if the string cannot be decoded (invalid)
*
* @see URI#getDefaultProtocolCharset
*/
public static String decode(String escaped) throws URIException {
try {
byte[] rawdata = URLCodec.decodeUrl(EncodingUtil.getAsciiBytes(escaped));
return EncodingUtil.getString(rawdata, URI.getDefaultProtocolCharset());
} catch (DecoderException e) {
throw new URIException(e.getMessage());
}
}
示例8: decode
import org.apache.commons.codec.DecoderException; //导入方法依赖的package包/类
/**
* Decodes URI encoded string.
*
* This is a two mapping, one from URI characters to octets, and
* subsequently a second from octets to original characters:
* <p><blockquote><pre>
* URI character sequence->octet sequence->original character sequence
* </pre></blockquote><p>
*
* A URI must be separated into its components before the escaped
* characters within those components can be allowedly decoded.
* <p>
* Notice that there is a chance that URI characters that are non UTF-8
* may be parsed as valid UTF-8. A recent non-scientific analysis found
* that EUC encoded Japanese words had a 2.7% false reading; SJIS had a
* 0.0005% false reading; other encoding such as ASCII or KOI-8 have a 0%
* false reading.
* <p>
* The percent "%" character always has the reserved purpose of being
* the escape indicator, it must be escaped as "%25" in order to be used
* as data within a URI.
* <p>
* The unescape method is internally performed within this method.
*
* @param component the URI character sequence
* @param charset the protocol charset
* @return original character sequence
* @throws URIException incomplete trailing escape pattern or unsupported
* character encoding
*
* @since 3.0
*/
protected static String decode(String component, String charset)
throws URIException {
if (component == null) {
throw new IllegalArgumentException("Component array of chars may not be null");
}
byte[] rawdata = null;
try {
rawdata = URLCodec.decodeUrl(EncodingUtil.getAsciiBytes(component));
} catch (DecoderException e) {
throw new URIException(e.getMessage());
}
return EncodingUtil.getString(rawdata, charset);
}