@Test public void testJoin_String() { String path = "/html/public"; Path instance = new Path("/var/www"); Path expResult = new Path("/var/www/html/public"); Path result = instance.join(path); assertEquals(expResult, result); }
public Path join(Path path) { if(path.isRoot()) return new Path(pathElements); if(isRoot()) return new Path(path.pathElements); String[] newElements = new String[pathElements.length + path.pathElements.length]; System.arraycopy(pathElements, 0, newElements, 0, pathElements.length); System.arraycopy(path.pathElements, 0, newElements, pathElements.length, path.pathElements.length); return new Path(newElements); }
Path implements Iterable<Path> { public Path join(Path path) { if(path.isRoot()) return new Path(pathElements); if(isRoot()) return new Path(path.pathElements); String[] newElements = new String[pathElements.length + path.pathElements.length]; System.arraycopy(pathElements, 0, newElements, 0, pathElements.length); System.arraycopy(path.pathElements, 0, newElements, pathElements.length, path.pathElements.length); return new Path(newElements); } }
Path implements Iterable<Path> { public Path join(Path path) { if(path.isRoot()) return new Path(pathElements); if(isRoot()) return new Path(path.pathElements); String[] newElements = new String[pathElements.length + path.pathElements.length]; System.arraycopy(pathElements, 0, newElements, 0, pathElements.length); System.arraycopy(path.pathElements, 0, newElements, pathElements.length, path.pathElements.length); return new Path(newElements); } Path();  Path(String path); private  Path(String[] pathElements); }
Path implements Iterable<Path> { public Path join(Path path) { if(path.isRoot()) return new Path(pathElements); if(isRoot()) return new Path(path.pathElements); String[] newElements = new String[pathElements.length + path.pathElements.length]; System.arraycopy(pathElements, 0, newElements, 0, pathElements.length); System.arraycopy(path.pathElements, 0, newElements, pathElements.length, path.pathElements.length); return new Path(newElements); } Path();  Path(String path); private  Path(String[] pathElements); String[] getPathElements(); String getFirstElement(); String getName(); Path getParent(); Path getNext(); boolean hasNext(); boolean isRoot(); boolean isSelf(); boolean isParent(); boolean isLast(); Path getCanonicalPath(); @Override String toString(); String toString(String pathSep); Path join(Path path); Path join(String path); @Override Iterator<Path> iterator(); String getExtension(); @Override int hashCode(); @Override boolean equals(Object obj); boolean startsWith(Path path); Path leftTrim(Path path); }
Path implements Iterable<Path> { public Path join(Path path) { if(path.isRoot()) return new Path(pathElements); if(isRoot()) return new Path(path.pathElements); String[] newElements = new String[pathElements.length + path.pathElements.length]; System.arraycopy(pathElements, 0, newElements, 0, pathElements.length); System.arraycopy(path.pathElements, 0, newElements, pathElements.length, path.pathElements.length); return new Path(newElements); } Path();  Path(String path); private  Path(String[] pathElements); String[] getPathElements(); String getFirstElement(); String getName(); Path getParent(); Path getNext(); boolean hasNext(); boolean isRoot(); boolean isSelf(); boolean isParent(); boolean isLast(); Path getCanonicalPath(); @Override String toString(); String toString(String pathSep); Path join(Path path); Path join(String path); @Override Iterator<Path> iterator(); String getExtension(); @Override int hashCode(); @Override boolean equals(Object obj); boolean startsWith(Path path); Path leftTrim(Path path);  }