20 package net.sf.gridarta.model.mapmodel;
22 import org.jetbrains.annotations.NotNull;
23 import org.jetbrains.annotations.Nullable;
57 throw new IllegalArgumentException(
"map file is empty");
59 if (
name.contains(
"/")) {
60 throw new IllegalArgumentException(
"map file contains '/': " +
name);
62 if (
name.equals(
".")) {
64 }
else if (
name.equals(
"..")) {
65 if (parent.path.isEmpty()) {
67 }
else if (parent.path.endsWith(
"/..") || parent.path.equals(
"..")) {
68 path = parent.path +
"/..";
70 final int index = parent.path.lastIndexOf(
'/');
71 path = index == -1 ?
"" : parent.path.substring(0, index);
74 path = parent.path.isEmpty() ?
name : parent.path +
"/" +
name;
83 @SuppressWarnings(
"TypeMayBeWeakened")
85 final String[] source =
MapPath.
SEPARATOR.split(sourceMapPath.getPath(), -1);
86 final String[] destination =
MapPath.
SEPARATOR.split(destinationMapPath.getPath(), -1);
88 while (begin < source.length && begin < destination.length && source[begin].equals(destination[begin])) {
91 if (begin == destination.length && begin > 0) {
94 final StringBuilder sb =
new StringBuilder();
95 int i = source.length - 1;
100 while (i < destination.length) {
101 sb.append(
"/").append(destination[i]);
104 path = sb.length() > 0 ? sb.substring(1) :
"";
129 return path.compareTo(o.path);
133 public boolean equals(@Nullable
final Object obj) {
134 if (obj ==
null || getClass() != obj.getClass()) {
143 return path.hashCode();