public boolean isDescendant(ResourcePath path) { ResourcePath pathToTest = path; while (pathToTest != null) { if (pathToTest.equals(this)) { return true; } pathToTest = pathToTest.getParent(); } return false; }
public boolean isDescendant(ResourcePath path) { ResourcePath pathToTest = path; while (pathToTest != null) { if (pathToTest.equals(this)) { return true; } pathToTest = pathToTest.getParent(); } return false; }
public boolean isChild(ResourcePath path) { return GosuObjectUtil.equals(this, path.getParent()); }
public boolean isChild(ResourcePath path) { return GosuObjectUtil.equals(this, path.getParent()); }
/** * Two ResourcePath objects are considered to be equal if they represent the same leaf path and if their parents * are equal. Note that currently the name matching is case-sensitive, even when this is being called on * a case-insensitive file system. * * @param obj the other object * @return true if the objects are equal, false otherwise */ @Override public boolean equals(Object obj) { if (obj instanceof ResourcePath) { ResourcePath otherPath = (ResourcePath) obj; return otherPath.getName().equals(getName()) && GosuObjectUtil.equals(getParent(), otherPath.getParent()); } else { return false; } }
/** * Two ResourcePath objects are considered to be equal if they represent the same leaf path and if their parents * are equal. Note that currently the name matching is case-sensitive, even when this is being called on * a case-insensitive file system. * * @param obj the other object * @return true if the objects are equal, false otherwise */ @Override public boolean equals(Object obj) { if (obj instanceof ResourcePath) { ResourcePath otherPath = (ResourcePath) obj; return otherPath.getName().equals(getName()) && GosuObjectUtil.equals(getParent(), otherPath.getParent()); } else { return false; } }
public String relativePath(ResourcePath other, String separator) { List<String> pathComponents = new ArrayList<String>(); ResourcePath pathToTest = other; boolean success = false; while (pathToTest != null) { if (pathToTest.equals(this)) { success = true; break; } pathComponents.add(0, pathToTest.getName()); pathToTest = pathToTest.getParent(); } if (!success || pathComponents.isEmpty()) { return null; } else { return GosuStringUtil.join(pathComponents, separator); } }
public String relativePath(ResourcePath other, String separator) { List<String> pathComponents = new ArrayList<String>(); ResourcePath pathToTest = other; boolean success = false; while (pathToTest != null) { if (pathToTest.equals(this)) { success = true; break; } pathComponents.add(0, pathToTest.getName()); pathToTest = pathToTest.getParent(); } if (!success || pathComponents.isEmpty()) { return null; } else { return GosuStringUtil.join(pathComponents, separator); } }
result = result.getParent(); if (result == null) { throw new IllegalArgumentException("Joining the path [" + otherPath + "] to the base path [" + getPathString() + "] resulted in traversing backwards past the root path element");
result = result.getParent(); if (result == null) { throw new IllegalArgumentException("Joining the path [" + otherPath + "] to the base path [" + getPathString() + "] resulted in traversing backwards past the root path element");