public class ConfigFinder extends Object
Add the suffixes you're looking for by calling addSuffix(). You must provide at least one suffix, or the findConfigs() method will fail.
The ConfigFinder also understands the convention of versioning your configuration files by storing them in subfolders named v<#>dot<#>. For instance, for a versioned schema you might have schema/v0dot1, schema/v1dot23, schema/v11dot3dot1 which would represent schemas at version 0.1, 1.23 and 11.3.1 respectively.
NOTE: as indicated, the finder assumes that you're working in an Eclipse environment where you have a directory structure like: project/bin project/src. The finder will see the project/bin on the java.class.path and then try to find the src directory in the same location.
If your development environment doesn't conform to this arrangement, you can derive your own class, or, manually specify the source directories to search by priming the ConfigFinder with calls to addSourceDirectory().
| Constructor and Description |
|---|
ConfigFinder() |
ConfigFinder(Iterator<String> srcdirs)
Constructs a new ConfigFinder that will search the specified folders for
configurations.
|
ConfigFinder(String suffix)
Convenience constructor to create a finder with the specified file suffix
|
ConfigFinder(String suffix,
ArrayList<String> sd,
boolean cp)
Convenience constructor to create a finder with the specified file suffix
and source directories.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addJarPrefix(String e)
Adds a jar prefix to hunt for.
|
void |
addSourceDirectory(String dir)
Adds a source directory root to the set of paths that the finder will
traverse in search of schemas.
|
void |
addSuffix(String s)
Adds a suffix to hunt for.
|
void |
debug(boolean db) |
void |
findConfigs()
Scans the class path (and an additional source directories) for files
ending with the suffixes you've specified.
|
ConfigVersion |
getConfig(String cn)
Returns the versions of the specified config.
|
Iterator<ConfigLocation> |
getLocations() |
int |
getLongestName() |
String |
getSearchInfo()
Returns a description of where we searched for your config files.
|
TreeMap<String,ConfigVersion> |
getVersions() |
void |
setSourceAndJarInfo(ArrayList<String> sd,
ArrayList<String> jars)
A convenience function to add source and jar search preferences in one shot.
|
void |
setSourceInfo(ArrayList<String> sd)
A convenience function to add source search preferences.
|
public ConfigFinder()
public ConfigFinder(String suffix)
suffix - public ConfigFinder(String suffix, ArrayList<String> sd, boolean cp)
suffix - the file suffixsd - the source directories to searchpublic void setSourceInfo(ArrayList<String> sd)
sd - source directories to searchpublic void setSourceAndJarInfo(ArrayList<String> sd, ArrayList<String> jars)
sd - source directories to searchjars - the prefixes of jars to searchpublic void debug(boolean db)
public void addSuffix(String s)
s - the suffix to hunt for.public void addJarPrefix(String e)
e - the JAR prefix to hunt for.public void addSourceDirectory(String dir)
dir - The source directory.public void findConfigs()
throws ResultException,
IOException
ResultExceptionIOExceptionpublic ConfigVersion getConfig(String cn)
cn - The config name.public TreeMap<String,ConfigVersion> getVersions()
public Iterator<ConfigLocation> getLocations()
public int getLongestName()
public String getSearchInfo()
Copyright © 2023. All rights reserved.