Package gnu.java.lang

Examples of gnu.java.lang.CPStringBuilder


        // Don't resolve external entity references
        factory.setProperty("javax.xml.stream.isSupportingExternalEntities",
                            Boolean.FALSE);
        XMLStreamReader reader = factory.createXMLStreamReader(in);
        String name, key = null;
        CPStringBuilder buf = null;
        while (reader.hasNext())
          {
            switch (reader.next())
              {
              case XMLStreamConstants.START_ELEMENT:
                name = reader.getLocalName();
                if (buf == null && "entry".equals(name))
                  {
                    key = reader.getAttributeValue(null, "key");
                    if (key == null)
                      {
                        String msg = "missing 'key' attribute";
                        throw new InvalidPropertiesFormatException(msg);
                      }
                    buf = new CPStringBuilder();
                  }
                else if (!"properties".equals(name) && !"comment".equals(name))
                  {
                    String msg = "unexpected element name '" + name + "'";
                    throw new InvalidPropertiesFormatException(msg);
                  }
                break;
              case XMLStreamConstants.END_ELEMENT:
                name = reader.getLocalName();
                if (buf != null && "entry".equals(name))
                  {
                    put(key, buf.toString());
                    buf = null;
                  }
                else if (!"properties".equals(name) && !"comment".equals(name))
                  {
                    String msg = "unexpected element name '" + name + "'";
                    throw new InvalidPropertiesFormatException(msg);
                  }
                break;
              case XMLStreamConstants.CHARACTERS:
              case XMLStreamConstants.SPACE:
              case XMLStreamConstants.CDATA:
                if (buf != null)
                  buf.append(reader.getText());
                break;
              }
          }
        reader.close();
      }
View Full Code Here


   *
   * @since 1.0.2
   */
  public String getHostAddress()
  {
    CPStringBuilder sb = new CPStringBuilder(40);

    int len = addr.length;
    int i = 0;
   
    for ( ; ; )
      {
        sb.append(addr[i] & 0xff);
        i++;
 
        if (i == len)
          break;
 
        sb.append('.');
      }

    return sb.toString();
  }
View Full Code Here

   * @return a String representation of the Collection
   */
  public String toString()
  {
    Iterator itr = iterator();
    CPStringBuilder r = new CPStringBuilder("[");
    boolean hasNext = itr.hasNext();
    while (hasNext)
      {
        Object o = itr.next();
  if (o == this)
    r.append("<this>");
  else
    r.append(o);
  hasNext = itr.hasNext();
        if (hasNext)
          r.append(", ");
      }
    r.append("]");
    return r.toString();
  }
View Full Code Here

  // Create whole stack trace in a stringbuffer so we don't have to print
  // it line by line. This prevents printing multiple stack traces from
  // different threads to get mixed up when written to the same PrintWriter.
  private String stackTraceString()
  {
    CPStringBuilder sb = new CPStringBuilder();

    // Main stacktrace
    StackTraceElement[] stack = getStackTrace();
    stackTraceStringBuffer(sb, this.toString(), stack, 0);

    // The cause(s)
    Throwable cause = getCause();
    while (cause != null)
      {
  // Cause start first line
        sb.append("Caused by: ");

        // Cause stacktrace
        StackTraceElement[] parentStack = stack;
        stack = cause.getStackTrace();
  if (parentStack == null || parentStack.length == 0)
    stackTraceStringBuffer(sb, cause.toString(), stack, 0);
  else
    {
      int equal = 0; // Count how many of the last stack frames are equal
      int frame = stack.length-1;
      int parentFrame = parentStack.length-1;
      while (frame > 0 && parentFrame > 0)
        {
    if (stack[frame].equals(parentStack[parentFrame]))
      {
        equal++;
        frame--;
        parentFrame--;
      }
    else
      break;
        }
      stackTraceStringBuffer(sb, cause.toString(), stack, equal);
    }
        cause = cause.getCause();
      }

    return sb.toString();
  }
View Full Code Here

  {
    // Since we are already synchronized, and entrySet().iterator()
    // would repeatedly re-lock/release the monitor, we directly use the
    // unsynchronized EntryIterator instead.
    Iterator<Map.Entry<K, V>> entries = new EntryIterator();
    CPStringBuilder r = new CPStringBuilder("{");
    for (int pos = size; pos > 0; pos--)
      {
        r.append(entries.next());
        if (pos > 1)
          r.append(", ");
      }
    r.append("}");
    return r.toString();
  }
View Full Code Here

   * @return A String describing this SampleModel.
   * @see java.lang.Object#toString()
   */
  public String toString()
  {
    CPStringBuilder result = new CPStringBuilder();
    result.append(getClass().getName());
    result.append("[");
    result.append("scanlineStride=").append(scanlineStride);
    for(int i = 0; i < bitMasks.length; i+=1)
    {
      result.append(", mask[").append(i).append("]=0x").append(
          Integer.toHexString(bitMasks[i]));
    }
   
    result.append("]");
    return result.toString();
  }
View Full Code Here

  /**
   * Returns a string describing the range, type, and validity of this lock.
   */
  public final String toString()
  {
    CPStringBuilder buf = new CPStringBuilder(getClass().getName());
    buf.append("[");
    buf.append(position);
    buf.append(":");
    buf.append(size);
    if (shared)
      buf.append(" shared");
    else
      buf.append(" exclusive");
    if (isValid())
      buf.append(" valid]");
    else
      buf.append(" invalid]");
    return buf.toString();
  }
View Full Code Here

      return "NaN";
    if (isInfinite(d))
      return d < 0 ? "-Infinity" : "Infinity";

    long bits = doubleToLongBits(d);
    CPStringBuilder result = new CPStringBuilder();
   
    if (bits < 0)
      result.append('-');
    result.append("0x");

    final int mantissaBits = 52;
    final int exponentBits = 11;
    long mantMask = (1L << mantissaBits) - 1;
    long mantissa = bits & mantMask;
    long expMask = (1L << exponentBits) - 1;
    long exponent = (bits >>> mantissaBits) & expMask;

    result.append(exponent == 0 ? '0' : '1');
    result.append('.');
    result.append(Long.toHexString(mantissa));
    if (exponent == 0 && mantissa != 0)
      {
        // Treat denormal specially by inserting '0's to make
        // the length come out right.  The constants here are
        // to account for things like the '0x'.
        int offset = 4 + ((bits < 0) ? 1 : 0);
        // The silly +3 is here to keep the code the same between
        // the Float and Double cases.  In Float the value is
        // not a multiple of 4.
        int desiredLength = offset + (mantissaBits + 3) / 4;
        while (result.length() < desiredLength)
          result.insert(offset, '0');
      }
    result.append('p');
    if (exponent == 0 && mantissa == 0)
      {
        // Zero, so do nothing special.
      }
    else
      {
        // Apply bias.
        boolean denormal = exponent == 0;
        exponent -= (1 << (exponentBits - 1)) - 1;
        // Handle denormal.
        if (denormal)
          ++exponent;
      }

    result.append(Long.toString(exponent));
    return result.toString();
  }
View Full Code Here

   * @return A String describing this SampleModel.
   * @see java.lang.Object#toString()
   */
  public String toString()
  {
    CPStringBuilder result = new CPStringBuilder();
    result.append(getClass().getName());
    result.append("[");
    result.append("scanlineStride=").append(scanlineStride);
    for(int i=0; i < bitMasks.length; i+=1)
    {
      result.append(", mask[").append(i).append("]=0x").append(Integer.toHexString(bitMasks[i]));
    }
   
    result.append("]");
    return result.toString();
  }
View Full Code Here

     * The string is easy to generate.
     * @return A string representation of the list.
     */
    public String toString()
    {
      CPStringBuilder r = new CPStringBuilder("{");
      for (int i = n - 1; --i > 0; )
        r.append(element).append(", ");
      r.append(element).append("}");
      return r.toString();
    }
View Full Code Here

TOP

Related Classes of gnu.java.lang.CPStringBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.