Why this piece of java code looks for a file in my Home directory? Why it's not in my eclipse workspace (/home/user/eclipse/workspace/)?
import org.eclipse.emf.common.util.URI;
URI uri = null;
try {
uri = URI.createURI("../models/task.cm");
Resource resource = resourceSet.getResource(uri, true);
...
getResource
Resource getResource(URI uri, boolean loadOnDemand)
Returns the resource resolved by the URI.
A resource set is expected to implement the following strategy in order to resolve the given URI to a resource. First it uses it's URI converter to normalize the URI and then to compare it with the normalized URI of each resource; if it finds a match, that resource becomes the result. Failing that, it delegates to allow the URI to be resolved elsewhere. For example, the package registry is used to resolve the namespace URI of a package to the static instance of that package. So the important point is that an arbitrary implementation may resolve the URI to any resource, not necessarily to one contained by this particular resource set. If the delegation step fails to provide a result, and if loadOnDemand is true, a resource is created and that resource becomes the result. If loadOnDemand is true and the result resource is not loaded, it will be loaded before it is returned.
Parameters:
uri - the URI to resolve.
loadOnDemand - whether to create and load the resource, if it doesn't
already exists.
Returns:
the resource resolved by the URI, or null if there isn't one and it's not
being demand loaded.
Throws:
java.lang.RuntimeException - if a resource can't be demand created.
WrappedException - if a problem occurs during demand load.
So, The resource is not found, and an arbitrary resource is created in your home directory.