Class 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 works
    
     StringBuilder 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();