Example #1
0
 /**
  * Returns the <code>CharArray</code> representation of this {@link TextBuilder}.
  *
  * @return the corresponding {@link CharArray} instance.
  */
 public final CharArray toCharArray() {
   CharArray cArray = new CharArray();
   char[] data;
   if (_length < C1) {
     data = _low;
   } else {
     data = new char[_length];
     this.getChars(0, _length, data, 0);
   }
   cArray.setArray(data, 0, _length);
   return cArray;
 }
Example #2
0
  public static @infix void toString(Object o, StringBuilder builder) {
    if (o == null) {
      builder.append("null");
      return;
    }

    Class c = o.getClass();
    if (c == String.class) {
      builder.append((String) o);
      return;
    }
    if (c == boolean[].class) {
      BooleanArray.toString((boolean[]) o, builder);
      return;
    }
    if (c == byte[].class) {
      ByteArray.toString((byte[]) o, builder);
      return;
    }
    if (c == short[].class) {
      ShortArray.toString((short[]) o, builder);
      return;
    }
    if (c == char[].class) {
      CharArray.toString((char[]) o, builder);
      return;
    }
    if (c == int[].class) {
      IntArray.toString((int[]) o, builder);
      return;
    }
    if (c == long[].class) {
      LongArray.toString((long[]) o, builder);
      return;
    }
    if (c == float[].class) {
      FloatArray.toString((float[]) o, builder);
      return;
    }
    if (c == double[].class) {
      DoubleArray.toString((double[]) o, builder);
      return;
    }
    if (c.isArray()) {
      deepToString((Object[]) o, builder);
      return;
    }

    builder.append(o.toString());
  }
Example #3
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    CharArray ca = new CharArray(new char[] {'H', 'A', 'L', 'L', 'O'});

    ca.print();

    ca.print(1, 4);

    System.out.println("Counter: " + ca.Counter);
    System.out.println("Counter: " + CharArray.Counter);

    CharArray caWorld = new CharArray(new char[] {'W', 'O', 'R', 'L', 'D'});

    ca.print();
    System.out.println("Counter: " + ca.Counter);
    System.out.println("Counter: " + caWorld.Counter);
    System.out.println("Counter: " + CharArray.Counter);

    caWorld.print();
  }
Example #4
0
 public CharStream append(CharArray chars) throws IOException {
   chars.write(delegate);
   return this;
 }