org.springframework.beandoc.util
Class BeanDocUtils

java.lang.Object
  extended by org.springframework.beandoc.util.BeanDocUtils

public class BeanDocUtils
extends Object

Collection of static utility methods used by BeanDoc.

Since:
1.0
Author:
Darren Davison, Michael Schuerig,

Method Summary
static Map filterByPrefix(Map map, String prefix)
          Returns a new Map containing only those entries from map whose key starts with prefix.
static Map filterByPrefix(Map map, String prefix, boolean removePrefix)
          Returns a new Map containing only those entries from map whose key starts with prefix.
static String getRelativePath(String input)
          Return a String denoting a relative path marker for the input file name (String).
static Resource[] getResources(String[] inputFileNames)
          Convert string values to physical resources
static List listFilesRecursively(File rootDir, FileFilter filter)
          Returns a List of File objects based on criteria specified.
static String[] normaliseFileNames(Resource[] inputFiles)
          For the given array of Resources, return an equivalent length array of filenames that uniquely identify each file-system resource from the shortest possible common root.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

filterByPrefix

public static Map filterByPrefix(Map map,
                                 String prefix)
Returns a new Map containing only those entries from map whose key starts with prefix. Prefixes are removed from the keys in the returned Map.

Parameters:
map - the original Map to be filtered; must not be null
prefix - prefix by which entries are filtered; may be empty of null
Returns:
a new Map with filtered entries
See Also:
filterByPrefix(Map, String, boolean)

filterByPrefix

public static Map filterByPrefix(Map map,
                                 String prefix,
                                 boolean removePrefix)
Returns a new Map containing only those entries from map whose key starts with prefix.

Parameters:
map - the original Map to be filtered; must not be null
prefix - prefix by which entries are filtered; may be empty of null
removePrefix - should prefixes be removed from entries in the returned Map?
Returns:
a new Map with filtered entries

getResources

public static Resource[] getResources(String[] inputFileNames)
                               throws IOException
Convert string values to physical resources

Parameters:
inputFileNames - an array of Strings representing resource names
Returns:
an array of Resource's resolved from the input names
Throws:
IOException

normaliseFileNames

public static String[] normaliseFileNames(Resource[] inputFiles)
For the given array of Resources, return an equivalent length array of filenames that uniquely identify each file-system resource from the shortest possible common root.

For example, given the following Resources (files);

   /projects/myproject/file1.xml
   /projects/myproject/module1/file1.xml
   /projects/myproject/module2/file1.xml
 
the method will return a String array of the following names;
   file1.xml
   module1/file1.xml
   module2/file1.xml
 
having stripped the longest common path from all of the input names.

Parameters:
inputFiles - an array of Resources which must be resolvable as Files
Returns:
a String array of filenames from a common root

getRelativePath

public static String getRelativePath(String input)
Return a String denoting a relative path marker for the input file name (String). For example, an input of "foo/bar/baz.html" has a relative marker of "../../" denoting the two path components.

Parameters:
input -
Returns:
a relative marker

listFilesRecursively

public static List listFilesRecursively(File rootDir,
                                        FileFilter filter)
Returns a List of File objects based on criteria specified. The functionality is equivalent to File.listFiles() but with the added benefit of recursing all subdirectories from the root directory supplied.

Parameters:
rootDir - A File object which indicates the root location to begin searching matching files. If not an existing directory on disk, an IllegalArgumentException will be thrown.
filter - A FileFilter that is used to specify which File's should be returned.
Returns:
A List of File objects that match the criteria specified in the FileFilter parameter


Copyright © 2004-2011 Spring BeanDoc. All Rights Reserved.