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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? messagefactory.java

?? iso8583協(xié)議的java實(shí)現(xiàn)
?? JAVA
字號(hào):
/*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.text.ParseException;import java.util.ArrayList;import java.util.BitSet;import java.util.Collections;import java.util.Date;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.solab.iso8583.parse.FieldParseInfo;/** This class is used to create messages, either from scratch or from an existing String or byte * buffer. It can be configured to put default values on newly created messages, and also to know * what to expect when reading messages from an InputStream. * <P> * The factory can be configured to know what values to set for newly created messages, both from * a template (useful for fields that must be set with the same value for EVERY message created) * and individually (for trace [field 11] and message date [field 7]). * <P> * It can also be configured to know what fields to expect in incoming messages (all possible values * must be stated, indicating the date type for each). This way the messages can be parsed from * a byte buffer. *  * @author Enrique Zamudio */public class MessageFactory {	protected static final Log log = LogFactory.getLog(MessageFactory.class);	/** This map stores the message template for each message type. Keys are integers, values are IsoMessages. */	private Map typeTemplates = new HashMap();	/** Stores the information needed to parse messages sorted by type.	 * Keys are Integers, values are Maps of Integers and FieldParseInfos. */	private Map parseMap = new HashMap();	/** Stores the field numbers to be parsed, in order of appearance.	 * Keys are Integers, values are Lists of Integers. */	private Map parseOrder = new HashMap();	private TraceNumberGenerator traceGen;	/** The ISO header to be included in each message type.	 * Keys are Integers, values are Strings. */	private Map isoHeaders = new HashMap();	/** Indicates if the current date should be set on new messages (field 7). */	private boolean setDate;	/** Indicates if the factory should create binary messages and also parse binary messages. */	private boolean useBinary;	private int etx = -1;	/** Tells the receiver to create and parse binary messages if the flag is true.	 * Default is false, that is, create and parse ASCII messages. */	public void setUseBinaryMessages(boolean flag) {		useBinary = flag;	}	/** Returns true is the factory is set to create and parse binary messages,	 * false if it uses ASCII messages. Default is false. */	public boolean getUseBinaryMessages() {		return useBinary;	}	/** Sets the ETX character to be sent at the end of the message. This is optional and the	 * default is -1, which means nothing should be sent as terminator.	 * @param value The ASCII value of the ETX character or -1 to indicate no terminator should be used. */	public void setEtx(int value) {		etx = value;	}	/** Creates a new message of the specified type, with optional trace and date values as well	 * as any other values specified in a message template. If the factory is set to use binary	 * messages, then the returned message will be written using binary coding.	 * @param type The message type, for example 0x200, 0x400, etc. */	public IsoMessage newMessage(int type) {		Integer itype = new Integer(type);		IsoMessage m = new IsoMessage((String)isoHeaders.get(itype));		m.setType(type);		m.setEtx(etx);		m.setBinary(useBinary);		//Copy the values from the template		IsoMessage templ = (IsoMessage)typeTemplates.get(itype);		if (templ != null) {			for (int i = 2; i < 128; i++) {				if (templ.hasField(i)) {					m.setField(i, (IsoValue)templ.getField(i).clone());				}			}		}		if (traceGen != null) {			m.setValue(11, new Integer(traceGen.nextTrace()), IsoType.NUMERIC, 6);		}		if (setDate) {			m.setValue(7, new Date(), IsoType.DATE10, 10);		}		return m;	}	/** Creates a message to respond to a request. Increments the message type by 16,	 * sets all fields from the template if there is one, and copies all values from the request,	 * overwriting fields from the template if they overlap.	 * @param request An ISO8583 message with a request type (ending in 00). */	public IsoMessage createResponse(IsoMessage request) {		Integer rtype = new Integer(request.getType() + 16);		IsoMessage resp = new IsoMessage((String)isoHeaders.get(rtype));		resp.setBinary(request.isBinary());		resp.setType(request.getType() + 16);		resp.setEtx(etx);		//Copy the values from the template		IsoMessage templ = (IsoMessage)typeTemplates.get(rtype);		if (templ != null) {			for (int i = 2; i < 128; i++) {				if (templ.hasField(i)) {					resp.setField(i, (IsoValue)templ.getField(i).clone());				}			}		}		for (int i = 2; i < 128; i++) {			if (request.hasField(i)) {				resp.setField(i, (IsoValue)request.getField(i).clone());			}		}		return resp;	}	/** Creates a new message instance from the buffer, which must contain a valid ISO8583	 * message. If the factory is set to use binary messages then it will try to parse	 * a binary message.	 * @param buf The byte buffer containing the message. Must not include the length header.	 * @param isoHeaderLength The expected length of the ISO header, after which the message type	 * and the rest of the message must come. */	public IsoMessage parseMessage(byte[] buf, int isoHeaderLength) throws ParseException {		IsoMessage m = new IsoMessage(isoHeaderLength > 0 ? new String(buf, 0, isoHeaderLength) : null);		//TODO it only parses ASCII messages for now		int type = 0;		if (useBinary) {			type = ((buf[isoHeaderLength] & 0xff) << 8) | (buf[isoHeaderLength + 1] & 0xff);		} else {			type = ((buf[isoHeaderLength] - 48) << 12)			| ((buf[isoHeaderLength + 1] - 48) << 8)			| ((buf[isoHeaderLength + 2] - 48) << 4)			| (buf[isoHeaderLength + 3] - 48);		}		m.setType(type);		//Parse the bitmap (primary first)		BitSet bs = new BitSet(64);		int pos = 0;		if (useBinary) {			for (int i = isoHeaderLength + 2; i < isoHeaderLength + 10; i++) {				int bit = 128;				for (int b = 0; b < 8; b++) {					bs.set(pos++, (buf[i] & bit) != 0);					bit >>= 1;				}			}			//Check for secondary bitmap and parse if necessary			if (bs.get(0)) {				for (int i = isoHeaderLength + 10; i < isoHeaderLength + 18; i++) {					int bit = 128;					for (int b = 0; b < 8; b++) {						bs.set(pos++, (buf[i] & bit) != 0);						bit >>= 1;					}				}				pos = 18 + isoHeaderLength;			} else {				pos = 10 + isoHeaderLength;			}		} else {			for (int i = isoHeaderLength + 4; i < isoHeaderLength + 20; i++) {				int hex = Integer.parseInt(new String(buf, i, 1), 16);				bs.set(pos++, (hex & 8) > 0);				bs.set(pos++, (hex & 4) > 0);				bs.set(pos++, (hex & 2) > 0);				bs.set(pos++, (hex & 1) > 0);			}			//Check for secondary bitmap and parse it if necessary			if (bs.get(0)) {				for (int i = isoHeaderLength + 20; i < isoHeaderLength + 36; i++) {					int hex = Integer.parseInt(new String(buf, i, 1), 16);					bs.set(pos++, (hex & 8) > 0);					bs.set(pos++, (hex & 4) > 0);					bs.set(pos++, (hex & 2) > 0);					bs.set(pos++, (hex & 1) > 0);				}				pos = 36 + isoHeaderLength;			} else {				pos = 20 + isoHeaderLength;			}		}		//Parse each field		Integer itype = new Integer(type);		Map parseGuide = (Map)parseMap.get(itype);		List index = (List)parseOrder.get(itype);		for (Iterator iter = index.iterator(); iter.hasNext();) {			Integer i = (Integer)iter.next();			FieldParseInfo fpi = (FieldParseInfo)parseGuide.get(i);			if (bs.get(i.intValue() - 1)) {				IsoValue val = useBinary ? fpi.parseBinary(buf, pos) : fpi.parse(buf, pos);				m.setField(i.intValue(), val);				if (useBinary && !(val.getType() == IsoType.ALPHA || val.getType() == IsoType.LLVAR						|| val.getType() == IsoType.LLLVAR)) {					pos += (val.getLength() / 2) + (val.getLength() % 2);				} else {					pos += val.getLength();				}				if (val.getType() == IsoType.LLVAR) {					pos += useBinary ? 1 : 2;				} else if (val.getType() == IsoType.LLLVAR) {					pos += useBinary ? 2 : 3;				}			}		}		return m;	}	/** Sets whether the factory should set the current date on newly created messages,	 * in field 7. Default is false. */	public void setAssignDate(boolean flag) {		setDate = true;	}	/** Returns true if the factory is assigning the current date to newly created messages	 * (field 7). Default is false. */	public boolean getAssignDate() {		return setDate;	}	/** Sets the generator that this factory will get new trace numbers from. There is no	 * default generator. */	public void setTraceNumberGenerator(TraceNumberGenerator value) {		traceGen = value;	}	/** Returns the generator used to assign trace numbers to new messages. */	public TraceNumberGenerator getTraceNumberGenerator() {		return traceGen;	}	/** Sets the ISO header to be used in each message type.	 * @param value A map where the keys are the message types and the values are the ISO headers.	 */	public void setIsoHeaders(Map value) {		isoHeaders.clear();		isoHeaders.putAll(value);	}	/** Sets the ISO header for a specific message type.	 * @param type The message type, for example 0x200.	 * @param value The ISO header, or NULL to remove any headers for this message type. */	public void setIsoHeader(int type, String value) {		if (value == null) {			isoHeaders.remove(new Integer(type));		} else {			isoHeaders.put(new Integer(type), value);		}	}	/** Returns the ISO header used for the specified type. */	public String getIsoHeader(int type) {		return (String)isoHeaders.get(new Integer(type));	}	/** Adds a message template to the factory. If there was a template for the same	 * message type as the new one, it is overwritten. */	public void addMessageTemplate(IsoMessage templ) {		if (templ != null) {			typeTemplates.put(new Integer(templ.getType()), templ);		}	}	/** Removes the message template for the specified type. */	public void removeMessageTemplate(int type) {		typeTemplates.remove(new Integer(type));	}	/** Sets a map with the fields that are to be expected when parsing a certain type of	 * message.	 * @param type The message type.	 * @param map A map of FieldParseInfo instances, each of which define what type and length	 * of field to expect. The keys will be the field numbers. */	public void setParseMap(Integer type, Map map) {		parseMap.put(type, map);		ArrayList index = new ArrayList();		index.addAll(map.keySet());		Collections.sort(index);		log.trace("Adding parse map for type " + Integer.toHexString(type.intValue()) + " with fields " + index);		parseOrder.put(type, index);	}}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区三区白人| 91在线国产福利| 欧美一卡在线观看| 日韩黄色在线观看| 日韩一级片在线播放| 激情欧美一区二区| 中文字幕不卡在线播放| 色婷婷国产精品综合在线观看| 亚洲六月丁香色婷婷综合久久| 91麻豆高清视频| 同产精品九九九| 欧美精品一区二区蜜臀亚洲| 成人免费视频网站在线观看| 综合久久国产九一剧情麻豆| 欧美日韩中字一区| 国精品**一区二区三区在线蜜桃| 国产三级精品在线| 欧美在线三级电影| 美国欧美日韩国产在线播放| 欧美国产成人在线| 欧美日韩中文字幕一区二区| 久久99精品久久久久久 | 在线一区二区观看| 日韩国产成人精品| 国产情人综合久久777777| 色哟哟欧美精品| 久久精品国产亚洲aⅴ | 国产精品久久久久久久久晋中 | 亚洲欧美一区二区三区久本道91 | 日韩欧美在线一区二区三区| 粉嫩蜜臀av国产精品网站| 亚洲一区二区三区中文字幕在线| 久久综合九色综合97婷婷| 91亚洲精华国产精华精华液| 久久精品国产999大香线蕉| 中文字幕亚洲在| 精品欧美久久久| 欧美日韩在线不卡| av在线不卡观看免费观看| 男女性色大片免费观看一区二区| 国产精品久久久久久户外露出| 3751色影院一区二区三区| aaa国产一区| 精品一区二区三区免费视频| 一区二区三区精品在线| 亚洲国产精品二十页| 欧美一区二区在线看| 色婷婷综合久久久中文一区二区| 国内精品写真在线观看| 日韩主播视频在线| 亚洲精品日日夜夜| 中日韩av电影| 久久视频一区二区| 欧美成人在线直播| 在线播放日韩导航| 欧美亚洲一区二区三区四区| 不卡欧美aaaaa| 粉嫩久久99精品久久久久久夜| 美女一区二区在线观看| 视频一区视频二区在线观看| 亚洲美女淫视频| 中文字幕一区二区三区乱码在线| 久久九九久久九九| 欧美精品一区二区三区蜜桃视频 | 成人精品电影在线观看| 国产毛片精品国产一区二区三区| 免费在线一区观看| 日韩高清一区二区| 视频一区视频二区中文| 亚洲国产精品天堂| 亚洲一区二区三区四区五区中文| 亚洲天堂中文字幕| 亚洲视频狠狠干| 国产精品麻豆欧美日韩ww| 日本一区二区成人| 国产精品久久久久久久久免费丝袜 | 91精品啪在线观看国产60岁| 欧美无人高清视频在线观看| 色噜噜狠狠色综合中国| 在线视频综合导航| 欧美天堂一区二区三区| 欧美日韩在线观看一区二区| 欧美性三三影院| 欧美日韩国产a| 在线成人高清不卡| 精品国产一区久久| 久久久91精品国产一区二区三区| 久久久久久免费| 亚洲国产精品成人久久综合一区| 国产精品久久免费看| 中文字幕一区二区不卡| 亚洲综合视频在线| 日本成人在线不卡视频| 精品一区二区三区欧美| 国产成a人无v码亚洲福利| av中文字幕不卡| 欧美视频中文一区二区三区在线观看| 欧美日韩中字一区| 精品国产不卡一区二区三区| 欧美激情一区二区三区| 一区二区三区四区不卡在线 | 日韩黄色免费网站| 激情综合色丁香一区二区| 国产成人自拍网| 色诱亚洲精品久久久久久| 欧美日韩综合在线免费观看| 精品日韩99亚洲| 国产精品国产三级国产aⅴ入口| 亚洲精品国产精品乱码不99| 天堂va蜜桃一区二区三区| 韩国精品免费视频| 91亚洲精品久久久蜜桃网站| 69堂精品视频| 国产精品网站在线| 五月天丁香久久| 国产精品原创巨作av| 色噜噜狠狠色综合欧洲selulu| 日韩一区二区精品葵司在线| 国产午夜精品久久久久久免费视 | 国产91在线看| 欧美美女视频在线观看| 国产无人区一区二区三区| 亚洲精品高清在线观看| 精品一区二区免费视频| 色婷婷av一区二区| 2017欧美狠狠色| 亚洲一区二区三区三| 成人自拍视频在线观看| 欧美女孩性生活视频| 欧美国产欧美综合| 免费人成精品欧美精品| 91在线视频播放| 久久夜色精品一区| 日韩福利视频导航| 色94色欧美sute亚洲线路一ni| 精品福利一二区| 天天影视色香欲综合网老头| 成人丝袜高跟foot| 久久综合狠狠综合久久综合88| 亚洲午夜久久久久久久久久久 | 日韩一级片网站| 亚洲成人免费av| 一本久久精品一区二区| 久久久国产综合精品女国产盗摄| 三级影片在线观看欧美日韩一区二区 | 成人免费精品视频| 精品国产第一区二区三区观看体验| 亚洲国产婷婷综合在线精品| 99re66热这里只有精品3直播| 久久一区二区视频| 捆绑调教一区二区三区| 欧美区视频在线观看| 一区二区三区日韩| 色婷婷亚洲一区二区三区| 欧美韩国一区二区| 国产99久久精品| 国产日韩欧美高清| 国产精品一区二区免费不卡| 欧美不卡视频一区| 久久精工是国产品牌吗| 制服丝袜中文字幕亚洲| 婷婷综合另类小说色区| 欧美精品日韩综合在线| 午夜精品久久久久影视| 欧美日韩国产精选| 亚洲成人www| 欧美一区二区三区影视| 偷拍亚洲欧洲综合| 日韩一区二区三区四区五区六区| 日韩精品一卡二卡三卡四卡无卡| 欧美日韩国产大片| 日韩中文字幕亚洲一区二区va在线| 欧美日韩第一区日日骚| 天天做天天摸天天爽国产一区 | 亚洲欧美在线另类| av中文字幕亚洲| 一区二区三区在线观看视频| 日本韩国精品一区二区在线观看| 一区二区三区成人在线视频| 欧美三级视频在线观看| 日韩精品国产欧美| 欧美mv和日韩mv的网站| 国产成人精品免费看| √…a在线天堂一区| 欧美亚洲一区二区在线观看| 亚洲第一会所有码转帖| 69p69国产精品| 国产在线日韩欧美| 国产精品夫妻自拍| 欧美久久一二三四区| 精品一区二区三区在线观看国产 | 日本欧美一区二区三区| 26uuu国产电影一区二区| 丁香婷婷综合激情五月色| 有坂深雪av一区二区精品| 欧美乱妇20p| 国产成a人亚洲精品| 亚洲国产视频一区| 久久久久高清精品| 在线观看网站黄不卡|