My current work needs to do the development based on open soure software. There is a class defined as DirLocator.java The code is as follows
public final class DirLocator implements IResourceLocator
{
/** The folder relative to which resources are resolved. */
private File dir;
/**
* Initializes the locator using the given directory. If the argument is null or a
* non-existent folder, the locator will return an empty set of resources.
*/
public DirLocator(File dir)
{
this.dir = dir;
}
/**
* Initializes the locator using the given path. If the argument is null or a
* non-existent folder, the locator will return an empty set of resources.
*/
public DirLocator(String dirPath)
{
this(dirPath == null ? null : new File(dirPath));
}
/**
*
*/
@Override
public IResource [] getAll(String resource)
{
if (dir != null && dir.isDirectory() && dir.canRead())
{
resource = resource.replace('/', File.separatorChar);
while (resource.startsWith(File.separator))
{
resource = resource.substring(1);
}
final File resourceFile = new File(dir, resource);
if (resourceFile.isFile() && resourceFile.canRead())
{
return new IResource []
{
new FileResource(resourceFile)
};
}
}
return new IResource [0];
}
@Override
public int hashCode()
{
return ObjectUtils.hashCode(dir);
}
@Override
public boolean equals(Object target)
{
if (target == this) return true;
if (target != null && target instanceof DirLocator)
{
return ObjectUtils.equals(this.dir, ((DirLocator) target).dir);
}
return false;
}
@Override
public String toString()
{
return this.getClass().getName() + " [dir: "
+ (dir == null ? "null" : dir.getAbsolutePath()) + "]";
}
}
I create an object as follows
File lexicalDir = new File("resources");
ResourceLookup lexicalResourceLookup = new ResourceLookup(new DirLocator(lexicalDir));
But the compiler says "The constructor DirLocator(File) is undefined"
I do not know where is the error come from, and how to fix it? If you need more information, please let me know.