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

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

?? tokenmap.java

?? 具有不同語法高亮的編輯器實例
?? JAVA
字號:
/*
 * 08/26/2004
 *
 * TokenMap.java - Similar to a Map in Java, only designed specifically for
 *                 org.fife.ui.rsyntaxtextarea.Tokens.
 * Copyright (C) 2004 Robert Futrell
 * email@address.com
 * www.website.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package org.fife.ui.rsyntaxtextarea;

import javax.swing.text.Segment;


/**
 * A hash table for reserved words, etc. defined by a
 * <code>org.fife.ui.rsyntaxtextarea.TokenMaker</code>.  This class is designed
 * for the quick lookup of tokens, as it can compare <code>Segment</code>s
 * without the need to allocate a new string.<p>
 * The <code>org.fife.ui.rsyntaxtextarea</code> package uses this class to help
 * identify reserved words in programming languages.  An instance of
 * <code>{@link org.fife.ui.rsyntaxtextarea.TokenMaker}</code> will create and
 * initialize an instance of this class containing all reserved words, data
 * types, and all other words that need to be syntax-highlighted for that
 * particular language.  When the token maker parses a line and identifies an
 * individual token, it is looked up in the <code>TokenMap</code> to see if it
 * should be syntax-highlighted.
 *
 * @author Robert Futrell
 * @version 0.6
 */
public class TokenMap {

	private int size;
	private TokenMapToken[] tokenMap;
	private boolean ignoreCase;

	private static final int DEFAULT_TOKEN_MAP_SIZE = 52;


/*****************************************************************************/


	/**
	 * Constructs a new token map that is case-sensitive.
	 */
	public TokenMap() {
		this(DEFAULT_TOKEN_MAP_SIZE);
	}


/*****************************************************************************/


	/**
	 * Constructs a new token map that is case-sensitive.
	 *
	 * @param size The size of the token map.
	 */
	public TokenMap(int size) {
		this(size, false);
	}


/*****************************************************************************/


	/**
	 * Constructs a new token map.
	 *
	 * @param ignoreCase Whether or not this token map should ignore case
	 *                   when comparing tokens.
	 */
	public TokenMap(boolean ignoreCase) {
		this(DEFAULT_TOKEN_MAP_SIZE, ignoreCase);
	}


/*****************************************************************************/


	/**
	 * Constructs a new token map.
	 *
	 * @param size The size of the token map.
	 * @param ignoreCase Whether or not this token map should ignore case
	 *                   when comparing tokens.
	 */
	public TokenMap(int size, boolean ignoreCase) {
		this.size = size;
		tokenMap = new TokenMapToken[size];
		this.ignoreCase = ignoreCase;
	}


/*****************************************************************************/


	/**
	 * Adds a token to a specified bucket in the token map.
	 *
	 * @param bucket The bucket in which to add the token.
	 * @param token The token to add.
	 */
	private void addTokenToBucket(int bucket, TokenMapToken token) {
		TokenMapToken old = tokenMap[bucket];
		token.nextToken = old;
		tokenMap[bucket] = token;
	}


/*****************************************************************************/


	/**
	 * Returns the token type associated with the given text, if the given
	 * text is in this token map.  If it isn't, <code>-1</code> is returned.
	 *
	 * @param text The segment from which to get the text to compare.
	 * @param start The starting index in the segment of the text.
	 * @param end The ending index in the segment of the text.
	 * @return The token type associated with the given text, or
	 *         <code>-1</code> if this token was not specified in this map.
	 */
	public int get(Segment text, int start, int end) {
		return get(text.array, start, end);
	}


/*****************************************************************************/


	/**
	 * Returns the token type associated with the given text, if the given
	 * text is in this token map.  If it isn't, <code>-1</code> is returned.
	 *
	 * @param array1 An array of characters containing the text.
	 * @param start The starting index in the array of the text.
	 * @param end The ending index in the array of the text.
	 * @return The token type associated with the given text, or
	 *         <code>-1</code> if this token was not specified in this map.
	 */
	public int get(char[] array1, int start, int end) {

		int length1 = end - start + 1;

		int hash = getHashCode(array1, start, length1);
		TokenMapToken token = tokenMap[hash];

		char[] array2;
		int offset2;
		int offset1;
		int length;

		/* We check whether or not to ignore case before doing any looping to
		 * minimize the number of extraneous comparisons we do.  This makes
		 * for slightly redundant code, but it'll be a little more efficient.
		 */

		// If matches are case-sensitive (C, C++, Java, etc.)...
		if (ignoreCase==false) {

		mainLoop:
			while (token!=null) {
				if (token.length==length1) {
					array2  = token.text;
					offset2 = token.offset;
					offset1 = start;
					length  = length1;
					while (length-- > 0) {
						if (array1[offset1++]!=array2[offset2++]) {
							token = token.nextToken;
							continue mainLoop;
						}
					}
					return token.tokenType;
				}
				token = token.nextToken;
			}

		}

		// If matches are NOT case-sensitive (HTML)...
		// Note that all tokens saved in this map were converted to
		// lower-case already.
		else {

		mainLoop2:
			while (token!=null) {
				if (token.length==length1) {
					array2  = token.text;
					offset2 = token.offset;
					offset1 = start;
					length  = length1;
					while (length-- > 0) {
						if (RSyntaxUtilities.toLowerCase(
							array1[offset1++]) != array2[offset2++]) {
							token = token.nextToken;
							continue mainLoop2;
						}
					}
					return token.tokenType;
				}
				token = token.nextToken;
			}

		}

		// Didn't match any of the tokens in the bucket.
		return -1;

	}


/*****************************************************************************/


	/**
	 * Returns the hash code for a given string.
	 *
	 * @param text The text to hash.
	 * @param offset The offset into the text at which to start hashing.
	 * @param length The last character in the text to hash.
	 * @return The hash code.
	 */
	private final int getHashCode(char[] text, int offset, int length) {
		return (RSyntaxUtilities.toLowerCase(text[offset]) +
				RSyntaxUtilities.toLowerCase(text[offset+length-1])) % size;
	}


/*****************************************************************************/


	/**
	 * Returns whether this token map ignores case when checking for tokens.
	 * This property is set in the constructor and cannot be changed, as this
	 * is an intrinsic property of a particular programming language.
	 *
	 * @return Whether or not this token maker is ignoring case.
	 */
	protected boolean isIgnoringCase() {
		return ignoreCase;
	}


/*****************************************************************************/


	/**
	 * Adds a string to this token map.
	 *
	 * @param string The string to add.
	 * @param tokenType The type of token the string is.
	 */
	public void put(final String string, final int tokenType) {
		if (isIgnoringCase())
			put(string.toLowerCase().toCharArray(), tokenType);
		else
			put(string.toCharArray(), tokenType);
	}


/*****************************************************************************/


	/**
	 * Adds a string to this token map.  The char array passed-in will be used
	 * as the actual data for the token, so it may well be modified (such as
	 * lower-casing it if <code>ignoreCase</code> is <code>true</code>).  This
	 * shouldn't be an issue though as this method is only called from the
	 * public <code>put</code> method, which allocates a new char array.
	 *
	 * @param string The string to add.
	 * @param tokenType The type of token the string is.
	 */
	private void put(char[] string, int tokenType) {
		int hashCode = getHashCode(string, 0, string.length);
		addTokenToBucket(hashCode, new TokenMapToken(string, tokenType));
	}


/*****************************************************************************/
/*********************** PRIVATE INNER CLASSES *******************************/
/*****************************************************************************/


	/**
	 * The "token" used by a token map.  Note that this isn't the same thing
	 * as the <code>org.fife.ui.rsyntaxtextarea.Token</code> class, but it's
	 * basically a 1-1 correspondance for reserved words, etc.
	 */
	private class TokenMapToken {

		char[] text;
		int offset;
		int length;
		int tokenType;
		TokenMapToken nextToken;

		TokenMapToken(char[] text, int tokenType) {
			this.text = text;
			this.offset = 0;
			this.length = text.length;
			this.tokenType = tokenType;
		}

		public String toString() {
			return "[TokenMapToken: " + new String(text,offset,length) + "]";
		}

	}


/*****************************************************************************/

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一二三区在线观看| 久久久影院官网| 99国产麻豆精品| 国产成人一级电影| 久久精品久久99精品久久| 丝袜美腿亚洲综合| 亚洲成人第一页| 日韩国产成人精品| 精品一区二区三区日韩| 国产毛片精品一区| 日本韩国欧美三级| 91电影在线观看| 欧美图区在线视频| 日韩欧美资源站| 精品国产电影一区二区| 国产视频一区二区在线| 亚洲国产精品激情在线观看| 中文字幕一区日韩精品欧美| 亚洲欧美另类综合偷拍| 亚洲一区二三区| 美女视频一区二区| 成人免费看视频| 在线观看日韩高清av| 欧美精品777| 国产亚洲一区二区三区| 亚洲丝袜自拍清纯另类| 午夜影院久久久| 国产一区在线精品| 91免费看`日韩一区二区| 5858s免费视频成人| 久久女同精品一区二区| 亚洲人成伊人成综合网小说| 婷婷成人综合网| 成人h动漫精品| 欧美一级免费观看| 国产精品日日摸夜夜摸av| 亚洲妇熟xx妇色黄| 国产盗摄视频一区二区三区| 色婷婷综合在线| 精品国产露脸精彩对白| 一区二区三区欧美久久| 精品一区二区免费看| 日本道精品一区二区三区| 日韩欧美在线123| 亚洲欧美日本韩国| 国产乱码精品1区2区3区| 欧美日韩中文字幕一区二区| 久久久www免费人成精品| 丝袜美腿亚洲综合| 一本色道久久综合亚洲aⅴ蜜桃| 欧美va亚洲va香蕉在线| 亚洲国产日韩a在线播放| 国产成+人+日韩+欧美+亚洲| 91精品国产aⅴ一区二区| 亚洲男人的天堂在线观看| 国产精品羞羞答答xxdd| 欧美一区二区精美| 亚洲图片一区二区| 91蝌蚪porny| 国产精品夫妻自拍| 国产一区二区三区免费看| 日韩一区二区不卡| 丝袜美腿高跟呻吟高潮一区| 91婷婷韩国欧美一区二区| 欧美激情中文不卡| 国产精品亚洲人在线观看| 精品久久久久久久久久久久包黑料| 一区二区三区在线播放| 99re这里都是精品| 中文字幕一区二区三区在线观看 | 国产经典欧美精品| 欧美一卡二卡在线| 石原莉奈在线亚洲三区| 久久综合九色综合欧美就去吻| 午夜精品一区在线观看| 欧美亚洲高清一区| 亚洲自拍偷拍图区| 欧美日韩国产在线播放网站| 亚洲综合一二三区| 欧美日韩国产区一| 天涯成人国产亚洲精品一区av| 色综合久久88色综合天天| 亚洲日本在线天堂| 欧美日韩综合一区| 免费视频一区二区| 精品日本一线二线三线不卡 | 日韩欧美一区二区免费| 日韩高清一级片| 精品日韩欧美一区二区| 国产成人8x视频一区二区| 中文字幕不卡在线播放| 91麻豆免费观看| 亚洲国产精品一区二区www在线| 欧美性感一区二区三区| 玖玖九九国产精品| 中文字幕精品综合| 欧美性感一类影片在线播放| 天天做天天摸天天爽国产一区| 日韩小视频在线观看专区| 国精产品一区一区三区mba视频| 国产三级欧美三级日产三级99| av日韩在线网站| 天堂成人免费av电影一区| 精品人在线二区三区| 91麻豆.com| 精品夜夜嗨av一区二区三区| 国产精品热久久久久夜色精品三区| 91亚洲资源网| 老司机午夜精品99久久| 国产精品久久久久婷婷二区次| 欧洲在线/亚洲| 狠狠色丁香婷婷综合久久片| 亚洲视频你懂的| 亚洲精品一区二区三区四区高清| 国产不卡免费视频| 日韩制服丝袜av| 国产精品丝袜在线| 91精品国产一区二区| av一区二区三区在线| 免费成人在线观看| 亚洲黄色小说网站| 国产欧美日韩在线观看| 欧美高清一级片在线| 99精品久久只有精品| 久久精品国产精品亚洲综合| 一区二区在线观看视频| 久久久久97国产精华液好用吗| 欧美日产国产精品| 91污在线观看| 国产精品亚洲第一 | 久久精品网站免费观看| 欧美精品99久久久**| 91论坛在线播放| 成人国产精品免费网站| 国产一区二区三区电影在线观看| 亚洲影院理伦片| 国产精品高潮呻吟| 中文字幕精品三区| 久久在线免费观看| 日韩视频在线观看一区二区| 欧洲一区二区三区在线| 成人h动漫精品一区二| 国产suv精品一区二区6| 国产综合色精品一区二区三区| 一区二区三区日本| 亚洲精品成人天堂一二三| 日韩激情一二三区| 亚洲国产一区二区在线播放| 亚洲女人小视频在线观看| 国产精品视频在线看| 国产片一区二区三区| 久久久久久一级片| 久久综合视频网| 精品国产a毛片| www欧美成人18+| 久久精品亚洲国产奇米99| 久久亚洲精华国产精华液 | 国产91精品久久久久久久网曝门| 蜜乳av一区二区| 另类中文字幕网| 精品一区精品二区高清| 黑人巨大精品欧美一区| 国产一区二区三区不卡在线观看| 久久精品99国产精品日本| 国内一区二区在线| 国产成人综合在线播放| 成人免费看的视频| 91影院在线免费观看| 在线视频观看一区| 91精品欧美福利在线观看| 日韩精品中文字幕一区二区三区| 精品少妇一区二区| 亚洲国产高清在线观看视频| 自拍偷拍亚洲欧美日韩| 亚洲一区二区在线播放相泽 | 国产精品麻豆视频| 亚洲人快播电影网| 午夜欧美在线一二页| 久久精品国产秦先生| 成人午夜免费电影| 欧亚洲嫩模精品一区三区| 制服丝袜亚洲精品中文字幕| 久久久亚洲高清| 亚洲一卡二卡三卡四卡无卡久久| 日韩国产精品久久久| 国产精品亚洲午夜一区二区三区 | 欧美浪妇xxxx高跟鞋交| 欧美精品一区二区三区四区| 国产精品欧美久久久久一区二区| 亚洲最大成人综合| 国产综合色在线| 欧美优质美女网站| 国产亚洲午夜高清国产拍精品| 亚洲欧美国产毛片在线| 久久精品99国产精品| 日本电影欧美片| 国产日韩一级二级三级| 男人操女人的视频在线观看欧美| 东方aⅴ免费观看久久av| 欧美日韩国产综合久久|