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

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

?? basictableparser.java

?? Short Message Peer to Peer
?? JAVA
字號:
/*
 * Copyright (c) 1996-2001
 * Logica Mobile Networks Limited
 * All rights reserved.
 *
 * This software is distributed under Logica Open Source License Version 1.0
 * ("Licence Agreement"). You shall use it and distribute only in accordance
 * with the terms of the License Agreement.
 *
 */
package org.smpp.smscsim.util;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import org.smpp.SmppObject;
import org.smpp.debug.Debug;

/**
 * Implements the <code>TableParser</code>. The expected format of the file
 * is as follows:<br>
 * <ul>
 *   <li>every line in the stream contains either attribute or
 *       comment or is empty</li>
 *   <li>each attribute is on one line</li>
 *   <li>attribute is in form <code>name "=" value</code><br>
 *       Example:<br><code>
 *         name=javier
 *       </code>
 *   </li>
 *   <li>Comment starts with hash <code>#</code> character in the first
 *       column of the line. If you need more lines of comment, each line
 *       of the comment must start with hash.</li>
 *   <li>record consists from several consecutive attributes; no emplty line
 *       or comment is allowed within one record</li>
 *   <li>records are delimited by one or more empty line or comments<br>
 *       Example:<br><pre>
 *# This is a comment
 *# The following line is an empty line
 *
 *# The first record follows
 *name=Charles
 *password=slercha
 *access=guest
 *
 *# And the second record...
 *name=thomas
 *password=TheOmas
 *# Note that comment doesn't (!) delimit records
 *# so you can comment on single attributes within the record
 *type=admin
 *access=full
 *
 *# And this is the third record.
 *name=peter
 *password=agent007
 *#Ok, this should be enough for demonstration.
 *
 *</pre></li>
 * </ul>
 * Note that if you read the file and then write it, the comments aren't
 * preserved.
 *
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.2 $
 */
public class BasicTableParser implements TableParser {
	/*
	  End of line chars definitions
	*/
	static final char CR = '\r';
	static final char LF = '\n';
	static final String LINE_END = "\r\n";

	/**
	 * The characters which can be used as delimiters between name of
	 * the attribute and it's value.
	 */
	static final String ATTR_DELIMS = "=:";

	static final String COMMENT_CHARS = "#;";

	Table table;
	InputStreamReader in;
	OutputStreamWriter out;
	char c, pending;
	boolean pendingChar = false;
	String line = "";
	Record record;
	boolean pendingRecord = false;

	private Debug debug = SmppObject.getDebug();

	/**
	 * This constructor passes to the parser a table to work on.
	 */
	public BasicTableParser(Table table) {
		this.table = table;
	}

	/**
	 * Parses the input stream and fills the table with data from the stream.
	 * @param is the input stream to read the data from
	 * @see #compose(OutputStream)
	 */
	public void parse(InputStream is) throws IOException {
		debug.write("going to parse from input stream");
		in = new InputStreamReader(is);
		prepareRecord();
		while (!eof()) {
			getLine();
			if (isEmpty()) {
				debug.write("got empty line");
				finaliseRecord(true);
			} else if (!isComment()) {
				parseAttribute(line);
			} else {
				debug.write("got comment line " + line);
			}
		}
		finaliseRecord(false);
	}

	/**
	 * Writes to the output stream formatted content of the table.
	 * @param os the output stream to write to
	 * @see #parse(InputStream)
	 */
	public void compose(OutputStream os) throws IOException {
		out = new OutputStreamWriter(os);
		Record record;
		Attribute attribute;
		int recCount;
		int attrCount;
		synchronized (table) {
			recCount = table.count();
			for (int ri = 0; ri < recCount; ri++) {
				record = table.get(ri);
				synchronized (record) {
					attrCount = record.count();
					for (int ai = 0; ai < attrCount; ai++) {
						attribute = record.get(ai);
						synchronized (attribute) {
							line = attribute.getName() + "=" + attribute.getValue();
						}
						out.write(line);
						out.write(LINE_END);
					}
				}
				if ((ri + 1) < recCount) {
					// if this wasn't last record, write empty line
					// as delimiter between users
					out.write(LINE_END);
				}
			}
		}
		out.flush();
	}

	/**
	 * Called whenever end of record was reached. If there is a record
	 * which hasn't been inserted to the table yet, it's inserted by this
	 * method.
	 */
	void finaliseRecord(boolean prepareNext) {
		if (pendingRecord) {
			debug.write("finished record, adding to table");
			table.add(record);
			pendingRecord = false;
			if (prepareNext) {
				prepareRecord();
			}
		}
	}

	/**
	 * Creates new record to add the newly read attributes to.
	 */
	void prepareRecord() {
		record = new Record();
	}

	/**
	 * Parses attribute and inserts it into the record.
	 */
	void parseAttribute(String attr) {
		int attrLen = attr.length();
		int currPos = 0;
		debug.write("going to parse attribute " + attr);
		while ((currPos < attrLen) && (ATTR_DELIMS.indexOf(attr.charAt(currPos)) == -1)) {
			currPos++;
		}
		String name = attr.substring(0, currPos);
		String value = attr.substring(currPos + 1, attrLen);
		record.set(name, value);
		pendingRecord = true;
	}

	/**
	 * Returns if end of the stream was already reached.
	 */
	boolean eof() throws IOException {
		return !in.ready();
	}

	/**
	 * Returns if on the current position in the stream there is end of line
	 * character.
	 */
	boolean eol() {
		return (c == CR) || (c == LF);
	}

	/**
	 * Returns if the current line is empty, i.e. doesn't contain any character
	 * including whitespace.
	 */
	boolean isEmpty() {
		return line.length() == 0;
	}

	/**
	 * Returns if the current line contains a comment text.
	 */
	boolean isComment() {
		return isEmpty() ? false : COMMENT_CHARS.indexOf(line.charAt(0)) != -1;
	}

	/**
	 * Reads one line from the input stream and stores it into <code>line</code>
	 * variable.
	 * @see #get()
	 * @see #unget()
	 */
	void getLine() throws IOException {
		line = "";
		get();
		do {
			if (!eol()) {
				line += c;
			}
			get();
		} while (!eof() && !eol());
		if (!eof()) {
			// then it must have been eol => we are trying
			// to skip another potential line delim
			if (c == CR) {
				// then we could have CRLF
				get();
				if (c != LF) {
					// no CRLF
					unget();
				}
			} else {
				// nothing as LF is ok
			}
		}
	}

	/**
	 * Reads one character from input stream or gets a pending character
	 * read before.
	 * @see #getLine()
	 * @see #unget()
	 */
	void get() throws IOException {
		if (pendingChar) {
			c = pending;
			pendingChar = false;
		} else {
			c = (char) in.read();
		}
	}

	/**
	 * If necessary, one and only one character can be 'unget' by this method.
	 * This character becomes pending character and will be get by next call to
	 * method <code>get</code>.
	 * @see #get()
	 * @see #getLine()
	 */
	void unget() {
		pending = c;
		pendingChar = true;
	}

}
/*
 * $Log: BasicTableParser.java,v $
 * Revision 1.2  2006/03/09 16:24:15  sverkera
 * Removed compiler and javadoc warnings
 *
 * Revision 1.1  2003/07/23 00:28:39  sverkera
 * Imported
 *
 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
www.色综合.com| 亚洲va韩国va欧美va精品| 国产一区二区三区免费| 日韩欧美一级精品久久| 久久99精品国产麻豆婷婷洗澡| 日韩精品最新网址| 国产精品亚洲成人| 国产精品无人区| 一本大道av伊人久久综合| 亚洲一区二区三区在线播放| 欧美午夜影院一区| 久久99精品国产| 综合婷婷亚洲小说| 91精品国产91热久久久做人人| 久久99精品久久只有精品| 国产精品青草综合久久久久99| 欧美曰成人黄网| 精品一区二区三区蜜桃| 国产精品久久久久久妇女6080| 欧美亚洲愉拍一区二区| 国产综合久久久久影院| 最新不卡av在线| 日韩欧美一级二级| 成人激情开心网| 亚洲第四色夜色| 久久精品视频在线看| 91免费版在线看| 男女性色大片免费观看一区二区 | 日韩理论片网站| 欧美日韩激情一区二区三区| 精品在线一区二区三区| 亚洲精品日产精品乱码不卡| 日韩一级片在线播放| 99精品久久久久久| 国产主播一区二区| 亚洲成人动漫一区| 国产精品卡一卡二| 欧美成人精品二区三区99精品| 成年人国产精品| 蜜臀久久99精品久久久久久9 | 久久综合久久综合久久| 一本一道波多野结衣一区二区| 激情综合五月天| 洋洋成人永久网站入口| 国产欧美日韩不卡| 欧美一区二区二区| 色哟哟精品一区| 国产精品亚洲一区二区三区妖精| 午夜精品久久久久久久久| 亚洲天堂久久久久久久| 26uuu亚洲| 4hu四虎永久在线影院成人| 91在线一区二区| 国产成人自拍在线| 国产在线精品一区二区三区不卡| 亚洲bt欧美bt精品777| 亚洲色欲色欲www| 久久九九99视频| 精品91自产拍在线观看一区| 欧美日韩国产另类一区| 色偷偷成人一区二区三区91 | 紧缚奴在线一区二区三区| 婷婷开心久久网| 亚洲午夜在线电影| 亚洲精品五月天| 亚洲欧美日韩国产成人精品影院| 欧美国产丝袜视频| 久久久99精品免费观看| 精品久久五月天| 精品国产青草久久久久福利| 欧美一区二区成人6969| 日韩精品一区二区三区视频播放 | 久久色.com| 久久综合久久99| 久久精品男人天堂av| 国产午夜精品久久久久久免费视 | 国产河南妇女毛片精品久久久 | 欧美精三区欧美精三区| 在线观看免费视频综合| 精品视频资源站| 欧美日韩国产一区| 91精品国产综合久久小美女| 日韩女优av电影在线观看| 日韩久久久久久| 久久欧美中文字幕| 国产精品视频免费看| 中文字幕一区日韩精品欧美| 亚洲乱码国产乱码精品精可以看| 一区二区久久久| 日韩在线卡一卡二| 国产揄拍国内精品对白| jlzzjlzz国产精品久久| 色综合激情五月| 欧美精品日韩一本| 欧美电影免费观看高清完整版在线观看 | 日韩中文字幕av电影| 麻豆极品一区二区三区| 国产毛片精品视频| 99re8在线精品视频免费播放| 欧美性色综合网| 精品久久久网站| 亚洲欧洲精品天堂一级 | 欧美一区午夜精品| 国产亚洲欧洲997久久综合| 中文字幕亚洲在| 天天色图综合网| 国产精品影视在线观看| 色哟哟欧美精品| 精品精品国产高清a毛片牛牛| 欧美国产日韩在线观看| 丝袜国产日韩另类美女| 国产a久久麻豆| 欧美精品久久99久久在免费线| 2017欧美狠狠色| 一区二区三区在线观看欧美| 蜜臀av一区二区在线免费观看| 成人高清免费观看| 4438x亚洲最大成人网| 中文无字幕一区二区三区 | 国产麻豆精品久久一二三| 91原创在线视频| 欧美一级片在线观看| 国产精品久久久久久久久图文区 | 亚洲欧洲精品一区二区三区| 日韩不卡一二三区| 99r国产精品| 亚洲精品一区二区三区影院| 一区二区三区免费观看| 国产成+人+日韩+欧美+亚洲| 在线不卡欧美精品一区二区三区| 日本一二三不卡| 久久激情五月婷婷| 欧美挠脚心视频网站| 国产精品初高中害羞小美女文| 乱一区二区av| 欧美撒尿777hd撒尿| 亚洲欧洲日韩综合一区二区| 久久草av在线| 欧美一区二区在线视频| 亚洲高清免费观看| 91捆绑美女网站| 欧美激情一区三区| 精品在线亚洲视频| 91精品国产色综合久久| 亚洲一区免费在线观看| 成人不卡免费av| 国产色婷婷亚洲99精品小说| 麻豆成人91精品二区三区| 91精品国产综合久久福利| 亚洲午夜日本在线观看| 色诱视频网站一区| 日韩理论片在线| 99久久精品一区| √…a在线天堂一区| 成人毛片在线观看| 日本一区二区成人在线| 成人黄色小视频在线观看| 国产丝袜欧美中文另类| 国产精品自拍av| 久久精品男人的天堂| 国产精品一区三区| 久久久久99精品一区| 韩日欧美一区二区三区| 欧美成人福利视频| 国产一区二区在线电影| 精品国产乱码久久久久久夜甘婷婷| 美女一区二区三区| 日韩欧美色综合| 国产一区二区h| 欧美国产禁国产网站cc| 成人av在线播放网址| 自拍偷拍国产精品| 色呦呦日韩精品| 午夜精品福利在线| 欧美一卡在线观看| 国产精品综合一区二区| 国产精品伦理在线| 日本久久一区二区三区| 亚洲午夜在线电影| 日韩亚洲国产中文字幕欧美| 精品一区二区久久| 亚洲国产精品成人综合 | 欧美国产禁国产网站cc| 99精品视频一区二区三区| 亚洲女同一区二区| 欧美喷潮久久久xxxxx| 国内精品国产成人国产三级粉色| 国产日韩三级在线| 色偷偷88欧美精品久久久| 香蕉久久夜色精品国产使用方法 | 99视频有精品| 亚洲大片一区二区三区| 欧美刺激午夜性久久久久久久| 国产精品资源在线观看| 亚洲图片另类小说| 91麻豆精品国产91久久久使用方法| 国产一区二区三区久久久| 1000精品久久久久久久久| 欧美一区二区三区在| 成人黄色网址在线观看|