Code with Finding: |
class ResourceClassProperties {
void initialize() {
// Load the editor properties:
try {
ZipEntry propentry = zip.getEntry(entryPath + "properties");
if (propentry != null) {
InputStream in = (new BufferedInputStream
(zip.getInputStream(propentry)));
editorProperties = new Properties();
editorProperties.load(in);
in.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
// From the editor properties, get the set of helpers:
if ( editorProperties != null )
helperClasses = getStringArray(editorProperties, "helpers");
// Load the helpers specific properties:
helperProperties = new Hashtable(11);
loadPropertyDirectory(helperProperties, zip, entryPath + "helpers");
// Load the specific attribute editor properties:
attributeProperties = new Hashtable(11);
loadPropertyDirectory(attributeProperties, zip,entryPath + "attrs");
}
}
class PropertyManager {
protected void initialize() {
ZipFile zip = null;
try {
zip = new ZipFile(this.zipfile);
} catch (Exception ex) {
ex.printStackTrace();
return;
}
Enumeration entries = zip.entries();
classProperties = new Hashtable(11);
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
String entry_name = entry.getName();
if (entry_name.equals( "icons"+ File.separator)) //reserved
continue;
// Skip non directory entries
if (! entry.isDirectory() )
continue;
// only first level sub directories
if (entry_name.indexOf(File.separator) ==
entry_name.lastIndexOf(File.separator)) {
ResourceClassProperties rcp = null;
rcp = new ResourceClassProperties(entry_name, zip);
String name = entry_name.substring(0, entry_name.length()-1 );
classProperties.put(name, rcp);
}
}
// and now the icons mapping
try {
ZipEntry icons = zip.getEntry("icons.p");
InputStream in = (new BufferedInputStream
(zip.getInputStream(icons)));
iconProperties = new Properties();
iconProperties.load(in);
in.close();
} catch (Exception ex) {
ex.printStackTrace();
}
// and now the mime types
mimeTypes = new Hashtable(11);
try {
ZipEntry mime = zip.getEntry("mimetypes.p");
InputStream in = (new BufferedInputStream
(zip.getInputStream(mime)));
Properties p = new Properties();
p.load(in);
in.close();
String[] major = ResourceClassProperties.getStringArray(p,"Types");
String[] minor;
for(int i=0; i<major.length; i++) {
minor = ResourceClassProperties.getStringArray(p, major[i]);
mimeTypes.put(major[i], minor);
}
} catch (Exception ex) {
ex.printStackTrace();
}
//resources list
try {
ZipEntry res = zip.getEntry("resources.p");
InputStream in = (new BufferedInputStream
(zip.getInputStream(res)));
resources = new Properties();
resources.load(in);
in.close();
} catch (Exception ex) {
ex.printStackTrace();
}
//frames list
try {
ZipEntry fr = zip.getEntry("frames.p");
InputStream in = (new BufferedInputStream
(zip.getInputStream(fr)));
frames = new Properties();
frames.load(in);
in.close();
} catch (Exception ex) {
ex.printStackTrace();
}
//indexers list
try {
ZipEntry idx = zip.getEntry("indexers.p");
InputStream in = (new BufferedInputStream
(zip.getInputStream(idx)));
indexers = new Properties();
indexers.load(in);
in.close();
} catch (Exception ex) {
ex.printStackTrace();
}
//close
try {
zip.close(); //FIXME: sure?
} catch (Exception ex) {
ex.printStackTrace();
}
inited = true;
}
}
|