com.illposed.osc.utility
Class OSCJavaToByteArrayConverter

java.lang.Object
  extended bycom.illposed.osc.utility.OSCJavaToByteArrayConverter

public class OSCJavaToByteArrayConverter
extends java.lang.Object

OSCJavaToByteArrayConverter is a helper class that translates from Java types to their byte stream representations according to the OSC spec.

The implementation is based on Markus Gaelli and Iannis Zannos' OSC implementation in Squeak.

This version includes bug fixes and improvements from Martin Kaltenbrunner and Alex Potsides.

Copyright (C) 2003-2006, C. Ramakrishnan / Illposed Software. All rights reserved.

See license.txt (or license.rtf) for license information.

Version:
1.0
Author:
Chandrasekhar Ramakrishnan, Martin Kaltenbrunner, Alex Potsides

Field Summary
protected  java.io.ByteArrayOutputStream stream
           
 
Constructor Summary
OSCJavaToByteArrayConverter()
           
 
Method Summary
 void appendNullCharToAlignStream()
          Pad the stream to have a size divisible by 4.
 byte[] toByteArray()
          Convert the contents of the output stream to a byte array.
 void write(java.math.BigInteger i)
           
 void write(byte[] bytes)
          Write bytes into the byte stream.
 void write(char c)
          Write a char into the byte stream.
 void write(java.lang.Float f)
          Write a float into the byte stream.
 void write(int i)
          Write an int into the byte stream.
 void write(java.lang.Integer i)
           
 void write(java.lang.Object anObject)
          Write an object into the byte stream.
 void write(java.lang.String aString)
          Write a string into the byte stream.
 void writeType(java.lang.Class c)
          Write the type tag for the type represented by the class
 void writeTypes(java.util.Vector vector)
          Write types for the arguments (use a vector for jdk1.1 compatibility, rather than an ArrayList).
 void writeTypesArray(java.lang.Object[] array)
          Write the types for an array element in the arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stream

protected java.io.ByteArrayOutputStream stream
Constructor Detail

OSCJavaToByteArrayConverter

public OSCJavaToByteArrayConverter()
Method Detail

appendNullCharToAlignStream

public void appendNullCharToAlignStream()
Pad the stream to have a size divisible by 4.


toByteArray

public byte[] toByteArray()
Convert the contents of the output stream to a byte array.

Returns:
the byte array containing the byte stream

write

public void write(byte[] bytes)
Write bytes into the byte stream.

Parameters:
bytes - byte[]

write

public void write(int i)
Write an int into the byte stream.

Parameters:
i - int

write

public void write(java.lang.Float f)
Write a float into the byte stream.

Parameters:
f - java.lang.Float

write

public void write(java.lang.Integer i)
Parameters:
i - java.lang.Integer

write

public void write(java.math.BigInteger i)
Parameters:
i - java.lang.Integer

write

public void write(java.lang.String aString)
Write a string into the byte stream.

Parameters:
aString - java.lang.String

write

public void write(char c)
Write a char into the byte stream.

Parameters:
c - char

write

public void write(java.lang.Object anObject)
Write an object into the byte stream.

Parameters:
anObject - one of Float, String, Integer, BigInteger, or array of these.

writeType

public void writeType(java.lang.Class c)
Write the type tag for the type represented by the class

Parameters:
c - Class of a Java object in the arguments

writeTypesArray

public void writeTypesArray(java.lang.Object[] array)
Write the types for an array element in the arguments.

Parameters:
array - java.lang.Object[]

writeTypes

public void writeTypes(java.util.Vector vector)
Write types for the arguments (use a vector for jdk1.1 compatibility, rather than an ArrayList).

Parameters:
vector - the arguments to an OSCMessage