hi,
i have a jar file with 2 reosources, when i use the reosources in jar file it's all ok.
If i import the file jar as library and use it in a new file Prova i recive the following message:
ERRORE: '/home/gianni/workspace/Prova/file:/home/gianni/JfuzzyLogicFML.jar!/net/sourceforge/jFuzzyLogic/fml2fcl.xsl (No such file or directory)'.
i have duplicate path and i don't get resources right....
how can do to work right?
public class Resources {
this is the class that manage resources;
public enum ResourceName{
fmlSchema,
xslt,
}
/**
* @uml.property name="properties"
*/
private static final String resourceName[] = new String[]{
"fmlSchema.xsd",
"fml2fcl.xsl"
};
/**
* @uml.property name="singleton"
*/
private static Resources singleton;
/**
* @throws Exception
*/
public static Resources getInstance() throws Exception {
if (singleton == null) {
synchronized (Resources.class) {
if (singleton == null) {
singleton = new Resources();
}
}
}
return singleton;
}
/**
* Constructor
*
* @throws Exception
*/
private Resources(){
mapResources = new HashMap<ResourceName, File>();
}
Map<ResourceName, File> mapResources;
public File getResource(ResourceName name){
File file;
file = mapResources.get(name);
if( file == null ){
file = new File( getClass().getResource(resourceName[name.ordinal()]).getPath());
mapResources.put(name, file);
}
return file;
}
}
and here i s where i use it:
public static FIS loadFML(String fmlFilePath, boolean verbose) throws SAXException {
FMLValidator validator = new FMLValidator();
File xml = new File(fmlFilePath);
File fmlSchema = resources.getResource(Resources.ResourceName.fmlSc hema);
File xslt = resources.getResource(Resources.ResourceName.xslt) ;
validator.validate( xml , fmlSchema.getPath());
String fclDefinition = FML2FCLTransformation.transform( xml , xslt);
System.out.print(xslt);
return createFromString(fclDefinition, verbose);
}
|