PathData implements Comparable<PathData> { public PathData[] getDirectoryContents() throws IOException { checkIfExists(FileTypeRequirement.SHOULD_BE_DIRECTORY); FileStatus[] stats = fs.listStatus(path); PathData[] items = new PathData[stats.length]; for (int i=0; i < stats.length; i++) { String child = getStringForChildPath(stats[i].getPath()); items[i] = new PathData(fs, child, stats[i]); } Arrays.sort(items); return items; } PathData(String pathString, Configuration conf);  PathData(URI localPath, Configuration conf); private  PathData(FileSystem fs, String pathString); private  PathData(FileSystem fs, String pathString, FileStatus stat); FileStatus refreshStatus(); PathData suffix(String extension); boolean parentExists(); boolean representsDirectory(); PathData[] getDirectoryContents(); RemoteIterator<PathData> getDirectoryContentsIterator(); PathData getPathDataForChild(PathData child); static PathData[] expandAsGlob(String pattern, Configuration conf); @Override String toString(); File toFile(); @Override int compareTo(PathData o); @Override boolean equals(Object o); @Override int hashCode(); public FileSystem fs; final Path path; public FileStatus stat; public boolean exists; }
@Test (timeout = 30000) public void testUnqualifiedUriContents() throws Exception { String dirString = "d1"; PathData item = new PathData(dirString, conf); PathData[] items = item.getDirectoryContents(); assertEquals( sortedString("d1/f1", "d1/f1.1", "d1/f2"), sortedString(items) ); }
@Test (timeout = 30000) public void testCwdContents() throws Exception { String dirString = Path.CUR_DIR; PathData item = new PathData(dirString, conf); PathData[] items = item.getDirectoryContents(); assertEquals( sortedString("d1", "d2"), sortedString(items) ); }