/** * Constructs a simple DotName which stores the string in it's entirety. This variant is ideal * for temporary usage, such as looking up an entry in a Map. * * @param name A fully qualified non-null name (with dots) * @return a simple DotName that wraps name */ public static DotName createSimple(String name) { return new DotName(null, name, false, false); }
private VoidType(AnnotationInstance[] annotations) { super(new DotName(null, "void", true, false), annotations); }
/** * Constructs a componentized DotName. Each DotName refers to a parent * prefix (or null if there is no further prefix) in addition to a local * name that has no dot separator. The fully qualified name this DotName * represents is constructed by recursing all parent prefixes and joining all * local name values with the '.' character. * * @param prefix Another DotName that is the portion to the left of * localName, this may be null if there is not one * @param localName the local non-null portion of this name, which does not contain * '.' * @return a componentized DotName. */ public static DotName createComponentized(DotName prefix, String localName) { if (localName.indexOf('.') != -1) throw new IllegalArgumentException("A componentized DotName can not contain '.' characters in a local name"); return new DotName(prefix, localName, true, false); }
/** * Constructs a componentized DotName. Each DotName refers to a parent * prefix (or null if there is no further prefix) in addition to a local * name that has no dot separator. The fully qualified name this DotName * represents is consructed by recursing all parent prefixes and joining all * local name values with the '.' character. * * @param prefix Another DotName that is the portion to the left of * localName, this may be null if there is not one * @param localName the local non-null portion of this name, which does not contain * '.' * @param innerClass whether or not this localName is an inner class name, requiring '$' vs '.' * @return a componentized DotName. */ public static DotName createComponentized(DotName prefix, String localName, boolean innerClass) { if (localName.indexOf('.') != -1) throw new IllegalArgumentException("A componentized DotName can not contain '.' characters in a local name"); return new DotName(prefix, localName, true, innerClass); }
private PrimitiveType(Primitive primitive, AnnotationInstance[] annotations) { super(new DotName(null, primitive.name().toLowerCase(Locale.ENGLISH), true, false), annotations); this.primitive = primitive; }
DotName convertToName(String name, char delim) { DotName result = names.get(name); if (result != null) return result; int loc = lastIndexOf(name, delim, '$'); String local = intern(name.substring(loc + 1)); DotName prefix = loc < 1 ? null : convertToName(intern(name.substring(0, loc)), delim); result = new DotName(prefix, local, true, loc > 0 && name.charAt(loc) == '$'); names.put(name, result); return result; }
DotName wrap(DotName prefix, String local, boolean inner) { DotName name = new DotName(prefix, intern(local), true, true); return intern(name, '.'); }
private DotName downgradeName(DotName name) { DotName n = name; StringBuilder builder = null; while (n.isInner()) { if (builder == null) { builder = new StringBuilder(); } builder.insert(0, n.local()).insert(0, '$'); if (! n.prefix().isInner()) { builder.insert(0, n.prefix().local()); name = new DotName(n.prefix().prefix(), builder.toString(), true, false); } n = n.prefix(); } return name; }
private void readClassTable(PackedDataInputStream stream) throws IOException { int entries = stream.readPackedU32(); int lastDepth = -1; DotName curr = null; // Null is the implicit first entry classTable = new DotName[++entries]; for (int i = 1; i < entries; i++) { int depth = stream.readPackedU32(); String local = stream.readUTF(); if (depth <= lastDepth) { while (lastDepth-- >= depth) curr = curr.prefix(); } classTable[i] = curr = new DotName(curr, local, true, false); lastDepth = depth; } }
private void readNameTable(PackedDataInputStream stream) throws IOException { // Null is the implicit first entry int entries = stream.readPackedU32() + 1; int lastDepth = -1; DotName curr = null; nameTable = new DotName[entries]; for (int i = 1; i < entries; i++) { int depth = stream.readPackedU32(); boolean inner = (depth & 1) == 1; depth >>= 1; String local = stringTable[stream.readPackedU32()]; if (depth <= lastDepth) { while (lastDepth-- >= depth) { assert curr != null; curr = curr.prefix(); } } nameTable[i] = curr = new DotName(curr, local, true, inner); lastDepth = depth; } }