I just got done writing a library that reads and writes messages encapsulated in envelopes.
It uses messages of the format (C) or (C,123,123,...) where C is a message type identifier.
I think you can apply this to your code, maybe. Disclaimer, I used the Serial class from Processing.
I've uploaded the code to my website where I'll keep it for probably a year or so until I figure nobody else is going to find it.
The pertinent code to your project is:
+ in the Arduino folder, where I have the library plus a library it relies on, and an example
+ in the Java folder, in the comms package. The Dashboard class in the uwheel package implements the MessageHandler interface, and responds to both a single-item command plus a command with parameters and therefore is a good example of how to use this.
It should be pretty easy to use this code in your Processing project since Processing is in Java. You'll just have to figure out how to install the comms package as a library in Processing (maybe remove the package declarations), then implement MessageHandler.
In case you are a beginner: Start with Dashboard.java and the Arduino example. You shouldn't need to touch much else, since I have tested both sides.http://johnmchilton.com/media/uwheel_src.zip