@Test public void normalizeFolderIdTest() { assertEquals(Folder.ROOT_FOLDER_ID, Folder.normalizeFolderId("/")); assertEquals(Folder.ROOT_FOLDER_ID, Folder.normalizeFolderId(" assertEquals(Folder.ROOT_FOLDER_ID, Folder.normalizeFolderId(" assertEquals(Folder.ROOT_FOLDER_ID, Folder.normalizeFolderId("\\\\ assertEquals("a", Folder.normalizeFolderId("a")); assertEquals("a", Folder.normalizeFolderId("/a")); assertEquals("a", Folder.normalizeFolderId("a/")); assertEquals("a", Folder.normalizeFolderId("/a/")); assertEquals("a/b/c", Folder.normalizeFolderId("a/b/c")); assertEquals("a/b/c", Folder.normalizeFolderId("/a/b/c")); assertEquals("a/b/c", Folder.normalizeFolderId("a/b/c/")); assertEquals("a/b/c", Folder.normalizeFolderId("/a/b/c/")); }
public static String normalizeFolderId(String id) { id = id.trim(); id = id.replace("\\", "/"); while (id.contains(" id = id.replaceAll(" } id = id.replaceAll(" if (id.equals(ROOT_FOLDER_ID)) { return ROOT_FOLDER_ID; } if (id.charAt(0) == '/') { id = id.substring(1); } if (id.charAt(id.length() - 1) == '/') { id = id.substring(0, id.length() - 1); } return id; }
Folder { public static String normalizeFolderId(String id) { id = id.trim(); id = id.replace("\\", "/"); while (id.contains(" id = id.replaceAll(" } id = id.replaceAll(" if (id.equals(ROOT_FOLDER_ID)) { return ROOT_FOLDER_ID; } if (id.charAt(0) == '/') { id = id.substring(1); } if (id.charAt(id.length() - 1) == '/') { id = id.substring(0, id.length() - 1); } return id; } }
Folder { public static String normalizeFolderId(String id) { id = id.trim(); id = id.replace("\\", "/"); while (id.contains(" id = id.replaceAll(" } id = id.replaceAll(" if (id.equals(ROOT_FOLDER_ID)) { return ROOT_FOLDER_ID; } if (id.charAt(0) == '/') { id = id.substring(1); } if (id.charAt(id.length() - 1) == '/') { id = id.substring(0, id.length() - 1); } return id; } Folder(String id); }
Folder { public static String normalizeFolderId(String id) { id = id.trim(); id = id.replace("\\", "/"); while (id.contains(" id = id.replaceAll(" } id = id.replaceAll(" if (id.equals(ROOT_FOLDER_ID)) { return ROOT_FOLDER_ID; } if (id.charAt(0) == '/') { id = id.substring(1); } if (id.charAt(id.length() - 1) == '/') { id = id.substring(0, id.length() - 1); } return id; } Folder(String id); String getId(); String getName(); String getParentFolderId(); static String normalizeFolderId(String id); void rename(String newId); void merge(Folder folder); void addFolderListener(FolderListener listener); void notifyRenamed(String oldFolderId); Folder getParent(); Map<String, Folder> getChildren(); void setParent(Folder parent); void addChild(Folder child); void removeChild(String folderId); void addNote(Note note); void addNotes(List<Note> newNotes); void removeNote(Note note); List<Note> getNotes(); List<Note> getNotesRecursively(); int countNotes(); boolean hasChild(); boolean isTrash(); }
Folder { public static String normalizeFolderId(String id) { id = id.trim(); id = id.replace("\\", "/"); while (id.contains(" id = id.replaceAll(" } id = id.replaceAll(" if (id.equals(ROOT_FOLDER_ID)) { return ROOT_FOLDER_ID; } if (id.charAt(0) == '/') { id = id.substring(1); } if (id.charAt(id.length() - 1) == '/') { id = id.substring(0, id.length() - 1); } return id; } Folder(String id); String getId(); String getName(); String getParentFolderId(); static String normalizeFolderId(String id); void rename(String newId); void merge(Folder folder); void addFolderListener(FolderListener listener); void notifyRenamed(String oldFolderId); Folder getParent(); Map<String, Folder> getChildren(); void setParent(Folder parent); void addChild(Folder child); void removeChild(String folderId); void addNote(Note note); void addNotes(List<Note> newNotes); void removeNote(Note note); List<Note> getNotes(); List<Note> getNotesRecursively(); int countNotes(); boolean hasChild(); boolean isTrash(); static final String ROOT_FOLDER_ID; static final String TRASH_FOLDER_ID; static final String TRASH_FOLDER_CONFLICT_INFIX; }