Class SharedStringBuilder
- java.lang.Object
-
- org.apache.myfaces.core.api.shared.lang.SharedStringBuilder
-
public class SharedStringBuilder extends Object
This gets a single FacesContext-local shared stringbuilder instance, each time you call _getSharedStringBuilder it sets the length of the stringBuilder instance to 0.
This allows you to use the same StringBuilder instance over and over. You must call toString on the instance before calling _getSharedStringBuilder again.
Example that worksStringBuilder sb1 = _getSharedStringBuilder(); sb1.append(a).append(b); String c = sb1.toString(); StringBuilder sb2 = _getSharedStringBuilder(); sb2.append(b).append(a); String d = sb2.toString();
Example that doesn't work, you must call toString on sb1 before calling _getSharedStringBuilder again.StringBuilder sb1 = _getSharedStringBuilder(); StringBuilder sb2 = _getSharedStringBuilder(); sb1.append(a).append(b); String c = sb1.toString(); sb2.append(b).append(a); String d = sb2.toString();
-
-
Constructor Summary
Constructors Constructor Description SharedStringBuilder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringBuilder
get(FacesContext facesContext, String stringBuilderKey)
static StringBuilder
get(FacesContext facesContext, String stringBuilderKey, int initialSize)
static StringBuilder
get(FacesContext facesContext, String stringBuilderKey, String initialText)
static StringBuilder
get(String stringBuilderKey)
static StringBuilder
get(String stringBuilderKey, String initialText)
-
-
-
Method Detail
-
get
public static StringBuilder get(String stringBuilderKey)
-
get
public static StringBuilder get(String stringBuilderKey, String initialText)
-
get
public static StringBuilder get(FacesContext facesContext, String stringBuilderKey)
-
get
public static StringBuilder get(FacesContext facesContext, String stringBuilderKey, String initialText)
-
get
public static StringBuilder get(FacesContext facesContext, String stringBuilderKey, int initialSize)
-
-