亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? isomessage.java

?? iso8583協議的java實現
?? JAVA
字號:
/*j8583 A Java implementation of the ISO8583 protocolCopyright (C) 2007 Enrique Zamudio LopezThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA*/package com.solab.iso8583;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.OutputStream;import java.nio.ByteBuffer;import java.util.ArrayList;import java.util.BitSet;import java.util.Collections;import java.util.Hashtable;import java.util.Iterator;/** Represents an ISO8583 message. This is the core class of the framework. * Contains the bitmap which is modified as fields are added/removed. * This class makes no assumptions as to what types belong in each field, * nor what fields should each different message type have; that is left * for the developer, since the different ISO8583 implementations can vary * greatly. *  * @author Enrique Zamudio */public class IsoMessage {	static final byte[] HEX = new byte[]{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };	/** The message type. */    private int type;    /** Indicates if the message is binary-coded. */    private boolean binary;    /** This is where the values are stored. */    private Hashtable fields = new Hashtable();    /** Stores the optional ISO header. */    private String isoHeader;    private int etx = -1;    /** Creates a new empty message with no values set. */    public IsoMessage() {    }    /** Creates a new message with the specified ISO header. This will be prepended to the message. */    IsoMessage(String header) {    	isoHeader = header;    }    /** Returns the ISO header that this message was created with. */    public String getIsoHeader() {    	return isoHeader;    }    /** Sets the ISO message type. Common values are 0x200, 0x210, 0x400, 0x410, 0x800, 0x810. */    public void setType(int value) {    	type = value;    }    /** Returns the ISO message type. */    public int getType() {    	return type;    }    /** Indicates whether the message should be binary. Default is false. */    public void setBinary(boolean flag) {    	binary = flag;    }    /** Returns true if the message is binary coded; default is false. */    public boolean isBinary() {    	return binary;    }    /** Sets the ETX character, which is sent at the end of the message as a terminator.     * Default is -1, which means no terminator is sent. */    public void setEtx(int value) {    	etx = value;    }    /** Returns the stored value in the field, without converting or formatting it.     * @param field The field number. 1 is the secondary bitmap and is not returned as such;     * real fields go from 2 to 128. */    public Object getObjectValue(int field) {    	IsoValue v = (IsoValue)fields.get(new Integer(field));    	if (v == null) {    		return null;    	}    	return v.getValue();    }    /** Returns the IsoValue for the specified field. First real field is 2. */    public IsoValue getField(int field) {    	return (IsoValue)fields.get(new Integer(field));    }    /** Stored the field in the specified index. The first field is the secondary bitmap and has index 1,     * so the first valid value for index must be 2. */    public void setField(int index, IsoValue field) {    	if (index < 2 || index > 128) {    		throw new IndexOutOfBoundsException("Field index must be between 2 and 128");    	}    	if (field == null) {    		fields.remove(new Integer(index));    	} else {    		fields.put(new Integer(index), field);    	}    }    /** Sets the specified value in the specified field, creating an IsoValue internally.     * @param index The field number (2 to 128)     * @param value The value to be stored.     * @param t The ISO type.     * @param length The length of the field, used for ALPHA and NUMERIC values only, ignored     * with any other type. */    public void setValue(int index, Object value, IsoType t, int length) {    	if (index < 2 || index > 128) {    		throw new IndexOutOfBoundsException("Field index must be between 2 and 128");    	}    	if (value == null) {    		fields.remove(new Integer(index));    	} else {    		IsoValue v = null;    		if (t.needsLength()) {    			v = new IsoValue(t, value, length);    		} else {    			v = new IsoValue(t, value);    		}    		fields.put(new Integer(index), v);    	}    }    /** Returns true is the message has a value in the specified field.     * @param idx The field number. */    public boolean hasField(int idx) {    	return fields.get(new Integer(idx)) != null;    }    /** Writes a message to a stream, after writing the specified number of bytes indicating     * the message's length. The message will first be written to an internal memory stream     * which will then be dumped into the specified stream. This method flushes the stream     * after the write. There are at most three write operations to the stream: one for the     * length header, one for the message, and the last one with for the ETX.     * @param outs The stream to write the message to.     * @param lengthBytes The size of the message length header. Valid ranges are 0 to 4.     * @throws IllegalArgumentException if the specified length header is more than 4 bytes.     * @throws IOException if there is a problem writing to the stream. */    public void write(OutputStream outs, int lengthBytes) throws IOException {    	if (lengthBytes > 4) {    		throw new IllegalArgumentException("The length header can have at most 4 bytes");    	}    	byte[] data = writeInternal();    	if (lengthBytes > 0) {    		int l = data.length;    		if (etx > -1) {    			l++;    		}    		byte[] buf = new byte[lengthBytes];    		int pos = 0;    		if (lengthBytes == 4) {    			buf[0] = (byte)((l & 0xff000000) >> 24);    			pos++;    		}    		if (lengthBytes > 2) {    			buf[pos] = (byte)((l & 0xff0000) >> 16);    			pos++;    		}    		if (lengthBytes > 1) {    			buf[pos] = (byte)((l & 0xff00) >> 8);    			pos++;    		}    		buf[pos] = (byte)(l & 0xff);    		outs.write(buf);    	}    	outs.write(data);    	//ETX    	if (etx > -1) {    		outs.write(etx);    	}    	outs.flush();    }    /** Creates and returns a ByteBuffer with the data of the message, including the length header.     * The returned buffer is already flipped, so it is ready to be written to a Channel. */    public ByteBuffer writeToBuffer(int lengthBytes) {    	if (lengthBytes > 4) {    		throw new IllegalArgumentException("The length header can have at most 4 bytes");    	}    	byte[] data = writeInternal();    	ByteBuffer buf = ByteBuffer.allocate(lengthBytes + data.length + (etx > -1 ? 1 : 0));    	if (lengthBytes > 0) {    		int l = data.length;    		if (etx > -1) {    			l++;    		}    		byte[] bbuf = new byte[lengthBytes];    		int pos = 0;    		if (lengthBytes == 4) {    			bbuf[0] = (byte)((l & 0xff000000) >> 24);    			pos++;    		}    		if (lengthBytes > 2) {    			bbuf[pos] = (byte)((l & 0xff0000) >> 16);    			pos++;    		}    		if (lengthBytes > 1) {    			bbuf[pos] = (byte)((l & 0xff00) >> 8);    			pos++;    		}    		bbuf[pos] = (byte)(l & 0xff);    		buf.put(bbuf);    	}    	buf.put(data);    	//ETX    	if (etx > -1) {    		buf.put((byte)etx);    	}    	buf.flip();    	return buf;    }    /** Writes the message to a memory buffer and returns it. The message does not include     * the ETX character or the header length. */    protected byte[] writeInternal() {    	ByteArrayOutputStream bout = new ByteArrayOutputStream();    	if (isoHeader != null) {    		try {    			bout.write(isoHeader.getBytes());    		} catch (IOException ex) {    			//should never happen, writing to a ByteArrayOutputStream    		}    	}    	//Message Type    	if (binary) {        	bout.write((type & 0xff00) >> 8);        	bout.write(type & 0xff);    	} else {    		String x = Integer.toHexString(type);    		if (x.length() < 4) {    			bout.write(48);    		}    		try {    			bout.write(x.getBytes());    		} catch (IOException ex) {    			//should never happen, writing to a ByteArrayOutputStream    		}    	}    	//Bitmap    	ArrayList keys = new ArrayList();    	keys.addAll(fields.keySet());    	Collections.sort(keys);    	BitSet bs = new BitSet(64);    	for (Iterator iter = keys.iterator(); iter.hasNext();) {    		bs.set(((Integer)iter.next()).intValue() - 1);    	}    	//Extend to 128 if needed    	if (bs.length() > 64) {    		BitSet b2 = new BitSet(128);    		b2.or(bs);    		bs = b2;    		bs.set(0);    	}    	//Write bitmap to stream    	if (binary) {    		int pos = 128;    		int b = 0;    		for (int i = 0; i < bs.size(); i++) {    			if (bs.get(i)) {    				b |= pos;    			}    			pos >>= 1;    			if (pos == 0) {    				bout.write(b);    				pos = 128;    				b = 0;    			}    		}    	} else {            int pos = 0;            int lim = bs.size() / 4;            for (int i = 0; i < lim; i++) {                int nibble = 0;                if (bs.get(pos++))                    nibble += 8;                if (bs.get(pos++))                    nibble += 4;                if (bs.get(pos++))                    nibble += 2;                if (bs.get(pos++))                    nibble++;                bout.write(HEX[nibble]);            }    	}    	//Fields    	for (Iterator iter = keys.iterator(); iter.hasNext();) {    		IsoValue v = (IsoValue)fields.get(iter.next());    		try {    			v.write(bout, binary);    		} catch (IOException ex) {    			//should never happen, writing to a ByteArrayOutputStream    		}    	}    	return bout.toByteArray();    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
秋霞电影一区二区| 日本麻豆一区二区三区视频| 欧美成人精品二区三区99精品| 91福利社在线观看| 欧美在线免费播放| 欧美性色黄大片| 欧美日韩电影在线| 91精品国产综合久久精品| 9191成人精品久久| 精品国产乱码久久久久久久| 欧美tickling网站挠脚心| 精品伦理精品一区| 国产丝袜在线精品| 亚洲天堂成人网| 一区二区成人在线观看| 国产精品一区在线| 91碰在线视频| 欧美日韩国产免费| 亚洲精品在线三区| 日韩一区日韩二区| 亚洲成人中文在线| 精品一区二区三区免费观看| 顶级嫩模精品视频在线看| 一本色道久久综合亚洲精品按摩 | 麻豆久久久久久久| 国产·精品毛片| 在线观看av一区二区| 日韩三级免费观看| 欧美国产亚洲另类动漫| 亚洲一区二区三区四区在线免费观看 | 日韩一区二区三免费高清| 欧美精品一区男女天堂| 亚洲精品国产一区二区精华液| 日韩精品亚洲一区| av不卡在线播放| 欧美精品18+| 国产精品美女久久久久久久久久久 | 成人高清在线视频| 欧美三级三级三级爽爽爽| 26uuuu精品一区二区| 亚洲一二三四区| 国产精品一区专区| 欧美一区二视频| 亚洲精品国产a久久久久久| 狠狠久久亚洲欧美| 欧美日产在线观看| 亚洲乱码国产乱码精品精98午夜 | 一级日本不卡的影视| 国产乱子伦视频一区二区三区 | 亚洲综合丁香婷婷六月香| 国产一区二区三区免费播放| 欧美日韩国产一级| 亚洲视频一区二区在线观看| 国产乱码精品一区二区三区av| 在线精品国精品国产尤物884a| 久久综合久久综合久久| 亚洲777理论| 欧美羞羞免费网站| 亚洲精品一卡二卡| www.99精品| 国产精品午夜电影| 国产一区二区三区综合| 日韩欧美在线影院| 亚洲国产成人av网| 色综合久久久久| 五月天丁香久久| 精品视频色一区| 亚洲最色的网站| 91久久精品国产91性色tv| 最新欧美精品一区二区三区| jlzzjlzz亚洲女人18| 中文字幕乱码一区二区免费| 顶级嫩模精品视频在线看| 国产日韩v精品一区二区| 国产一区二区三区视频在线播放| 国产亚洲精品久| 成人午夜短视频| 亚洲免费电影在线| 欧美自拍偷拍一区| 日韩综合小视频| 91精品国产综合久久久蜜臀粉嫩| 青青国产91久久久久久| 精品国产自在久精品国产| 国产自产高清不卡| 国产精品污网站| 色8久久精品久久久久久蜜| 亚洲一卡二卡三卡四卡无卡久久| 欧美在线观看禁18| 免费人成在线不卡| 久久精品一区二区三区不卡牛牛| 国产成都精品91一区二区三| 欧美激情一区二区三区蜜桃视频| 成人高清视频免费观看| 亚洲在线免费播放| 日韩视频在线你懂得| 成人美女视频在线观看18| 国产精品乱码一区二区三区软件| 91福利国产成人精品照片| 天堂在线亚洲视频| 久久久另类综合| aaa国产一区| 美女视频一区在线观看| 国产欧美精品国产国产专区| 97国产一区二区| 热久久国产精品| 国产精品你懂的| 欧美探花视频资源| 国产传媒欧美日韩成人| 亚洲自拍偷拍网站| 久久亚洲精品小早川怜子| 在线中文字幕一区二区| 狠狠色丁香婷婷综合| 亚洲小说春色综合另类电影| 国产免费久久精品| 欧美日韩国产一区| 97精品国产97久久久久久久久久久久 | 一区二区三区欧美| 国产视频视频一区| 欧美三级电影在线看| 成人动漫av在线| 久久99精品国产.久久久久久| 中文字幕一区二区三区在线观看| 欧美精品欧美精品系列| 成人高清视频免费观看| 精品综合免费视频观看| 亚洲一二三四区不卡| 欧美高清一级片在线观看| 欧美一区二区大片| 欧美视频一区二区三区四区| 成人免费av资源| 精彩视频一区二区| 奇米精品一区二区三区在线观看一| 亚洲三级在线看| 日本视频免费一区| 亚洲免费电影在线| 国产精品视频九色porn| 精品少妇一区二区三区视频免付费| 欧美性大战久久久久久久蜜臀| 成人高清av在线| 粉嫩av一区二区三区粉嫩| 国产美女久久久久| 国产一区二区电影| 久草在线在线精品观看| 热久久免费视频| 麻豆精品视频在线观看| 美女mm1313爽爽久久久蜜臀| 看片的网站亚洲| 日韩va亚洲va欧美va久久| 视频在线观看91| 天天做天天摸天天爽国产一区| 亚洲欧美电影一区二区| 亚洲欧美日韩中文播放| 亚洲人精品午夜| 一区二区三区四区蜜桃| 亚洲五码中文字幕| 亚洲成人av福利| 日韩精品一二区| 精品一区二区三区不卡| 国产制服丝袜一区| 成人综合婷婷国产精品久久| 粉嫩久久99精品久久久久久夜 | 91国偷自产一区二区开放时间| 国产成人精品免费在线| 成人激情小说网站| 97精品久久久久中文字幕| 在线观看av不卡| 91精品福利在线一区二区三区 | 亚洲成人免费在线观看| 午夜精品一区二区三区免费视频| 亚洲bt欧美bt精品777| 免费观看成人鲁鲁鲁鲁鲁视频| 久久爱另类一区二区小说| 国产98色在线|日韩| 色欧美片视频在线观看在线视频| 欧美曰成人黄网| 精品国产91久久久久久久妲己| 国产亚洲精品aa| 亚洲专区一二三| 国产一区二区在线影院| voyeur盗摄精品| 欧美一区二区成人| 国产精品传媒视频| 天堂资源在线中文精品| 国产激情91久久精品导航| 色婷婷国产精品| 日韩你懂的电影在线观看| 国产精品美女久久久久久久网站| 午夜免费久久看| 波多野结衣亚洲| 日韩视频一区二区三区| 亚洲色欲色欲www在线观看| 婷婷六月综合亚洲| 成人成人成人在线视频| 91精品国产综合久久久久| 国产精品日韩成人| 精品制服美女丁香| 欧美中文字幕一区| 欧美激情一区三区| 久久国产精品一区二区| 在线精品视频免费播放|