TYPE = File.class;
- private TreePropertiesIterator(final String prefix) {
- entries = properties.entrySet().iterator();
- this.prefix = prefix;
+ /**
+ *
+ * Getter for the field suffix.
+ *
+ *
+ * @return a {@link java.lang.String} object.
+ */
+ @Override
+ public final String getSuffix() {
+ return SUFFIX;
}
- // After this call, the next element is determined, or the child
- // iterator has next
-
+ /**
+ *
+ * Getter for the field type.
+ *
+ *
+ * @return a {@link java.lang.Class} object.
+ */
@Override
- public boolean hasNext() {
- if (next != null) {
- return true;
- } else if (child != null && child.hasNext()) {
- return true;
- } else if (entries.hasNext()) {
- Entry entry = entries.next();
- final String[] parts = entry.getKey().split("--");
- final Class> cls;
- final Object value = entry.getValue();
+ public final Class getType() {
+ return TYPE;
+ }
- if (parts.length == 1) {
- cls = String.class;
- } else if (parts[1].equals(TRANSPARENT)) {
- child = ((TreeProperties) entry.getValue()).iterator(prefix);
- // recursive, for the case that the child iterator is empty
- return hasNext();
- } else if (parts[1].equals(TreeProperties.CHILD)) {
- child = ((TreeProperties) entry.getValue()).iterator(prefix + parts[0] + "/");
- // recursive, for the case that the child iterator is empty
- return hasNext();
+ /** {@inheritDoc} */
+ @Override
+ public final File toObject(final TreeProperties p, final String s) {
+ String path = getPath(s);
+ File f = new File(path);
+ if (f.isAbsolute()) {
+ return f;
+ } else {
+ return new File(p.getPath(), path);
+ }
+ }
+
+ /**
+ * Returns a path path from a property value. Three substitutions are
+ * applied:
+ *
+ * - A "~/" or "~\" at the beginning is replaced with the user's home
+ * directory
+ * - A "$$" anywhere is replaced with a single "$"
+ * - A "${*}", where * is any string without "}", is replaced by
+ *
+ * @param s a {@link java.lang.String} object.
+ * @return a {@link java.lang.String} object.
+ * {@link System#getProperty(String)}
+ *
+ */
+ public static String getPath(String s) {
+ if (s.startsWith("~/")) {
+ s = System.getProperty("user.home") + "/" + s.substring(2);
+ } else if (s.startsWith("~\\")) {
+ s = System.getProperty("user.home") + "\\" + s.substring(2);
+ }
+ Matcher m = Pattern.compile("\\$\\$|\\$\\{([^\\}]*)\\}").matcher(s);
+ StringBuffer result = new StringBuffer();
+ while (m.find()) {
+ if (m.group().equals("$$")) {
+ m.appendReplacement(result, Matcher.quoteReplacement("$"));
} else {
- // class is determined by the content type
- PropertyType> t = instanceSuffixes.get(parts[1]);
- cls = t.getType();
+ m.appendReplacement(result, Matcher.quoteReplacement(System.getProperty(m.group(1))));
}
- next = new PropertyElement() {
-
- @Override
- public String getKey() {
- return prefix + parts[0];
- }
-
- @Override
- public Class> getType() {
- return cls;
- }
-
- @Override
- public Object getValue() {
- return value;
- }
-
- @Override
- public void setValue(final String value) {
- }
- };
- return true;
- } else {
- return false;
}
- }
-
- @Override
- public PropertyElement next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- } else if (next != null) {
- PropertyElement next = this.next;
- this.next = null;
- return next;
- } else {
- return child.next();
- }
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
+ m.appendTail(result);
+ return result.toString();
}
}
}
diff --git a/src/main/java/tree/properties/PropertyElement.java b/src/main/java/tree/properties/PropertyElement.java
deleted file mode 100644
index 4693148c7f2..00000000000
--- a/src/main/java/tree/properties/PropertyElement.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2009 Clemens Koza
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package tree.properties;
-
-/**
- * The class PropertyElement.
- *
- * @author Clemens Koza
- * @version V0.0 19.08.2009
- */
-public interface PropertyElement {
- /**
- * Returns the key of the property in the TreeProperties.
- *
- * @return a {@link java.lang.String} object.
- */
- String getKey();
-
- /**
- * Returns the type of the element.
- *
- * @return a {@link java.lang.Class} object.
- */
- Class> getType();
-
- /**
- * Returns the value of the element.
- *
- * @return a {@link java.lang.Object} object.
- */
- Object getValue();
-
- /**
- * Sets the property value as a string.
- *
- * @param value
- * a {@link java.lang.String} object.
- */
- void setValue(String value);
-}
diff --git a/src/main/java/tree/properties/PropertyType.java b/src/main/java/tree/properties/PropertyType.java
deleted file mode 100644
index 3d483ba4618..00000000000
--- a/src/main/java/tree/properties/PropertyType.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2009 Clemens Koza
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package tree.properties;
-
-/**
- * PropertyTypeHandler.java
- *
- * Created on 19.08.2009
- *
- * @param the generic type
- */
-
-/**
- * The class PropertyType. A property type is used to process special, suffixed
- * entries in a {@link TreeProperties} ' properties-file
- *
- * @author Clemens Koza
- * @version V0.0 19.08.2009
- *
- * @param
- *
- */
-public interface PropertyType {
- /**
- * The suffix, not including "--", that identifies this content type.
- *
- * @return a {@link java.lang.String} object.
- */
- String getSuffix();
-
- /**
- * The class that identifies this content type.
- *
- * @return a {@link java.lang.Class} object.
- */
- Class getType();
-
- /**
- * Returns an object for the specified value, in the context of a
- * TreeProperties.
- *
- * @param p
- * a {@link tree.properties.TreeProperties} object.
- * @param s
- * a {@link java.lang.String} object.
- * @return a T object.
- */
- T toObject(TreeProperties p, String s);
-}
diff --git a/src/main/java/tree/properties/package-info.java b/src/main/java/tree/properties/package-info.java
deleted file mode 100644
index f3b15e72e4a..00000000000
--- a/src/main/java/tree/properties/package-info.java
+++ /dev/null
@@ -1,2 +0,0 @@
-/** Forge Card Game. */
-package tree.properties;
diff --git a/src/main/java/tree/properties/types/FileType.java b/src/main/java/tree/properties/types/FileType.java
deleted file mode 100644
index bad2e7426fa..00000000000
--- a/src/main/java/tree/properties/types/FileType.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2009 Clemens Koza
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package tree.properties.types;
-
-import java.io.File;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import tree.properties.PropertyType;
-import tree.properties.TreeProperties;
-
-/**
- * The class FileType.
- *
- * @author Clemens Koza
- * @version V0.0 19.08.2009
- */
-public class FileType implements PropertyType {
- /** Constant suffix="file". */
- public static final String SUFFIX = "file";
- /** Constant type. */
- public static final Class TYPE = File.class;
-
- /**
- *
- * Getter for the field suffix.
- *
- *
- * @return a {@link java.lang.String} object.
- */
- @Override
- public final String getSuffix() {
- return SUFFIX;
- }
-
- /**
- *
- * Getter for the field type.
- *
- *
- * @return a {@link java.lang.Class} object.
- */
- @Override
- public final Class getType() {
- return TYPE;
- }
-
- /** {@inheritDoc} */
- @Override
- public final File toObject(final TreeProperties p, final String s) {
- String path = getPath(s);
- File f = new File(path);
- if (f.isAbsolute()) {
- return f;
- } else {
- return new File(p.getPath(), path);
- }
- }
-
- /**
- * Returns a path path from a property value. Three substitutions are
- * applied:
- *
- * - A "~/" or "~\" at the beginning is replaced with the user's home
- * directory
- * - A "$$" anywhere is replaced with a single "$"
- * - A "${*}", where * is any string without "}", is replaced by
- *
- * @param s a {@link java.lang.String} object.
- * @return a {@link java.lang.String} object.
- * {@link System#getProperty(String)}
- *
- */
- public static String getPath(String s) {
- if (s.startsWith("~/")) {
- s = System.getProperty("user.home") + "/" + s.substring(2);
- } else if (s.startsWith("~\\")) {
- s = System.getProperty("user.home") + "\\" + s.substring(2);
- }
- Matcher m = Pattern.compile("\\$\\$|\\$\\{([^\\}]*)\\}").matcher(s);
- StringBuffer result = new StringBuffer();
- while (m.find()) {
- if (m.group().equals("$$")) {
- m.appendReplacement(result, Matcher.quoteReplacement("$"));
- } else {
- m.appendReplacement(result, Matcher.quoteReplacement(System.getProperty(m.group(1))));
- }
- }
- m.appendTail(result);
- return result.toString();
- }
-}
diff --git a/src/main/java/tree/properties/types/package-info.java b/src/main/java/tree/properties/types/package-info.java
deleted file mode 100644
index a72843489d1..00000000000
--- a/src/main/java/tree/properties/types/package-info.java
+++ /dev/null
@@ -1,2 +0,0 @@
-/** Forge Card Game. */
-package tree.properties.types;