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(
'/');
74 path = parent.path.substring(0, index);
78 if (parent.path.isEmpty()) {
81 path = parent.path +
"/" + name;
100 return (RelativeMapPath) mapPath;
103 return new RelativeMapPath(
this, (AbsoluteMapPath) mapPath);
105 throw new AssertionError();
111 final int index = path.indexOf(
'/', 1);
116 return path.substring(0, index);
121 return path.compareTo(o.path);
125 public boolean equals(@Nullable
final Object obj) {
126 if (obj == null || getClass() != obj.getClass()) {
135 return path.hashCode();
String getPath()
Returns the map path information.
int compareTo(@NotNull final AbsoluteMapPath o)
A MapPath that is absolute, that is, it starts with a "/".
Represents a maps directory local map path.
String getMapComponent()
Returns the initial path component of a map path.
RelativeMapPath getRelativeMapPathTo(@NotNull final MapPath mapPath)
Returns a map path of an another map path relative to this map path.
static final long serialVersionUID
The serial versionUID,.
AbsoluteMapPath()
Creates a new instance.
final String path
The map path information.
boolean equals(@Nullable final Object obj)
Represents a maps directory local map path.
AbsoluteMapPath(@NotNull final AbsoluteMapPath parent, @NotNull final String name)
Creates a new map path based on a parent map path.