checkstyle

This commit is contained in:
jendave
2011-10-25 15:44:22 +00:00
parent 5f3b16f4d0
commit c46a032795
4 changed files with 181 additions and 137 deletions

View File

@@ -6,39 +6,39 @@
package tree.properties; package tree.properties;
/** /**
* The class PropertyElement. * The class PropertyElement.
* *
* @author Clemens Koza * @author Clemens Koza
* @version V0.0 19.08.2009 * @version V0.0 19.08.2009
*/ */
public interface PropertyElement { public interface PropertyElement {
/** /**
* Returns the key of the property in the TreeProperties. * Returns the key of the property in the TreeProperties.
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
String getKey(); String getKey();
/** /**
* Returns the type of the element. * Returns the type of the element.
* *
* @return a {@link java.lang.Class} object. * @return a {@link java.lang.Class} object.
*/ */
Class<?> getType(); Class<?> getType();
/** /**
* Returns the value of the element. * Returns the value of the element.
* *
* @return a {@link java.lang.Object} object. * @return a {@link java.lang.Object} object.
*/ */
Object getValue(); Object getValue();
/** /**
* Sets the property value as a string. * Sets the property value as a string.
* *
* @param value a {@link java.lang.String} object. * @param value
* a {@link java.lang.String} object.
*/ */
void setValue(String value); void setValue(String value);
} }

View File

@@ -1,43 +1,44 @@
package tree.properties; package tree.properties;
/** /**
* PropertyTypeHandler.java * PropertyTypeHandler.java
* *
* Created on 19.08.2009 * Created on 19.08.2009
*/ */
/** /**
* The class PropertyType. A property type is used to process special, suffixed entries in a {@link TreeProperties} * The class PropertyType. A property type is used to process special, suffixed
* ' properties-file * entries in a {@link TreeProperties} ' properties-file
* *
* @author Clemens Koza * @author Clemens Koza
* @version V0.0 19.08.2009 * @version V0.0 19.08.2009
* *
* @param <T> * @param <T>
* *
*/ */
public interface PropertyType<T> { public interface PropertyType<T> {
/** /**
* The suffix, not including "--", that identifies this content type. * The suffix, not including "--", that identifies this content type.
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
String getSuffix(); String getSuffix();
/** /**
* The class that identifies this content type. * The class that identifies this content type.
* *
* @return a {@link java.lang.Class} object. * @return a {@link java.lang.Class} object.
*/ */
Class<T> getType(); Class<T> getType();
/** /**
* Returns an object for the specified value, in the context of a TreeProperties. * Returns an object for the specified value, in the context of a
* * TreeProperties.
* @param p a {@link treeProperties.TreeProperties} object. *
* @param s a {@link java.lang.String} object. * @param p
* a {@link treeProperties.TreeProperties} object.
* @param s
* a {@link java.lang.String} object.
* @return a T object. * @return a T object.
*/ */
T toObject(TreeProperties p, String s); T toObject(TreeProperties p, String s);

View File

@@ -1,13 +1,11 @@
package tree.properties; package tree.properties;
/** /**
* TreeProperties.java * TreeProperties.java
* *
* Created on 19.08.2009 * Created on 19.08.2009
*/ */
import static java.lang.String.format; import static java.lang.String.format;
import static java.util.Collections.unmodifiableList; import static java.util.Collections.unmodifiableList;
@@ -28,24 +26,27 @@ import java.util.Set;
import tree.properties.types.FileType; import tree.properties.types.FileType;
/** /**
* The class TreeProperties. This class allows for a tree-like structure of properties-files. This class lays some * The class TreeProperties. This class allows for a tree-like structure of
* restrictions on the keys used in properties-files: * properties-files. This class lays some restrictions on the keys used in
* properties-files:
* <ul> * <ul>
* <li>The use of "--" is forbidden</li> * <li>The use of "--" is forbidden</li>
* <li>The suffixes "--properties" and "--transparent-properties" are reserved for specifying additional * <li>The suffixes "--properties" and "--transparent-properties" are reserved
* properties-files in the tree (relative paths are relative to the properties-file where they are referenced)</li> * for specifying additional properties-files in the tree (relative paths are
* <li>Other suffixes are used by {@link PropertyType}s. PropertyTypes are registered or unregistered using * relative to the properties-file where they are referenced)</li>
* {@link #addType(PropertyType)} or {@link #removeType(PropertyType)}.</li> * <li>Other suffixes are used by {@link PropertyType}s. PropertyTypes are
* registered or unregistered using {@link #addType(PropertyType)} or
* {@link #removeType(PropertyType)}.</li>
* </ul> * </ul>
* Take a look at these files: * Take a look at these files:
* <p/> * <p/>
*
* <pre> * <pre>
* #root.properties * #root.properties
* title=directions * title=directions
* icons--properties=img/icons.properties * icons--properties=img/icons.properties
* *
* #img/icons.properties * #img/icons.properties
* left--file=left.jpg * left--file=left.jpg
* right--file=right.jpg * right--file=right.jpg
@@ -53,7 +54,7 @@ import tree.properties.types.FileType;
* down--file=down.jpg * down--file=down.jpg
* #note that the path does not contain &quot;img/&quot; * #note that the path does not contain &quot;img/&quot;
* size--transparent-properties=size.properties * size--transparent-properties=size.properties
* *
* #img/size.properties * #img/size.properties
* width=20 * width=20
* height=20 * height=20
@@ -61,6 +62,7 @@ import tree.properties.types.FileType;
* <p/> * <p/>
* These properties are retrieved with * These properties are retrieved with
* <p/> * <p/>
*
* <pre> * <pre>
* getProperty(&quot;title&quot;) //directions * getProperty(&quot;title&quot;) //directions
* getFile(&quot;icons/left&quot;) //img/left.jpg * getFile(&quot;icons/left&quot;) //img/left.jpg
@@ -71,15 +73,17 @@ import tree.properties.types.FileType;
* getProperty(&quot;icons/height&quot;) //20 * getProperty(&quot;icons/height&quot;) //20
* </pre> * </pre>
* <p/> * <p/>
* As you can see, a properties file included with "--transparent-properties" hides its existence from the user. A * As you can see, a properties file included with "--transparent-properties"
* file included with "--properties" is not hidden. The child properties are accessible as if their keys were * hides its existence from the user. A file included with "--properties" is not
* prepended with the parent key, separated by a slash. * hidden. The child properties are accessible as if their keys were prepended
* with the parent key, separated by a slash.
* <p/> * <p/>
* Note that --file, --properties and --transparent-properties entries will be relative to the included file, even * Note that --file, --properties and --transparent-properties entries will be
* if the properties file is transparent. * relative to the included file, even if the properties file is transparent.
* <p/> * <p/>
* Also, the TreeProperties can be retrieved: * Also, the TreeProperties can be retrieved:
* <p/> * <p/>
*
* <pre> * <pre>
* getChildProperties(&quot;icons&quot;) * getChildProperties(&quot;icons&quot;)
* getTransparentProperties(&quot;icons/size&quot;) * getTransparentProperties(&quot;icons/size&quot;)
@@ -87,7 +91,7 @@ import tree.properties.types.FileType;
* <p/> * <p/>
* <p/> * <p/>
* TODO add edit & save support * TODO add edit & save support
* *
* @author Clemens Koza * @author Clemens Koza
* @version V0.0 19.08.2009 * @version V0.0 19.08.2009
* @see Properties * @see Properties
@@ -119,9 +123,12 @@ public class TreeProperties implements Iterable<PropertyElement> {
private List<Exception> exceptions; private List<Exception> exceptions;
/** /**
* <p>addType.</p> * <p>
* * addType.
* @param type a {@link treeProperties.PropertyType} object. * </p>
*
* @param type
* a {@link treeProperties.PropertyType} object.
*/ */
public static void addType(final PropertyType<?> type) { public static void addType(final PropertyType<?> type) {
TYPES.put(type.getType(), type); TYPES.put(type.getType(), type);
@@ -129,9 +136,12 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
/** /**
* <p>removeType.</p> * <p>
* * removeType.
* @param type a {@link treeProperties.PropertyType} object. * </p>
*
* @param type
* a {@link treeProperties.PropertyType} object.
*/ */
public static void removeType(final PropertyType<?> type) { public static void removeType(final PropertyType<?> type) {
TYPES.remove(type.getType()); TYPES.remove(type.getType());
@@ -139,34 +149,44 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
/** /**
* Delegate to {@link #TreeProperties(File)} with a new {@link File#File(String)}. * Delegate to {@link #TreeProperties(File)} with a new
* * {@link File#File(String)}.
* @param f a {@link java.lang.String} object. *
* @throws java.io.IOException if any. * @param f
* a {@link java.lang.String} object.
* @throws java.io.IOException
* if any.
*/ */
public TreeProperties(final String f) throws IOException { public TreeProperties(final String f) throws IOException {
this(new File(f)); this(new File(f));
} }
/** /**
* Delegate to {@link #TreeProperties(File)} with a new {@link File#File(File, String)}. * Delegate to {@link #TreeProperties(File)} with a new
* * {@link File#File(File, String)}.
* @param parent a {@link java.io.File} object. *
* @param f a {@link java.lang.String} object. * @param parent
* @throws java.io.IOException if any. * a {@link java.io.File} object.
* @param f
* a {@link java.lang.String} object.
* @throws java.io.IOException
* if any.
*/ */
public TreeProperties(final File parent, final String f) throws IOException { public TreeProperties(final File parent, final String f) throws IOException {
this(new File(parent, f)); this(new File(parent, f));
} }
/** /**
* The constructor is forgiving in the way that Exceptions are not directly forwarded. The only fatal exception * The constructor is forgiving in the way that Exceptions are not directly
* is if the parameter is null or not found. Instead, the rest of the properties are processed, so that the * forwarded. The only fatal exception is if the parameter is null or not
* erroneous properties are the only ones not present in this TreeProperties. Afterwards, the exceptions can be * found. Instead, the rest of the properties are processed, so that the
* accessed. * erroneous properties are the only ones not present in this
* * TreeProperties. Afterwards, the exceptions can be accessed.
* @param f a {@link java.io.File} object. *
* @throws java.io.IOException if any. * @param f
* a {@link java.io.File} object.
* @throws java.io.IOException
* if any.
*/ */
public TreeProperties(final File f) throws IOException { public TreeProperties(final File f) throws IOException {
if (f == null) { if (f == null) {
@@ -177,9 +197,9 @@ public class TreeProperties implements Iterable<PropertyElement> {
instanceSuffixes = new HashMap<String, PropertyType<?>>(SUFFIXES); instanceSuffixes = new HashMap<String, PropertyType<?>>(SUFFIXES);
Properties p = new Properties(); Properties p = new Properties();
// BufferedReader r = new BufferedReader(new FileReader(f)); // BufferedReader r = new BufferedReader(new FileReader(f));
// p.load(r); // p.load(r);
// r.close(); // r.close();
BufferedInputStream is = new BufferedInputStream(new FileInputStream(f)); BufferedInputStream is = new BufferedInputStream(new FileInputStream(f));
p.load(is); p.load(is);
is.close(); is.close();
@@ -195,10 +215,10 @@ public class TreeProperties implements Iterable<PropertyElement> {
String[] parts = key.split("--", 2); String[] parts = key.split("--", 2);
Object result; Object result;
if (parts.length == 1) { if (parts.length == 1) {
//Regular // Regular
result = value; result = value;
} else { } else {
//suffix // suffix
if (parts[1].equals(TRANSPARENT) || parts[1].equals(CHILD)) { if (parts[1].equals(TRANSPARENT) || parts[1].equals(CHILD)) {
TreeProperties child = new TreeProperties(path, FileType.getPath(value)); TreeProperties child = new TreeProperties(path, FileType.getPath(value));
exceptions.addAll(child.exceptions); exceptions.addAll(child.exceptions);
@@ -213,15 +233,16 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
properties.put(key, result); properties.put(key, result);
} catch (Exception ex) { } catch (Exception ex) {
exceptions.add(new Exception(format("File '%s', Property '%s':%n %s", f, key, ex.getMessage()), exceptions.add(new Exception(format("File '%s', Property '%s':%n %s", f, key, ex.getMessage()), ex
ex.getCause())); .getCause()));
} }
} }
} }
/** /**
* Returns the exceptions that were thrown while creating the tree properties. * Returns the exceptions that were thrown while creating the tree
* * properties.
*
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public final List<Exception> getExceptions() { public final List<Exception> getExceptions() {
@@ -229,10 +250,11 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
/** /**
* If exceptions occurred during construction, this method throws an IOException that combines the messages of * If exceptions occurred during construction, this method throws an
* those exceptions. * IOException that combines the messages of those exceptions.
* *
* @throws java.io.IOException if any. * @throws java.io.IOException
* if any.
*/ */
public final void rethrow() throws IOException { public final void rethrow() throws IOException {
if (exceptions.isEmpty()) { if (exceptions.isEmpty()) {
@@ -248,7 +270,7 @@ public class TreeProperties implements Iterable<PropertyElement> {
/** /**
* Returns the parent directory of this TreeProperties. * Returns the parent directory of this TreeProperties.
* *
* @return a {@link java.io.File} object. * @return a {@link java.io.File} object.
*/ */
public final File getPath() { public final File getPath() {
@@ -256,10 +278,12 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
/** /**
* Checks if the key is valid for a query and throws an {@link IllegalArgumentException} if not. Slashes are * Checks if the key is valid for a query and throws an
* allowed in this method, but suffixes are not * {@link IllegalArgumentException} if not. Slashes are allowed in this
* * method, but suffixes are not
* @param key a {@link java.lang.String} object. *
* @param key
* a {@link java.lang.String} object.
*/ */
private void checkQueryKey(final String key) { private void checkQueryKey(final String key) {
if (key.contains("--")) { if (key.contains("--")) {
@@ -269,8 +293,9 @@ public class TreeProperties implements Iterable<PropertyElement> {
/** /**
* Retrieves the string property for the given key. * Retrieves the string property for the given key.
* *
* @param key a {@link java.lang.String} object. * @param key
* a {@link java.lang.String} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getProperty(final String key) { public final String getProperty(final String key) {
@@ -279,8 +304,9 @@ public class TreeProperties implements Iterable<PropertyElement> {
/** /**
* Convenience for {@code getProperty(key, File.class)}. * Convenience for {@code getProperty(key, File.class)}.
* *
* @param key a {@link java.lang.String} object. * @param key
* a {@link java.lang.String} object.
* @return a {@link java.io.File} object. * @return a {@link java.io.File} object.
*/ */
public final File getFile(final String key) { public final File getFile(final String key) {
@@ -288,9 +314,11 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
/** /**
* Retrieves the child properties for the given key. Transparent properties can't be retrieved this way. * Retrieves the child properties for the given key. Transparent properties
* * can't be retrieved this way.
* @param key a {@link java.lang.String} object. *
* @param key
* a {@link java.lang.String} object.
* @return a {@link treeProperties.TreeProperties} object. * @return a {@link treeProperties.TreeProperties} object.
*/ */
public final TreeProperties getChildProperties(final String key) { public final TreeProperties getChildProperties(final String key) {
@@ -299,8 +327,9 @@ public class TreeProperties implements Iterable<PropertyElement> {
/** /**
* Retrieves the child properties for the given key. * Retrieves the child properties for the given key.
* *
* @param key a {@link java.lang.String} object. * @param key
* a {@link java.lang.String} object.
* @return a {@link treeProperties.TreeProperties} object. * @return a {@link treeProperties.TreeProperties} object.
*/ */
public final TreeProperties getTransparentProperties(final String key) { public final TreeProperties getTransparentProperties(final String key) {
@@ -308,12 +337,16 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
/** /**
* Returns a property of the given type. This does not work to retrieve tree properties. * Returns a property of the given type. This does not work to retrieve tree
* * properties.
* @param key a {@link java.lang.String} object. *
* @param cls a {@link java.lang.Class} object. * @param key
* a {@link java.lang.String} object.
* @param cls
* a {@link java.lang.Class} object.
* @return a T object. * @return a T object.
* @param <T> a T object. * @param <T>
* a T object.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final <T> T getProperty(final String key, final Class<T> cls) { public final <T> T getProperty(final String key, final Class<T> cls) {
@@ -328,25 +361,30 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
/** /**
* <p>getProperty.</p> * <p>
* * getProperty.
* @param key a {@link java.lang.String} object. * </p>
* @param suffix a {@link java.lang.String} object. *
* @param top a boolean. * @param key
* a {@link java.lang.String} object.
* @param suffix
* a {@link java.lang.String} object.
* @param top
* a boolean.
* @return a {@link java.lang.Object} object. * @return a {@link java.lang.Object} object.
*/ */
private Object getProperty(final String key, final String suffix, final boolean top) { private Object getProperty(final String key, final String suffix, final boolean top) {
checkQueryKey(key); checkQueryKey(key);
//first, try the key in the current file, as if there were no slash // first, try the key in the current file, as if there were no slash
//No subpath - either directly in the properties... // No subpath - either directly in the properties...
Object result = properties.get(key + suffix); Object result = properties.get(key + suffix);
if (result != null) { if (result != null) {
return result; return result;
} }
//...or in a transparent properties // ...or in a transparent properties
//look for all --transparent-properties // look for all --transparent-properties
for (Entry<String, Object> entry : properties.entrySet()) { for (Entry<String, Object> entry : properties.entrySet()) {
if (entry.getKey().endsWith("--" + TRANSPARENT)) { if (entry.getKey().endsWith("--" + TRANSPARENT)) {
TreeProperties p = (TreeProperties) entry.getValue(); TreeProperties p = (TreeProperties) entry.getValue();
@@ -357,10 +395,10 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
} }
//if there is no immediate containment, try the children // if there is no immediate containment, try the children
//try every combination // try every combination
//for a/b/c, there could be a child "a/b--properties" that contains "c" // for a/b/c, there could be a child "a/b--properties" that contains "c"
//or "a--properties" with "b/c" // or "a--properties" with "b/c"
int index = -1; int index = -1;
while ((index = key.indexOf('/', index + 1)) != -1) { while ((index = key.indexOf('/', index + 1)) != -1) {
String first = key.substring(0, index), second = key.substring(index + 1); String first = key.substring(0, index), second = key.substring(index + 1);
@@ -376,16 +414,16 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
if (top) { if (top) {
Exception ex = new Exception("TreeProperties returns null for " + key + suffix); Exception ex = new Exception("TreeProperties returns null for " + key + suffix);
// ex.printStackTrace(); // ex.printStackTrace();
System.err.println(ex); System.err.println(ex);
} }
return null; return null;
} }
/** /**
* Returns an iterator over all the regular entries of this object. That means that transparent or child tree * Returns an iterator over all the regular entries of this object. That
* properties are not included. * means that transparent or child tree properties are not included.
* *
* @return a {@link java.util.Iterator} object. * @return a {@link java.util.Iterator} object.
*/ */
public final Iterator<PropertyElement> iterator() { public final Iterator<PropertyElement> iterator() {
@@ -393,10 +431,14 @@ public class TreeProperties implements Iterable<PropertyElement> {
}; };
/** /**
* <p>iterator.</p> * <p>
* * iterator.
* @param prefix a {@link java.lang.String} object. * </p>
* @return a {@link treeProperties.TreeProperties.TreePropertiesIterator} object. *
* @param prefix
* a {@link java.lang.String} object.
* @return a {@link treeProperties.TreeProperties.TreePropertiesIterator}
* object.
*/ */
private TreePropertiesIterator iterator(final String prefix) { private TreePropertiesIterator iterator(final String prefix) {
return new TreePropertiesIterator(prefix); return new TreePropertiesIterator(prefix);
@@ -413,7 +455,8 @@ public class TreeProperties implements Iterable<PropertyElement> {
this.prefix = prefix; this.prefix = prefix;
} }
//After this call, the next element is determined, or the child iterator has next // After this call, the next element is determined, or the child
// iterator has next
public boolean hasNext() { public boolean hasNext() {
if (next != null) { if (next != null) {
@@ -430,14 +473,14 @@ public class TreeProperties implements Iterable<PropertyElement> {
cls = String.class; cls = String.class;
} else if (parts[1].equals(TRANSPARENT)) { } else if (parts[1].equals(TRANSPARENT)) {
child = ((TreeProperties) entry.getValue()).iterator(prefix); child = ((TreeProperties) entry.getValue()).iterator(prefix);
//recursive, for the case that the child iterator is empty // recursive, for the case that the child iterator is empty
return hasNext(); return hasNext();
} else if (parts[1].equals(TreeProperties.CHILD)) { } else if (parts[1].equals(TreeProperties.CHILD)) {
child = ((TreeProperties) entry.getValue()).iterator(prefix + parts[0] + "/"); child = ((TreeProperties) entry.getValue()).iterator(prefix + parts[0] + "/");
//recursive, for the case that the child iterator is empty // recursive, for the case that the child iterator is empty
return hasNext(); return hasNext();
} else { } else {
//class is determined by the content type // class is determined by the content type
PropertyType<?> t = instanceSuffixes.get(parts[1]); PropertyType<?> t = instanceSuffixes.get(parts[1]);
cls = t.getType(); cls = t.getType();
} }
@@ -447,17 +490,14 @@ public class TreeProperties implements Iterable<PropertyElement> {
return prefix + parts[0]; return prefix + parts[0];
} }
public Class<?> getType() { public Class<?> getType() {
return cls; return cls;
} }
public Object getValue() { public Object getValue() {
return value; return value;
} }
public void setValue(final String value) { public void setValue(final String value) {
} }
}; };
@@ -467,7 +507,6 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
} }
public PropertyElement next() { public PropertyElement next() {
if (!hasNext()) { if (!hasNext()) {
throw new NoSuchElementException(); throw new NoSuchElementException();
@@ -480,7 +519,6 @@ public class TreeProperties implements Iterable<PropertyElement> {
} }
} }
public void remove() { public void remove() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@@ -6,18 +6,16 @@
package tree.properties.types; package tree.properties.types;
import tree.properties.PropertyType;
import tree.properties.TreeProperties;
import java.io.File; import java.io.File;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import tree.properties.PropertyType;
import tree.properties.TreeProperties;
/** /**
* The class FileType. * The class FileType.
* *
* @author Clemens Koza * @author Clemens Koza
* @version V0.0 19.08.2009 * @version V0.0 19.08.2009
*/ */
@@ -28,8 +26,10 @@ public class FileType implements PropertyType<File> {
public static final Class<File> TYPE = File.class; public static final Class<File> TYPE = File.class;
/** /**
* <p>Getter for the field <code>suffix</code>.</p> * <p>
* * Getter for the field <code>suffix</code>.
* </p>
*
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getSuffix() { public final String getSuffix() {
@@ -37,15 +37,16 @@ public class FileType implements PropertyType<File> {
} }
/** /**
* <p>Getter for the field <code>type</code>.</p> * <p>
* * Getter for the field <code>type</code>.
* </p>
*
* @return a {@link java.lang.Class} object. * @return a {@link java.lang.Class} object.
*/ */
public final Class<File> getType() { public final Class<File> getType() {
return TYPE; return TYPE;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
public final File toObject(final TreeProperties p, final String s) { public final File toObject(final TreeProperties p, final String s) {
String path = getPath(s); String path = getPath(s);
@@ -58,14 +59,18 @@ public class FileType implements PropertyType<File> {
} }
/** /**
* Returns a path path from a property value. Three substitutions are applied: * Returns a path path from a property value. Three substitutions are
* applied:
* <ul> * <ul>
* <li>A "~/" or "~\" at the beginning is replaced with the user's home directory</li> * <li>A "~/" or "~\" at the beginning is replaced with the user's home
* directory</li>
* <li>A "$$" anywhere is replaced with a single "$"</li> * <li>A "$$" anywhere is replaced with a single "$"</li>
* <li>A "${*}", where * is any string without "}", is replaced by {@link System#getProperty(String)}</li> * <li>A "${*}", where * is any string without "}", is replaced by
* {@link System#getProperty(String)}</li>
* </ul> * </ul>
* *
* @param s a {@link java.lang.String} object. * @param s
* a {@link java.lang.String} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public static String getPath(String s) { public static String getPath(String s) {