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

📄 charkeyword.java

📁 支持并发访问的B+树
💻 JAVA
字号:
/* * Created on Aug 1, 2004 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */package com.nay0648.ds.bplustree;import java.io.UnsupportedEncodingException;/** * Description:<br> * &nbsp&nbsp this is used to support String keyword. * the keyword value saved in CharKeyword is fixed length. * if data need to save is large than the fixed length,it * throws a IllegalArgumentException,else if data length * small than fixed length it will fill space with ' ' to * the end of the data to let the length equal to the fixed * length.the string is ASCII mode,so one char is one byte * length. * @abstract * @keywords * @author nay0648<br> * if you have any questions,advices,suggests,or find any * bugs,please mail me: <a href="mailto:">nay0648@sina.com</a> * @version last modified:Aug 1, 2004 */class CharKeyword implements Keyword{private static final String SPACE=" ";private static final String ENCODING="ASCII";private String value;	public CharKeyword(String value,int fixedlength)	{		int i;		StringBuffer s;				if(value.length()>fixedlength)			throw new IllegalArgumentException("keyword size too large. size: "+value.length()+" required: <="+fixedlength);		s=new StringBuffer();		s.append(value);		for(i=value.length();i<fixedlength;i++) s.append(SPACE);		this.value=s.toString();	}		public CharKeyword(byte[] key,int fixedlength)	{		if(key.length!=fixedlength)			throw new IllegalArgumentException("keyword size too large. size: "+value.length()+" required: <="+fixedlength);		try		{			value=new String(key,ENCODING);		}		catch(UnsupportedEncodingException e)		{			e.printStackTrace();		}	}	public String getValue()	{		return value;	}	public boolean equals(Object o)	{		CharKeyword key;			if(!(o instanceof CharKeyword)) return false;		else		{			key=(CharKeyword)o;			return value.equals(key.getValue());		}	}	public int compareTo(Object o)	{		CharKeyword key;			key=(CharKeyword)o;		return value.compareTo(key.getValue());	}		public byte[] getBytes()	{		byte[] key=null;				try		{			key=value.getBytes(ENCODING);		}		catch(UnsupportedEncodingException e)		{			e.printStackTrace();		}		return key;	}	public String toString()	{		return value;	}	}

⌨️ 快捷键说明

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