Пример #1
0
 /**
  * Expand all instances of <code>"${property-name}"</code> into <code>
  * System.getProperty("property-name")</code>.
  */
 private static String expand(final String s) {
   final CPStringBuilder result = new CPStringBuilder();
   final CPStringBuilder prop = new CPStringBuilder();
   int state = 0;
   for (int i = 0; i < s.length(); i++) {
     switch (state) {
       case 0:
         if (s.charAt(i) == '$') state = 1;
         else result.append(s.charAt(i));
         break;
       case 1:
         if (s.charAt(i) == '{') state = 2;
         else {
           state = 0;
           result.append('$').append(s.charAt(i));
         }
         break;
       case 2:
         if (s.charAt(i) == '}') {
           String p = prop.toString();
           if (p.equals("/")) p = "file.separator";
           p = System.getProperty(p);
           if (p == null) p = "";
           result.append(p);
           prop.setLength(0);
           state = 0;
         } else prop.append(s.charAt(i));
         break;
     }
   }
   if (state != 0) result.append('$').append('{').append(prop);
   return result.toString();
 }
Пример #2
0
  /**
   * Returns the string representation for this object.
   *
   * @return The string representation.
   */
  public String toString() {
    CPStringBuilder b = new CPStringBuilder();

    if (attributes.size() > 0) b.append(attributes.get(0));

    for (int i = 1; i < attributes.size(); i++) b.append(", " + attributes.get(i));

    return b.toString();
  }
Пример #3
0
 /** Return the human readable representation. */
 public String toString() {
   CPStringBuilder b = new CPStringBuilder();
   b.append(host);
   b.append(":");
   b.append(port);
   b.append(" (v");
   b.append(version);
   b.append(")");
   if (components.size() > 0) b.append(" " + components.size() + " extra components.");
   return b.toString();
 }
Пример #4
0
  /**
   * Tries to load the bundle for a given locale, also loads the backup locales with the same
   * language.
   *
   * @param baseName the raw bundle name, without locale qualifiers
   * @param locale the locale
   * @param classLoader the classloader
   * @param wantBase whether a resource bundle made only from the base name (with no locale
   *     information attached) should be returned.
   * @return the resource bundle if it was loaded, otherwise the backup
   */
  private static ResourceBundle tryBundle(
      String baseName, Locale locale, ClassLoader classLoader, boolean wantBase) {
    String language = locale.getLanguage();
    String country = locale.getCountry();
    String variant = locale.getVariant();

    int baseLen = baseName.length();

    // Build up a CPStringBuilder containing the complete bundle name, fully
    // qualified by locale.
    CPStringBuilder sb = new CPStringBuilder(baseLen + variant.length() + 7);

    sb.append(baseName);

    if (language.length() > 0) {
      sb.append('_');
      sb.append(language);

      if (country.length() > 0) {
        sb.append('_');
        sb.append(country);

        if (variant.length() > 0) {
          sb.append('_');
          sb.append(variant);
        }
      }
    }

    // Now try to load bundles, starting with the most specialized name.
    // Build up the parent chain as we go.
    String bundleName = sb.toString();
    ResourceBundle first = null; // The most specialized bundle.
    ResourceBundle last = null; // The least specialized bundle.

    while (true) {
      ResourceBundle foundBundle = tryBundle(bundleName, classLoader);
      if (foundBundle != null) {
        if (first == null) first = foundBundle;
        if (last != null) last.parent = foundBundle;
        foundBundle.locale = locale;
        last = foundBundle;
      }
      int idx = bundleName.lastIndexOf('_');
      // Try the non-localized base name only if we already have a
      // localized child bundle, or wantBase is true.
      if (idx > baseLen || (idx == baseLen && (first != null || wantBase)))
        bundleName = bundleName.substring(0, idx);
      else break;
    }

    return first;
  }
Пример #5
0
 /**
  * Returns an implementation-dependent string describing the attributes of this <code>JProgressBar
  * </code>.
  *
  * @return A string describing the attributes of this <code>JProgressBar</code> (never <code>null
  *     </code>).
  */
 protected String paramString() {
   String superParamStr = super.paramString();
   CPStringBuilder sb = new CPStringBuilder();
   sb.append(",orientation=");
   if (orientation == HORIZONTAL) sb.append("HORIZONTAL");
   else sb.append("VERTICAL");
   sb.append(",paintBorder=").append(isBorderPainted());
   sb.append(",paintString=").append(isStringPainted());
   sb.append(",progressString=");
   if (progressString != null) sb.append(progressString);
   sb.append(",indeterminateString=").append(isIndeterminate());
   return superParamStr + sb.toString();
 }
Пример #6
0
  /**
   * Returs a stringified reference.
   *
   * @return a newly constructed stringified reference.
   */
  public String toStringifiedReference() {
    BufferedCdrOutput out = new BufferedCdrOutput();

    _write(out);

    CPStringBuilder b = new CPStringBuilder("IOR:");

    byte[] binary = out.buffer.toByteArray();
    String s;

    for (int i = 0; i < binary.length; i++) {
      s = Integer.toHexString(binary[i] & 0xFF);
      if (s.length() == 1) b.append('0');
      b.append(s);
    }

    return b.toString();
  }
Пример #7
0
  /** Returns a human readable string representation of this IOR object. */
  public String toString() {
    CPStringBuilder b = new CPStringBuilder();
    b.append(Id);
    b.append(" at ");
    b.append(Internet);

    if (!Big_Endian) b.append(" (Little endian) ");

    b.append(" Key ");

    for (int i = 0; i < key.length; i++) {
      b.append(Integer.toHexString(key[i] & 0xFF));
    }

    b.append(" ");
    b.append(Internet.CodeSets);

    return b.toString();
  }
Пример #8
0
  /**
   * Returns a string representation of the list.
   *
   * @return String representation, similar to BNF expression.
   */
  public String toString() {
    CPStringBuilder b = new CPStringBuilder();
    b.append(" ( ");
    for (int i = 0; i < nodes.length; i++) {
      if (i > 0) b.append(" " + (char) nodes[i].binary + " ");
      b.append(nodes[i]);
    }

    b.append(" )");
    if (unary != 0) b.append((char) unary);
    else b.append(' ');
    return b.toString();
  }
Пример #9
0
 /** Get a better formatted multiline string representation. */
 public String toStringFormatted() {
   CPStringBuilder b = new CPStringBuilder();
   b.append("\n  Native set " + name(native_set));
   if (conversion != null && conversion.length > 0) {
     b.append("\n  Other supported sets:\n    ");
     for (int i = 0; i < conversion.length; i++) {
       b.append(name(conversion[i]));
       b.append(' ');
     }
   }
   b.append("\n");
   return b.toString();
 }
Пример #10
0
 /** Get a string representation. */
 public String toString() {
   CPStringBuilder b = new CPStringBuilder();
   b.append("native " + name(native_set));
   if (conversion != null && conversion.length > 0) {
     b.append(" conversion ");
     for (int i = 0; i < conversion.length; i++) {
       b.append(name(conversion[i]));
       b.append(' ');
     }
   }
   b.append(' ');
   return b.toString();
 }
Пример #11
0
  /** Returns a multiline formatted human readable string representation of this IOR object. */
  public String toStringFormatted() {
    CPStringBuilder b = new CPStringBuilder();
    b.append("\nObject Id:\n  ");
    b.append(Id);
    b.append("\nObject is accessible at:\n  ");
    b.append(Internet);

    if (Big_Endian) b.append("\n  Big endian encoding");
    else b.append("\n  Little endian encoding.");

    b.append("\nObject Key\n  ");

    for (int i = 0; i < key.length; i++) {
      b.append(Integer.toHexString(key[i] & 0xFF));
    }

    b.append("\nSupported code sets:");
    b.append("\n Wide:");
    b.append(Internet.CodeSets.wide.toStringFormatted());
    b.append(" Narrow:");
    b.append(Internet.CodeSets.wide.toStringFormatted());

    return b.toString();
  }
Пример #12
0
 public String toString() {
   CPStringBuilder builder = new CPStringBuilder(getClass().getName());
   builder.append("[defaultLocale=");
   builder.append(defaultLocale);
   builder.append(",baseName=");
   builder.append(baseName);
   builder.append(",locale=");
   builder.append(locale);
   builder.append(",classLoader=");
   builder.append(classLoader);
   builder.append("]");
   return builder.toString();
 }