net.sf.adatagenerator.util
Class ResourceUtil

java.lang.Object
  extended by net.sf.adatagenerator.util.ResourceUtil

public class ResourceUtil
extends Object


Method Summary
static void closeReader(Reader r)
           
static BufferedReader getBufferedReader(ClassLoader cl, String fqrn)
          A general convenience utility that opens a buffered reader to the specified, fully qualified resource name using the specified class loader
static FrequencyBasedList<String> loadFrequencyBasedList(ClassLoader cl, String fqrn, String nullValueMarker)
          A utility that uses a specified class loader and fully qualified resource name to load a Febrl-style frequency-based list from a resource file.
static Map<String,List<String>> loadMappedLists(ClassLoader cl, String fqrn)
          A utility that uses a specified class loader and fully qualified resource name to load a Febrl-style map of Strings to Lists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBufferedReader

public static BufferedReader getBufferedReader(ClassLoader cl,
                                               String fqrn)
A general convenience utility that opens a buffered reader to the specified, fully qualified resource name using the specified class loader

Parameters:
fqrn - a non-null, non-blank fully qualified resource name
cl - a non-null class loader
Returns:

closeReader

public static void closeReader(Reader r)

loadFrequencyBasedList

public static FrequencyBasedList<String> loadFrequencyBasedList(ClassLoader cl,
                                                                String fqrn,
                                                                String nullValueMarker)
                                                         throws IOException
A utility that uses a specified class loader and fully qualified resource name to load a Febrl-style frequency-based list from a resource file.

Parameters:
cl - a non-null class loader
fqrn - a non-null, non-blank fully qualified resource name
nullValueMarker - a String that indicates a value in the frequency-based list is null; e.g. if the string NULL is specified as the null value marker, then null would be an element in the returned list. If null value value itself is null, then all values in the list are interpreted literally; i.e. the string NULL would be an element in the returned list.
Returns:
a non-null frequency-based list.
Throws:
IOException

loadMappedLists

public static Map<String,List<String>> loadMappedLists(ClassLoader cl,
                                                       String fqrn)
                                                throws IOException
A utility that uses a specified class loader and fully qualified resource name to load a Febrl-style map of Strings to Lists. The lists are shuffled after loading.

Parameters:
fqrn - a non-null, non-blank fully qualified resource name
cl - a non-null class loader
Returns:
a non-null map of Strings to shuffled lists of Strings.
Throws:
IOException


Copyright © 2011-2012. All Rights Reserved.