String expandStringProperties(String value,int lineno) throws ConfigurationException {
  int p=value.indexOf("${",0);
  if (p == -1) {
    return value;
  }
  int max=value.length();
  StringBuffer sb=new StringBuffer(max);
  int i=0;
  while (true) {
    if (p > i) {
      sb.append(value.substring(i,p));
      i=p;
    }
    int pe=value.indexOf('}',p + 2);
    if (pe == -1) {
      sb.append(value.substring(p,max));
      break;
    }
    String prop=value.substring(p + 2,pe);
    if (prop.equals("/")) {
      sb.append(File.separatorChar);
    }
 else {
      try {
        String val=prop.length() == 0 ? null : System.getProperty(prop);
        if (val != null) {
          sb.append(val);
        }
 else {
          oops("problem expanding system property '" + prop + "'",lineno,override);
        }
      }
 catch (      SecurityException e) {
        oops("problem expanding system property '" + prop + "'",lineno,override,e);
      }
    }
    i=pe + 1;
    p=value.indexOf("${",i);
    if (p == -1) {
      if (i < max) {
        sb.append(value.substring(i,max));
      }
      break;
    }
  }
  return sb.toString();
}

String expandStringProperties ( String value , int lineno ) throws ConfigurationException { int p = value . indexOf ( "${" , 0 ) ; if ( p == - 1 ) { return value ; } int max = value . length ( ) ; StringBuffer sb = new StringBuffer ( max ) ; int i = 0 ; while ( true ) { if ( p > i ) { sb . append ( value . substring ( i , p ) ) ; i = p ; } int pe = value . indexOf ( '}' , p + 2 ) ; if ( pe == - 1 ) { sb . append ( value . substring ( p , max ) ) ; break ; } String prop = value . substring ( p + 2 , pe ) ; if ( prop . equals ( "/" ) ) { sb . append ( File . separatorChar ) ; } else { try { String val = prop . length ( ) == 0 ? null : System . getProperty ( prop ) ; if ( val != null ) { sb . append ( val ) ; } else { oops ( "problem expanding system property '" + prop + "'" , lineno , override ) ; } } catch ( SecurityException e ) { oops ( "problem expanding system property '" + prop + "'" , lineno , override , e ) ; } } i = pe + 1 ; p = value . indexOf ( "${" , i ) ; if ( p == - 1 ) { if ( i < max ) { sb . append ( value . substring ( i , max ) ) ; } break ; } } return sb . toString ( ) ; }
expands properties embedded in a string with $ { some . property . name } . also treats $ { / } as $ { file . separator } .
