Package org.netbeans.jemmy
Class BundleManager
- java.lang.Object
-
- org.netbeans.jemmy.BundleManager
-
public class BundleManager extends java.lang.ObjectProvides functionality to work with a bunch of resource files.- Author:
- Alexandre Iline (alexandre.iline@sun.com)
- See Also:
Bundle
-
-
Constructor Summary
Constructors Constructor Description BundleManager()Bundle manager constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BundleaddBundle(Bundle bundle, java.lang.String ID)Adds a Bundle to the managed collection of resource files.intcalculateResources(java.lang.String key)Counts the number of resource occurences in all the managed Bundles.BundleManagercloneThis()Creates a shallow copy of this BundleManager.BundlegetBundle(java.lang.String ID)Returns a Bundle given it's symbolic ID.java.lang.StringgetResource(java.lang.String key)Searches for a resource in all the managed Bundles.java.lang.StringgetResource(java.lang.String bundleID, java.lang.String key)Returns resource from ID bundle.Bundleload()Loads resources from simple text file pointed by jemmy.resources system property.BundleloadBundleFromFile(java.lang.String fileName, java.lang.String ID)Create a new Bundle, load resources from a simple text file, and add the bundle.BundleloadBundleFromJar(java.lang.String fileName, java.lang.String entryName, java.lang.String ID)Loads resources from file in jar archive into new Bundle object and adds it.BundleloadBundleFromResource(java.lang.ClassLoader cl, java.lang.String resource, java.lang.String ID)BundleloadBundleFromStream(java.io.InputStream stream, java.lang.String ID)BundleloadBundleFromZip(java.lang.String fileName, java.lang.String entryName, java.lang.String ID)Loads resources from file in zip archive into new Bundle object and adds it.voidprint(java.io.PrintStream stream)Prints bundles contents.voidprint(java.io.PrintWriter writer)Prints bundles contents.BundleremoveBundle(java.lang.String ID)Removes a Bundle from the managed collection of resource files.
-
-
-
Method Detail
-
addBundle
public Bundle addBundle(Bundle bundle, java.lang.String ID)
Adds a Bundle to the managed collection of resource files.- Parameters:
bundle- Bundle objectID- Symbolic bundle id- Returns:
- First parameter or null if bundle with ID already exists.
- See Also:
Bundle
-
removeBundle
public Bundle removeBundle(java.lang.String ID)
Removes a Bundle from the managed collection of resource files.- Parameters:
ID- Symbolic bundle id- Returns:
- Removed bundle or null if no bundle ID is.
-
getBundle
public Bundle getBundle(java.lang.String ID)
Returns a Bundle given it's symbolic ID.- Parameters:
ID- Symbolic bundle ID- Returns:
- the Bundle. A null reference is returned if no bundle with the symbolic ID was found.
-
loadBundleFromFile
public Bundle loadBundleFromFile(java.lang.String fileName, java.lang.String ID) throws java.io.IOException, java.io.FileNotFoundException
Create a new Bundle, load resources from a simple text file, and add the bundle. Load resources from a text file to a new Bundle object. The new Bundle is added to the collection of objects managed by thisBundleManager.- Parameters:
fileName- Name of a file to load resources from.ID- Symbolic bundle ID used to identify the new bundle used to manage the resources from the file.- Returns:
- a newly created bundle.
- Throws:
java.io.IOExceptionjava.io.FileNotFoundException
-
loadBundleFromStream
public Bundle loadBundleFromStream(java.io.InputStream stream, java.lang.String ID) throws java.io.IOException, java.io.FileNotFoundException
- Throws:
java.io.IOExceptionjava.io.FileNotFoundException
-
loadBundleFromResource
public Bundle loadBundleFromResource(java.lang.ClassLoader cl, java.lang.String resource, java.lang.String ID) throws java.io.IOException, java.io.FileNotFoundException
- Throws:
java.io.IOExceptionjava.io.FileNotFoundException
-
load
public Bundle load() throws java.io.IOException, java.io.FileNotFoundException
Loads resources from simple text file pointed by jemmy.resources system property. The resources are loaded into the Bundle with ID "". Does not do anything if jemmy.resources has not been set or is empty.- Returns:
- a newly created bundle.
- Throws:
java.io.IOExceptionjava.io.FileNotFoundException
-
loadBundleFromJar
public Bundle loadBundleFromJar(java.lang.String fileName, java.lang.String entryName, java.lang.String ID) throws java.io.IOException, java.io.FileNotFoundException
Loads resources from file in jar archive into new Bundle object and adds it.- Parameters:
fileName- Name of jar file.entryName- ?enryName? Name of file to load resources from.ID- Symbolic bundle id- Returns:
- a newly created bundle.
- Throws:
java.io.IOExceptionjava.io.FileNotFoundException
-
loadBundleFromZip
public Bundle loadBundleFromZip(java.lang.String fileName, java.lang.String entryName, java.lang.String ID) throws java.io.IOException, java.io.FileNotFoundException, java.util.zip.ZipException
Loads resources from file in zip archive into new Bundle object and adds it.- Parameters:
fileName- Name of jar file.entryName- ?enryName? Name of file to load resources from.ID- Symbolic bundle id- Returns:
- a newly created bundle.
- Throws:
java.util.zip.ZipExceptionjava.io.IOExceptionjava.io.FileNotFoundException
-
print
public void print(java.io.PrintWriter writer)
Prints bundles contents.- Parameters:
writer- Writer to print data in.
-
print
public void print(java.io.PrintStream stream)
Prints bundles contents.- Parameters:
stream- Stream to print data in.
-
getResource
public java.lang.String getResource(java.lang.String bundleID, java.lang.String key)Returns resource from ID bundle.- Parameters:
bundleID- Bundle ID.key- Resource key.- Returns:
- the resource value. If the bundle ID does not exist if the resource with the given key cannot be found, a null reference is returned.
-
getResource
public java.lang.String getResource(java.lang.String key)
Searches for a resource in all the managed Bundles.- Parameters:
key- Resource key.- Returns:
- first resource value found that is indexed by the given key. If no resource is found, return a null reference.
-
calculateResources
public int calculateResources(java.lang.String key)
Counts the number of resource occurences in all the managed Bundles.- Parameters:
key- Resource key- Returns:
- the number of resource occurences with the given key among all the Bundles managed by this BundleManager.
-
cloneThis
public BundleManager cloneThis()
Creates a shallow copy of this BundleManager. Does not copy bundles, only their references.- Returns:
- a copy of this BundleManager.
-
-