コード例 #1
0
  /**
   * creates a String to be included in a .preperties file
   *
   * @param value default value to be included in the text
   * @return
   */
  public String toPropertyString(String value, boolean commentOutValue) {
    if (value == null) {
      value = "";
    }
    StringBuilder builder = new StringBuilder();
    String pathName = parameterBase.getPath().toString();
    builder.append("\n#********  ").append(pathName);
    if (description != null) {
      String withPounds = description.replaceAll("\n", "\n#");
      builder.append('\n').append("#** ").append(withPounds);
    }
    if (isNotModifiableAtRuntime()) {
      builder.append("\n#**  static parameter (not modifiable at runtime)");
    }
    if (constraints != null && !"".equals(constraints.trim())) {
      builder
          .append("\n#** constraints : ")
          .append(constraints)
          .append(" ; type : ")
          .append(TypeInfos.get(parameterBase.getTypeName()));
    } else {
      builder.append("\n#** type : ").append(TypeInfos.get(parameterBase.getTypeName()));
    }
    if (category != null && !"".equals(category.trim())) {
      builder.append("\n#** category : ").append(category);
    }
    String propName = this.simpleName;
    if (propName == null || "".equals(propName.trim())) {
      propName = pathName;
    } else {
      propName = propName.trim().replaceAll(" ", "\\\\ ");
    }
    builder
        .append("\n#**\n#********\n\n")
        .append(commentOutValue ? "#" : "")
        .append(propName)
        .append(" = ")
        .append(value)
        .append('\n');

    // System.out.println(" -> -> " +builder );
    return builder.toString();
  }
コード例 #2
0
 public String getTypeName() {
   return parameterBase.getTypeName();
 }