docs: public static StringBuilder replaceResources(StringBuilder sb, ResourceBundle reg, Map<String, Object> map, PropertyOwner propertyOwner, boolean systemProperties)
      {
      	boolean bDoubleBraces = false;
          int index = 0;
          while (index < sb.length())
          {
              int iStartBrace = sb.indexOf("{", index);
              if (iStartBrace == -1)
                  break;
              if (iStartBrace + 1 < sb.length())
              	if (sb.charAt(iStartBrace + 1) == '{')
          	{
              	bDoubleBraces = true;
              	index = iStartBrace + 2;
              	continue;
          	}
              int iEndBrace = sb.indexOf("}", iStartBrace);
              if (iEndBrace == -1)
                  break;
              String strKey = sb.substring(iStartBrace + 1, iEndBrace);
              if (iStartBrace > 0)
              	if (sb.charAt(iStartBrace - 1) == '$')
              		iStartBrace--;
              String string = null;
              if (map != null)
              	if (map.get(strKey) != null)
              		string = map.get(strKey).toString();
              if (reg != null)
                  if (string == null)
                      string = reg.getString(strKey);
              if (propertyOwner != null)
                  if (string == null)
                      string = propertyOwner.getProperty(strKey);
              if (string == null)
                  if (systemProperties)
                      try {
                          string = System.getProperty(strKey);
                      } catch (Exception e) { // Ignore (security) errors
                      }
              if (string == null)
                  string = strKey;    // Never
              sb.replace(iStartBrace, iEndBrace + 1, string);
              index = index + string.length();
          }
          if (bDoubleBraces)
          {
              index = 0;
              while (index < sb.length() - 1)
              {
              	index = sb.indexOf("{{", index);
              	if (index == -1)
              		break;
      			sb.replace(index, index + 2, "{");
              	index = sb.indexOf("}}", index);
              	if (index == -1)
              		break;
      			sb.replace(index, index + 2, "}");
              }
          }
          return sb;
      }