⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 octetencoder.java

📁 SMPP(点到点短消息协议)的java实现
💻 JAVA
字号:
package ie.omk.smpp.message.tlv;/** * Encode an octet string to a byte array. This class is encoding byte arrays to * byte arrays! Therefore it's just copying bytes around. Not much more to it. *  * @author Oran Kelly * @version $Id: OctetEncoder.java 255 2006-03-09 09:34:37Z orank $ */public class OctetEncoder implements Encoder {    private static final String BAD_VALUE_MSG = "Value must be of type byte[]";    /**     * Create a new OctetEncoder.     */    public OctetEncoder() {    }    public void writeTo(Tag tag, Object value, byte[] b, int offset) {        try {            byte[] valBytes = (byte[]) value;            System.arraycopy(valBytes, 0, b, offset, valBytes.length);        } catch (ClassCastException x) {            throw new BadValueTypeException(BAD_VALUE_MSG);        }    }    public Object readFrom(Tag tag, byte[] b, int offset, int length) {        byte[] val = new byte[length];        System.arraycopy(b, offset, val, 0, length);        return val;    }    public int getValueLength(Tag tag, Object value) {        try {            byte[] b = (byte[]) value;            return b.length;        } catch (ClassCastException x) {            throw new BadValueTypeException(BAD_VALUE_MSG);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -