コード例 #1
0
  /**
   * Write the types for an array element in the arguments.
   *
   * @param array java.lang.Object[]
   */
  public void writeTypesArray(Object[] array) {
    // A big ol' case statement in a for loop -- what's polymorphism mean, again?
    // I really wish I could extend the base classes!

    for (int i = 0; i < array.length; i++) {
      if (null == array[i]) continue;
      // Create a way to deal with Boolean type objects
      if (Boolean.TRUE.equals(array[i])) {
        stream.write('T');
        continue;
      }
      if (Boolean.FALSE.equals(array[i])) {
        stream.write('F');
        continue;
      }
      // this is an object -- write the type for the class
      writeType(array[i].getClass());
    }
  }
コード例 #2
0
  /**
   * Write types for the arguments (use a vector for jdk1.1 compatibility, rather than an
   * ArrayList).
   *
   * @param vector the arguments to an OSCMessage
   */
  public void writeTypes(Vector vector) {
    // A big ol' case statement in a for loop -- what's polymorphism mean, again?
    // I really wish I could extend the base classes!

    Enumeration enm = vector.elements();
    Object nextObject;
    while (enm.hasMoreElements()) {
      nextObject = enm.nextElement();
      if (null == nextObject) continue;
      // if the array at i is a type of array write a [
      // This is used for nested arguments
      if (nextObject.getClass().isArray()) {
        stream.write('[');
        // fill the [] with the SuperCollider types corresponding to the object
        // (e.g., Object of type String needs -s).
        writeTypesArray((Object[]) nextObject);
        // close the array
        stream.write(']');
        continue;
      }
      // Create a way to deal with Boolean type objects
      if (Boolean.TRUE.equals(nextObject)) {
        stream.write('T');
        continue;
      }
      if (Boolean.FALSE.equals(nextObject)) {
        stream.write('F');
        continue;
      }
      // go through the array and write the superCollider types as shown in the
      // above method. the Classes derived here are used as the arg to the above method
      writeType(nextObject.getClass());
    }
    // align the stream with padded bytes
    appendNullCharToAlignStream();
  }