Methods Summary |
---|
public synchronized void | addRoot(java.lang.String root)Adds a root to the cache.
String[] a = new String[roots.length + 1];
System.arraycopy(roots, 0, a, 0, roots.length);
a[roots.length] = root;
roots = a;
|
public static synchronized com.sun.midp.io.j2me.file.RootCache | getInstance()Gets reference to the root cache.
If an instance does not exist then creates it,
otherwise returns existing one.
if (instance == null) {
instance = new RootCache();
}
return instance;
|
public synchronized java.lang.String[] | getRoots()Gets the list of cached roots.
return roots;
|
public static synchronized void | initialize()Creates instance of root cache and fills it with current root paths.
getInstance();
|
public synchronized boolean | isRoot(java.lang.String root)Checks if path is a root path.
for (int i = 0; i < roots.length; i++) {
if (root.equals(roots[i])) {
return true;
}
}
return false;
|
public synchronized void | removeRoot(java.lang.String root)Removes a root from the cache.
int index = -1;
for (int i = 0; i < roots.length && index == -1; i++) {
if (root.equals(roots[i])) {
index = i;
}
}
if (index != -1) {
String[] a = new String[roots.length - 1];
System.arraycopy(roots, 0, a, 0, index);
System.arraycopy(roots, index + 1, a, index, a.length - index);
roots = a;
}
|