📄 name.java
字号:
*/ public static Name concat(Table table, Name ns[]) { int len = 0; for (int i = 0; i < ns.length; i++) len = len + ns[i].len; byte[] bs = new byte[len]; len = 0; for (int i = 0; i < ns.length; i++) { ns[i].getBytes(bs, len); len = len + ns[i].len; } return fromUtf(table, bs, 0, len); } public char charAt(int index) { return toString().charAt(index); } public CharSequence subSequence(int start, int end) { return toString().subSequence(start, end); } public boolean contentEquals(CharSequence cs) { return this.toString().equals(cs.toString()); } public static class Table { // maintain a freelist of recently used name tables for reuse. private static List<SoftReference<Table>> freelist = List.nil(); static private synchronized Table make() { while (freelist.nonEmpty()) { Table t = freelist.head.get(); freelist = freelist.tail; if (t != null) return t; } return new Table(); } static private synchronized void dispose(Table t) { freelist = freelist.prepend(new SoftReference<Table>(t)); } public void dispose() { dispose(this); } public static final Context.Key<Table> namesKey = new Context.Key<Table>(); public static Table instance(Context context) { Table instance = context.get(namesKey); if (instance == null) { instance = make(); context.put(namesKey, instance); } return instance; } /** The hash table for names. */ private Name[] hashes; /** The array holding all encountered names. */ public byte[] names; /** The mask to be used for hashing */ private int hashMask; /** The number of filled bytes in `names'. */ private int nc = 0; /** Allocator * @param hashSize the (constant) size to be used for the hash table * needs to be a power of two. * @param nameSize the initial size of the name table. */ public Table(int hashSize, int nameSize) { hashMask = hashSize - 1; hashes = new Name[hashSize]; names = new byte[nameSize]; slash = fromString("/"); hyphen = fromString("-"); T = fromString("T"); slashequals = fromString("/="); deprecated = fromString("deprecated"); init = fromString("<init>"); clinit = fromString("<clinit>"); error = fromString("<error>"); any = fromString("<any>"); empty = fromString(""); one = fromString("1"); period = fromString("."); comma = fromString(","); semicolon = fromString(";"); asterisk = fromString("*"); _this = fromString("this"); _super = fromString("super"); _default = fromString("default"); _class = fromString("class"); java_lang = fromString("java.lang"); java_lang_Object = fromString("java.lang.Object"); java_lang_Class = fromString("java.lang.Class"); java_lang_Cloneable = fromString("java.lang.Cloneable"); java_io_Serializable = fromString("java.io.Serializable"); java_lang_Enum = fromString("java.lang.Enum"); package_info = fromString("package-info"); serialVersionUID = fromString("serialVersionUID"); ConstantValue = fromString("ConstantValue"); LineNumberTable = fromString("LineNumberTable"); LocalVariableTable = fromString("LocalVariableTable"); LocalVariableTypeTable = fromString("LocalVariableTypeTable"); CharacterRangeTable = fromString("CharacterRangeTable"); StackMap = fromString("StackMap"); StackMapTable = fromString("StackMapTable"); SourceID = fromString("SourceID"); CompilationID = fromString("CompilationID"); Code = fromString("Code"); Exceptions = fromString("Exceptions"); SourceFile = fromString("SourceFile"); InnerClasses = fromString("InnerClasses"); Synthetic = fromString("Synthetic"); Bridge= fromString("Bridge"); Deprecated = fromString("Deprecated"); Enum = fromString("Enum"); _name = fromString("name"); Signature = fromString("Signature"); Varargs = fromString("Varargs"); Annotation = fromString("Annotation"); RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations"); RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations"); RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations"); RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations"); Value = fromString("Value"); EnclosingMethod = fromString("EnclosingMethod"); desiredAssertionStatus = fromString("desiredAssertionStatus"); append = fromString("append"); family = fromString("family"); forName = fromString("forName"); toString = fromString("toString"); length = fromString("length"); valueOf = fromString("valueOf"); value = fromString("value"); getMessage = fromString("getMessage"); getClass = fromString("getClass"); TYPE = fromString("TYPE"); FIELD = fromString("FIELD"); METHOD = fromString("METHOD"); PARAMETER = fromString("PARAMETER"); CONSTRUCTOR = fromString("CONSTRUCTOR"); LOCAL_VARIABLE = fromString("LOCAL_VARIABLE"); ANNOTATION_TYPE = fromString("ANNOTATION_TYPE"); PACKAGE = fromString("PACKAGE"); SOURCE = fromString("SOURCE"); CLASS = fromString("CLASS"); RUNTIME = fromString("RUNTIME"); Array = fromString("Array"); Method = fromString("Method"); Bound = fromString("Bound"); clone = fromString("clone"); getComponentType = fromString("getComponentType"); getClassLoader = fromString("getClassLoader"); initCause = fromString("initCause"); values = fromString("values"); iterator = fromString("iterator"); hasNext = fromString("hasNext"); next = fromString("next"); AnnotationDefault = fromString("AnnotationDefault"); ordinal = fromString("ordinal"); equals = fromString("equals"); hashCode = fromString("hashCode"); compareTo = fromString("compareTo"); getDeclaringClass = fromString("getDeclaringClass"); ex = fromString("ex"); finalize = fromString("finalize"); } public Table() { this(0x8000, 0x20000); } /** Create a name from the bytes in cs[start..start+len-1]. * Assume that bytes are in utf8 format. */ public Name fromUtf(byte cs[], int start, int len) { return Name.fromUtf(this, cs, start, len); } /** Create a name from the bytes in array cs. * Assume that bytes are in utf8 format. */ public Name fromUtf(byte cs[]) { return Name.fromUtf(this, cs, 0, cs.length); } /** Create a name from the characters in cs[start..start+len-1]. */ public Name fromChars(char[] cs, int start, int len) { return Name.fromChars(this, cs, start, len); } /** Create a name from the characters in string s. */ public Name fromString(CharSequence s) { return Name.fromString(this, s); } public final Name slash; public final Name hyphen; public final Name T; public final Name slashequals; public final Name deprecated; public final Name init; public final Name clinit; public final Name error; public final Name any; public final Name empty; public final Name one; public final Name period; public final Name comma; public final Name semicolon; public final Name asterisk; public final Name _this; public final Name _super; public final Name _default; public final Name _class; public final Name java_lang; public final Name java_lang_Object; public final Name java_lang_Class; public final Name java_lang_Cloneable; public final Name java_io_Serializable; public final Name serialVersionUID; public final Name java_lang_Enum; public final Name package_info; public final Name ConstantValue; public final Name LineNumberTable; public final Name LocalVariableTable; public final Name LocalVariableTypeTable; public final Name CharacterRangeTable; public final Name StackMap; public final Name StackMapTable; public final Name SourceID; public final Name CompilationID; public final Name Code; public final Name Exceptions; public final Name SourceFile; public final Name InnerClasses; public final Name Synthetic; public final Name Bridge; public final Name Deprecated; public final Name Enum; public final Name _name; public final Name Signature; public final Name Varargs; public final Name Annotation; public final Name RuntimeVisibleAnnotations; public final Name RuntimeInvisibleAnnotations; public final Name RuntimeVisibleParameterAnnotations; public final Name RuntimeInvisibleParameterAnnotations; public final Name Value; public final Name EnclosingMethod; public final Name desiredAssertionStatus; public final Name append; public final Name family; public final Name forName; public final Name toString; public final Name length; public final Name valueOf; public final Name value; public final Name getMessage; public final Name getClass; public final Name TYPE; public final Name FIELD; public final Name METHOD; public final Name PARAMETER; public final Name CONSTRUCTOR; public final Name LOCAL_VARIABLE; public final Name ANNOTATION_TYPE; public final Name PACKAGE; public final Name SOURCE; public final Name CLASS; public final Name RUNTIME; public final Name Array; public final Name Method; public final Name Bound; public final Name clone; public final Name getComponentType; public final Name getClassLoader; public final Name initCause; public final Name values; public final Name iterator; public final Name hasNext; public final Name next; public final Name AnnotationDefault; public final Name ordinal; public final Name equals; public final Name hashCode; public final Name compareTo; public final Name getDeclaringClass; public final Name ex; public final Name finalize; } public boolean isEmpty() { return len == 0; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -