You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2009/02/09 12:55:08 UTC
svn commit: r742412 - in
/ofbiz/trunk/framework/base/src/org/ofbiz/base/util: MessageString.java
StringUtil.java
Author: jonesde
Date: Mon Feb 9 11:55:07 2009
New Revision: 742412
URL: http://svn.apache.org/viewvc?rev=742412&view=rev
Log:
A simple StringWrapper object that can be used to get around the general HTML auto-encoding now done in FTL rendered through the Screen Widget; just call the static method to wrap it and it will insert fine and the encoder will leave it alone
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java?rev=742412&r1=742411&r2=742412&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/MessageString.java Mon Feb 9 11:55:07 2009
@@ -18,19 +18,19 @@
*******************************************************************************/
package org.ofbiz.base.util;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;
-import java.io.Serializable;
/**
* Contains extra information about Messages
*
*/
+@SuppressWarnings("serial")
public class MessageString implements Serializable {
public static final String module = MessageString.class.getName();
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=742412&r1=742411&r2=742412&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java Mon Feb 9 11:55:07 2009
@@ -626,5 +626,41 @@
return sb.toString();
}
+
+ public static StringWrapper makeStringWrapper(String theString) {
+ if (theString == null) return null;
+ if (theString.length() == 0) return StringWrapper.EMPTY_STRING_WRAPPER;
+ return new StringWrapper(theString);
+ }
+
+ /**
+ * A super-lightweight object to wrap a String object. Mainly used with FTL templates
+ * to avoid the general HTML auto-encoding that is now done through the Screen Widget.
+ */
+ public static class StringWrapper {
+ public static final StringWrapper EMPTY_STRING_WRAPPER = new StringWrapper("");
+
+ protected String theString;
+ protected StringWrapper() { }
+ public StringWrapper(String theString) {
+ this.theString = theString;
+ }
+
+ /**
+ * Fairly simple method used for the plus (+) base concatenation in Groovy.
+ *
+ * @param value
+ * @return
+ */
+ public String plus(Object value) {
+ return this.theString + value;
+ }
+ /**
+ * @return The String this object wraps.
+ */
+ public String toString() {
+ return this.theString;
+ }
+ }
}