|
9
|
1 |
/** |
|
0
|
2 |
* @author cramakrishnan |
|
|
3 |
* |
|
|
4 |
* Copyright (C) 2003, C. Ramakrishnan / Illposed Software |
|
|
5 |
* All rights reserved. |
|
|
6 |
* |
|
|
7 |
* See license.txt (or license.rtf) for license information. |
|
|
8 |
* |
|
|
9 |
* |
|
|
10 |
* OscPacket is the abstract superclass for the various |
|
|
11 |
* kinds of OSC Messages. Its direct subclasses are: |
|
|
12 |
* OscMessage, OscBundle |
|
|
13 |
* |
|
|
14 |
* Subclasses need to know how to produce a byte array |
|
|
15 |
* in the format specified by the OSC spec (or SuperCollider |
|
|
16 |
* documentation, as the case may be). |
|
|
17 |
* |
|
|
18 |
* This implementation is based on Markus Gaelli and |
|
|
19 |
* Iannis Zannos' OSC implementation in Squeak: |
|
|
20 |
* http://www.emergent.de/Goodies/ |
|
|
21 |
*/ |
|
|
22 |
|
|
|
23 |
package com.illposed.osc; |
|
|
24 |
|
|
|
25 |
import com.illposed.osc.utility.*; |
|
|
26 |
|
|
|
27 |
public abstract class OSCPacket { |
|
|
28 |
|
|
9
|
29 |
protected byte[] byteArray; |
|
0
|
30 |
|
|
9
|
31 |
public OSCPacket() { |
|
|
32 |
super(); |
|
|
33 |
} |
|
0
|
34 |
|
|
9
|
35 |
protected void computeByteArray() { |
|
|
36 |
OSCJavaToByteArrayConverter stream = new OSCJavaToByteArrayConverter(); |
|
|
37 |
computeByteArray(stream); |
|
|
38 |
} |
|
0
|
39 |
|
|
9
|
40 |
/** |
|
|
41 |
* @param stream OscPacketByteArrayConverter |
|
|
42 |
* |
|
|
43 |
* Subclasses should implement this method to product a byte array |
|
|
44 |
* formatted according to the OSC/SuperCollider specification. |
|
|
45 |
*/ |
|
|
46 |
protected abstract void computeByteArray(OSCJavaToByteArrayConverter stream); |
|
0
|
47 |
|
|
9
|
48 |
/** |
|
|
49 |
* @return byte[] |
|
|
50 |
*/ |
|
|
51 |
public byte[] getByteArray() { |
|
|
52 |
computeByteArray(); |
|
|
53 |
return byteArray; |
|
|
54 |
} |
|
0
|
55 |
|
|
9
|
56 |
protected void init() { |
|
|
57 |
|
|
|
58 |
} |
|
0
|
59 |
|
|
|
60 |
} |