checkstyle

This commit is contained in:
jendave
2011-09-09 16:07:55 +00:00
parent 5aff635eb8
commit fc7b732dea

View File

@@ -22,18 +22,18 @@ import java.util.regex.Pattern;
* @version V0.0 19.08.2009 * @version V0.0 19.08.2009
*/ */
public class FileType implements PropertyType<File> { public class FileType implements PropertyType<File> {
/** Constant <code>suffix="file"</code> */ /** Constant <code>suffix="file"</code>. */
public static final String suffix = "file"; public static final String SUFFIX = "file";
/** Constant <code>type</code> */ /** Constant <code>type</code>. */
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 String getSuffix() { public final String getSuffix() {
return suffix; return SUFFIX;
} }
/** /**
@@ -41,17 +41,20 @@ public class FileType implements PropertyType<File> {
* *
* @return a {@link java.lang.Class} object. * @return a {@link java.lang.Class} object.
*/ */
public Class<File> getType() { public final Class<File> getType() {
return type; return TYPE;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
public File toObject(TreeProperties p, String s) { public final File toObject(final TreeProperties p, final String s) {
String path = getPath(s); String path = getPath(s);
File f = new File(path); File f = new File(path);
if (f.isAbsolute()) return f; if (f.isAbsolute()) {
else return new File(p.getPath(), path); return f;
} else {
return new File(p.getPath(), path);
}
} }
/** /**
@@ -66,13 +69,19 @@ public class FileType implements PropertyType<File> {
* @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) {
if (s.startsWith("~/")) s = System.getProperty("user.home") + "/" + s.substring(2); if (s.startsWith("~/")) {
else if (s.startsWith("~\\")) s = System.getProperty("user.home") + "\\" + s.substring(2); 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); Matcher m = Pattern.compile("\\$\\$|\\$\\{([^\\}]*)\\}").matcher(s);
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
while (m.find()) { while (m.find()) {
if (m.group().equals("$$")) m.appendReplacement(result, Matcher.quoteReplacement("$")); if (m.group().equals("$$")) {
else m.appendReplacement(result, Matcher.quoteReplacement(System.getProperty(m.group(1)))); m.appendReplacement(result, Matcher.quoteReplacement("$"));
} else {
m.appendReplacement(result, Matcher.quoteReplacement(System.getProperty(m.group(1))));
}
} }
m.appendTail(result); m.appendTail(result);
return result.toString(); return result.toString();