@Override public String getValue() { if (myPath.length == 1) { final String name = FileNameCache.getVFileName(myPath[0]).toString(); // handle case of windows drive letter return name.length() == 2 && name.endsWith(":")? name + "/" : name; } final StringBuilder buf = new StringBuilder(); for (int element : myPath) { if (buf.length() > 0) { buf.append("/"); } buf.append(FileNameCache.getVFileName(element)); } return buf.toString(); }
@Override public String getValue() { if (myPath.length == 1) { final String name = FileNameCache.getVFileName(myPath[0]); // handle case of windows drive letter return name.length() == 2 && name.endsWith(":")? name + "/" : name; } final StringBuilder buf = new StringBuilder(); for (int element : myPath) { if (buf.length() > 0) { buf.append("/"); } buf.append(FileNameCache.getVFileName(element)); } return buf.toString(); }
/** * @param path assuming system-independent path with forward slashes */ protected InternedPath(String path) { final IntArrayList list = new IntArrayList(); final StringTokenizer tokenizer = new StringTokenizer(path, "/", false); while(tokenizer.hasMoreTokens()) { final String element = tokenizer.nextToken(); list.add(FileNameCache.storeName(element)); } myPath = list.toArray(); }
@Override public String getValue() { if (myPath.length > 0) { final StringBuilder buf = new StringBuilder(); for (int element : myPath) { buf.append("/").append(FileNameCache.getVFileName(element)); } return buf.toString(); } return "/"; }
@NotNull public static NameId[] listAll(int parentId) { try { r.lock(); try { final DataInputStream input = readAttribute(parentId, ourChildrenAttr); if (input == null) return NameId.EMPTY_ARRAY; int count = DataInputOutputUtil.readINT(input); NameId[] result = count == 0 ? NameId.EMPTY_ARRAY : new NameId[count]; int prevId = parentId; for (int i = 0; i < count; i++) { int id = DataInputOutputUtil.readINT(input) + prevId; prevId = id; int nameId = getNameId(id); result[i] = new NameId(id, nameId, FileNameCache.getVFileName(nameId)); } input.close(); return result; } finally { r.unlock(); } } catch (Throwable e) { throw DbConnection.handleError(e); } }
public static CharSequence getNameSequence(int id) { try { r.lock(); try { final int nameId = getRecordInt(id, NAME_OFFSET); return nameId != 0 ? FileNameCache.getVFileName(nameId) : ""; } finally { r.unlock(); } } catch (Throwable e) { throw DbConnection.handleError(e); } }
private static String decodePackageName(@NotNull int[] interned) { if (interned.length == 0) { return ""; } StringBuilder result = new StringBuilder(interned[0]); for (int i = 1; i < interned.length; i++) { if (i > 1) { result.append('.'); } result.append(FileNameCache.getVFileName(interned[i])); } return result.toString(); }
private static int[] internPackageName(@Nullable String packageName, @Nullable TObjectIntHashMap<String> alreadyEnumerated) { if (packageName == null) { return null; } if (packageName.isEmpty()) { return ArrayUtil.EMPTY_INT_ARRAY; } int dotCount = StringUtil.countChars(packageName, '.'); int[] result = new int[dotCount + 2]; result[0] = packageName.length(); int tokenStart = 0; int tokenIndex = 0; while (tokenStart < packageName.length()) { int tokenEnd = packageName.indexOf('.', tokenStart); if (tokenEnd < 0) { tokenEnd = packageName.length(); } String nextName = packageName.substring(tokenStart, tokenEnd); int internedId = alreadyEnumerated != null ? alreadyEnumerated.get(nextName) : 0; if (internedId == 0) { internedId = FileNameCache.storeName(nextName); if (alreadyEnumerated != null) alreadyEnumerated.put(nextName, internedId); } result[tokenIndex + 1] = internedId; tokenStart = tokenEnd + 1; tokenIndex++; } return result; }
@Nonnull public static NameId[] listAll(int parentId) { try { r.lock(); try { final DataInputStream input = readAttribute(parentId, ourChildrenAttr); if (input == null) return NameId.EMPTY_ARRAY; int count = DataInputOutputUtil.readINT(input); NameId[] result = count == 0 ? NameId.EMPTY_ARRAY : new NameId[count]; int prevId = parentId; for (int i = 0; i < count; i++) { int id = DataInputOutputUtil.readINT(input) + prevId; prevId = id; int nameId = getNameId(id); result[i] = new NameId(id, nameId, FileNameCache.getVFileName(nameId)); } input.close(); return result; } finally { r.unlock(); } } catch (Throwable e) { throw DbConnection.handleError(e); } }
protected static int toNameId(String name) { if (name == null) return NULL_NAME_ID; if (name.isEmpty()) return EMPTY_NAME_ID; return FileNameCache.storeName(name); }
private static CharSequence fromNameId(int nameId) { if (nameId == NULL_NAME_ID) return null; if (nameId == EMPTY_NAME_ID) return ""; return FileNameCache.getVFileName(nameId); }