private void add(final TreeEntry entry) { String type = entry.getType(); String path = entry.getPath(); if (TextUtils.isEmpty(path)) return; if (TYPE_BLOB.equals(type)) { String[] segments = path.split("/"); if (segments.length > 1) { Folder folder = folders.get(segments[0]); if (folder != null) folder.addFile(entry, segments, 1); } else if (segments.length == 1) { Entry file = new Entry(entry, this); files.put(file.name, file); } } else if (TYPE_TREE.equals(type)) { String[] segments = path.split("/"); if (segments.length > 1) { Folder folder = folders.get(segments[0]); if (folder != null) folder.addFolder(entry, segments, 1); } else if (segments.length == 1) { Folder folder = new Folder(entry, this); folders.put(folder.name, folder); } } }
public void add(String filePath, String languageName, String moduleName, int lineCount) { // Get rid of Microsoft's incompatibility once and forever filePath = filePath.replace("\\", DIRECTORY_SEPARATOR); String folderPath = extractFolder(filePath); File file = new File(filePath, languageName, moduleName, lineCount); this.addFile(file); Folder folder = this.getFolder(folderPath); if (folder == null) { folder = new Folder(folderPath); this.addFolder(folder); } folder.addFile(file); Language language = this.getLanguage(languageName); if (language == null) { language = new Language(languageName); this.addLanguage(language); } language.addFile(file); Module module = getModule(moduleName); if (module == null) { module = new Module(moduleName); this.addModule(module); } module.addFile(file); }
private void addFile(TreeEntry entry, String[] pathSegments, int index) { if (index == pathSegments.length - 1) { Entry file = new Entry(entry, this); files.put(file.name, file); } else { Folder folder = folders.get(pathSegments[index]); if (folder != null) folder.addFile(entry, pathSegments, index + 1); } }