public StringFormatter(final String formatString){
  staticParts=new ArrayList<String>();
  parameterPositions=new ArrayList<String>();
  parameter=new HashMap<String,String>();
  String current=formatString;
  int index;
  boolean hasStart=false;
  do {
    if (hasStart) {
      index=current.indexOf(PARAMETER_END);
    }
 else {
      index=current.indexOf(PARAMETER_START);
    }
    if (index >= 0) {
      if (hasStart) {
        final String param=current.substring(PARAMETER_START.length(),index);
        current=current.substring(index + PARAMETER_END.length());
        parameter.put(param,"");
        parameterPositions.add(param);
      }
 else {
        final String s=current.substring(0,index);
        current=current.substring(index);
        staticParts.add(s);
      }
      hasStart=!hasStart;
    }
  }
 while (index >= 0);
  staticParts.add(current);
}

public StringFormatter ( final String formatString ) { staticParts = new ArrayList < String > ( ) ; parameterPositions = new ArrayList < String > ( ) ; parameter = new HashMap < String , String > ( ) ; String current = formatString ; int index ; boolean hasStart = false ; do { if ( hasStart ) { index = current . indexOf ( PARAMETER_END ) ; } else { index = current . indexOf ( PARAMETER_START ) ; } if ( index >= 0 ) { if ( hasStart ) { final String param = current . substring ( PARAMETER_START . length ( ) , index ) ; current = current . substring ( index + PARAMETER_END . length ( ) ) ; parameter . put ( param , "" ) ; parameterPositions . add ( param ) ; } else { final String s = current . substring ( 0 , index ) ; current = current . substring ( index ) ; staticParts . add ( s ) ; } hasStart = ! hasStart ; } } while ( index >= 0 ) ; staticParts . add ( current ) ; }
creates a new instance of stringformatter .
