private void getChildPaths( Configuration conf, Set<String> results, int trim, Path path, int depth ) throws IOException { if( depth == 0 ) { String substring = path.toString().substring( trim ); String identifier = getIdentifier(); if( identifier == null || identifier.isEmpty() ) results.add( new Path( substring ).toString() ); else results.add( new Path( identifier, substring ).toString() ); return; } FileStatus[] statuses = getFileSystem( conf ).listStatus( path, HIDDEN_FILES_FILTER ); if( statuses == null ) return; for( FileStatus fileStatus : statuses ) getChildPaths( conf, results, trim, fileStatus.getPath(), depth - 1 ); }
@Override public String[] getChildIdentifiers( Configuration conf, int depth, boolean fullyQualified ) throws IOException { if( !resourceExists( conf ) ) return new String[ 0 ]; if( depth == 0 && !fullyQualified ) return new String[]{getIdentifier()}; String fullIdentifier = getFullIdentifier( conf ); int trim = fullyQualified ? 0 : fullIdentifier.length() + 1; Set<String> results = new LinkedHashSet<String>(); getChildPaths( conf, results, trim, new Path( fullIdentifier ), depth ); return results.toArray( new String[ results.size() ] ); }
private void getChildPaths( Configuration conf, Set<String> results, int trim, Path path, int depth ) throws IOException { if( depth == 0 ) { String substring = path.toString().substring( trim ); String identifier = getIdentifier(); if( identifier == null || identifier.isEmpty() ) results.add( new Path( substring ).toString() ); else results.add( new Path( identifier, substring ).toString() ); return; } FileStatus[] statuses = getFileSystem( conf ).listStatus( path, HIDDEN_FILES_FILTER ); if( statuses == null ) return; for( FileStatus fileStatus : statuses ) getChildPaths( conf, results, trim, fileStatus.getPath(), depth - 1 ); }
@Override public String[] getChildIdentifiers( Configuration conf, int depth, boolean fullyQualified ) throws IOException { if( !resourceExists( conf ) ) return new String[ 0 ]; if( depth == 0 && !fullyQualified ) return new String[]{getIdentifier()}; String fullIdentifier = getFullIdentifier( conf ); int trim = fullyQualified ? 0 : fullIdentifier.length() + 1; Set<String> results = new LinkedHashSet<String>(); getChildPaths( conf, results, trim, new Path( fullIdentifier ), depth ); return results.toArray( new String[ results.size() ] ); }