Beispiel #1
0
  public static void main(String[] args) {
    dumpSystemInfo();

    Set<?> keys = System.getProperties().keySet();

    @SuppressWarnings("unchecked")
    List<String> list = createArrayList((Set<String>) keys);

    Collections.sort(list);

    for (String key : list) {
      String value = System.getProperty(key);

      System.out.println(key + " = " + defaultIfNull(StringEscapeUtil.escapeJava(value), "[n/a]"));
    }
  }
Beispiel #2
0
  /** 添加query。 */
  public URIBroker addQueryData(String id, Object value) {
    id = assertNotNull(trimToNull(id), "empty query id");

    String strValue;

    if (value == null) {
      strValue = EMPTY_STRING;
    } else {
      assertTrue(!value.getClass().isArray(), "use setQueryData(array) instead");
      strValue = String.valueOf(value);
    }

    Object values = getQuery().get(id);

    if (values == null) {
      values = strValue;
    } else if (values instanceof String) {
      values = new String[] {(String) values, strValue};
    } else if (values instanceof String[]) {
      int length = ((String[]) values).length;
      String[] tmp = new String[length + 1];
      System.arraycopy(values, 0, tmp, 0, length);
      tmp[length] = strValue;
      values = tmp;
    } else {
      unreachableCode();
    }

    getQuery().put(id, values);

    renderer.updateQueryBuffer(id, strValue);

    return this;
  }
Beispiel #3
0
  /**
   * 取得系统属性,如果因为Java安全的限制而失败,则将错误打在<code>System.err</code>中,然后返回 <code>null</code>。
   *
   * @param name 属性名
   * @param quiet 安静模式,不将出错信息打在<code>System.err</code>中
   * @return 属性值或<code>null</code>
   */
  private static String getSystemProperty(String name, boolean quiet) {
    try {
      return System.getProperty(name);
    } catch (SecurityException e) {
      if (!quiet) {
        System.err.println(
            "Caught a SecurityException reading the system property '"
                + name
                + "'; the SystemUtil property value will default to null.");
      }

      return null;
    }
  }