diff --git a/src/main/java/li/strolch/model/Locator.java b/src/main/java/li/strolch/model/Locator.java
index 43ee86a12..31f50528c 100644
--- a/src/main/java/li/strolch/model/Locator.java
+++ b/src/main/java/li/strolch/model/Locator.java
@@ -15,7 +15,6 @@
*/
package li.strolch.model;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -27,8 +26,9 @@ import ch.eitchnet.utils.helper.StringHelper;
/**
*
- * The {@link Locator} is used to fully qualify the location of an object in the model. It consists of a {@link List} of
- * Strings which starting from the first value, defining the root, with the last item defining the objects id.
+ * The {@link Locator} is an immutable object and is used to fully qualify the location of an object in the model. It
+ * consists of a {@link List} of Strings which starting from the first value, defining the root, with the last item
+ * defining the objects id.
*
*
*
@@ -112,6 +112,15 @@ public class Locator {
this.pathElements = Collections.unmodifiableList(fullPath);
}
+ /**
+ * Returns the immutable list of path elements making up this locator
+ *
+ * @return the pathElements
+ */
+ public List getPathElements() {
+ return this.pathElements;
+ }
+
/**
* Returns the number of elements which this {@link Locator} contains
*
@@ -185,12 +194,6 @@ public class Locator {
* if the path elements does not contain at least two items
*/
private String formatPath(List pathElements) throws StrolchException {
- if (pathElements.isEmpty()) {
- String msg = "A Path always consists of at least 1 element: {0}"; //$NON-NLS-1$
- msg = MessageFormat.format(msg, pathElements);
- throw new StrolchException(msg);
- }
-
StringBuilder sb = new StringBuilder();
Iterator iter = pathElements.iterator();
@@ -229,6 +232,17 @@ public class Locator {
return true;
}
+ /**
+ * Instantiates a new immutable {@link Locator} instance from the given string
+ *
+ * @param locatorPath
+ * the path from which to instantiate the locator
+ * @return the immutable {@link Locator} instance
+ */
+ public static Locator valueOf(String locatorPath) {
+ return new Locator(locatorPath);
+ }
+
/**
* {@link LocatorBuilder} is used to build {@link Locator}s where a deep hierarchy is to be created. The
* {@link #append(String)} method returns itself for chain building
@@ -270,11 +284,13 @@ public class Locator {
}
/**
- * Creates a {@link Locator} instance with the current elements
+ * Creates an immutable {@link Locator} instance with the current elements
*
* @return a new {@link Locator} instance
*/
public Locator build() {
+ if (this.pathElements.isEmpty())
+ throw new StrolchException("The path elements must contain at least 1 item"); //$NON-NLS-1$
return new Locator(this.pathElements);
}
}
diff --git a/src/main/java/li/strolch/model/ParameterizedElement.java b/src/main/java/li/strolch/model/ParameterizedElement.java
index cf25546dd..3db4eab35 100644
--- a/src/main/java/li/strolch/model/ParameterizedElement.java
+++ b/src/main/java/li/strolch/model/ParameterizedElement.java
@@ -192,7 +192,7 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
@Override
public void fillLocator(LocatorBuilder lb) {
- lb.append(Tags.PARAMETERIZED_ELEMENT).append(this.id);
+ lb.append(this.id);
}
@Override
diff --git a/src/main/java/li/strolch/model/parameter/AbstractParameter.java b/src/main/java/li/strolch/model/parameter/AbstractParameter.java
index cdb6c558c..fc80bb6fa 100644
--- a/src/main/java/li/strolch/model/parameter/AbstractParameter.java
+++ b/src/main/java/li/strolch/model/parameter/AbstractParameter.java
@@ -166,7 +166,7 @@ public abstract class AbstractParameter extends AbstractStrolchElement implem
@Override
protected void fillLocator(LocatorBuilder locatorBuilder) {
- locatorBuilder.append(Tags.PARAMETER).append(this.id);
+ locatorBuilder.append(this.id);
}
@Override