diff --git a/source/net/sourceforge/filebot/format/AssociativeScriptObject.java b/source/net/sourceforge/filebot/format/AssociativeScriptObject.java index 7888d45c..d8e53ac2 100644 --- a/source/net/sourceforge/filebot/format/AssociativeScriptObject.java +++ b/source/net/sourceforge/filebot/format/AssociativeScriptObject.java @@ -109,9 +109,8 @@ public class AssociativeScriptObject implements Scriptable { /** * Returns the string value of this object. */ - @SuppressWarnings("unchecked") @Override - public Object getDefaultValue(Class typeHint) { + public Object getDefaultValue(Class typeHint) { return this.toString(); } diff --git a/source/net/sourceforge/filebot/format/ExpressionFormat.global.js b/source/net/sourceforge/filebot/format/ExpressionFormat.global.js index 159cd18e..d1d76593 100644 --- a/source/net/sourceforge/filebot/format/ExpressionFormat.global.js +++ b/source/net/sourceforge/filebot/format/ExpressionFormat.global.js @@ -1,5 +1,7 @@ /** - * Convenience method to pad strings or numbers with given characters ('0' by default) + * Pad strings or numbers with given characters ('0' by default). + * + * e.g. "1" -> "01" */ String.prototype.pad = Number.prototype.pad = function(length, padding) { var s = this.toString(); @@ -16,8 +18,20 @@ String.prototype.pad = Number.prototype.pad = function(length, padding) { /** - * Convenience method to replace space characters with a given characters + * Replace space characters with a given characters. + * + * e.g. "Doctor Who" -> "Doctor_Who" */ String.prototype.space = function(replacement) { return this.replace(/\s/g, replacement); } + + +/** + * Remove trailing parenthesis including any leading whitespace. + * + * e.g. "Doctor Who (2005)" -> "Doctor Who" + */ +String.prototype.removeTrailingBraces = function() { + return this.replace(/\s*\([^\)]*\)$/, ""); +} diff --git a/source/net/sourceforge/filebot/format/ExpressionFormat.java b/source/net/sourceforge/filebot/format/ExpressionFormat.java index 360dff14..a6fbe3f2 100644 --- a/source/net/sourceforge/filebot/format/ExpressionFormat.java +++ b/source/net/sourceforge/filebot/format/ExpressionFormat.java @@ -18,7 +18,6 @@ import java.security.PrivilegedExceptionAction; import java.security.ProtectionDomain; import java.text.FieldPosition; import java.text.Format; -import java.text.NumberFormat; import java.text.ParsePosition; import java.util.ArrayList; import java.util.List; @@ -126,11 +125,6 @@ public class ExpressionFormat extends Format { Object value = ((CompiledScript) snipped).eval(context); if (value != null) { - if (value instanceof Double && value.equals(Math.floor((Double) value))) { - // value is really an integer, not a decimal (number literals -1, 0 and 1 are interpreted as decimal by rhino) - value = NumberFormat.getIntegerInstance().format(value); - } - sb.append(value); } } catch (ScriptException e) {