Java Reference
In-Depth Information
L ISTING D.9 Continued
* Returns an array of Strings containing the names of all
the entries for a given URL.
*/
public String[] getNames(URL urlKey) throws java.net.MalformedURLException,
java.io.IOException {
File f = new File(sysDir, transformURL(urlKey));
return f.list();
}
/**
* Returns an int corresponding to the current value of the tag
* for the persistent data store entry associated with the given URL.
*/
public int getTag(URL parm1) throws java.net.MalformedURLException,
java.io.IOException {
System.out.println(“Method getTag() not yet implemented.”);
return CACHED;
}
/**
* Tags the persistent data store entry associated
with the given URL with the given tag value.
*/
public void setTag(URL parm1, int parm2) throws
java.net.MalformedURLException, java.io.IOException {
System.out.println(“Method setTag() not yet implemented.”);
}
/**
* transform an URl into a local file system path as a String
*/
private String transformURL(URL url) {
String s = url.toString().substring(url.toString().indexOf(“://”)+2);
StringBuffer stringbuffer = new StringBuffer(url.getProtocol());
for(int j = 0; j < s.length(); j++)
if(s.charAt(j) == '/') {
stringbuffer.append(File.separatorChar);
} else
if(s.charAt(j) == '&')
stringbuffer.append(“_”);
else
if(s.charAt(j) == ':')
stringbuffer.append(“-”);
Search WWH ::




Custom Search