package com.streamvantage.BaseUtilities;import java.io.*;public class XMLMessage {	public static final byte EOM = 0x04;	public static final byte ESC = 0x1b;	public static class XMLInputStream 		extends FilterInputStream {				private boolean EOFEncountered = false;				public XMLInputStream (InputStream is) {			super (is);		}				public InputStream getUnderlyingStream () {			return in;		}				public int read () throws IOException {			if (EOFEncountered) {				return -1;			}						int b = super.read ();			if (b == EOM) {				EOFEncountered = true;				return -1;			} else if (b == ESC) {				return super.read ();			} else {				return b;			}		}				public int read (byte [] b, int off, int len) throws IOException {			if (b == null) {			    throw new NullPointerException ();			} else if ((off < 0) || (off > b.length) || (len < 0) ||				   ((off + len) > b.length) || ((off + len) < 0)) {			    throw new IndexOutOfBoundsException ();			} else if (len == 0) {				return 0;			}						int i;			int c = read ();			if (c == -1) {				return -1;			}			b [off] = (byte) c;						for (i = 1; i < len; i++) {				c = read ();				if (c == -1) {					return i;				}				b [off + i] = (byte) c;			}						return len;		}				public void close () throws IOException {		}		}		public static class XMLOutputStream 		extends FilterOutputStream {				public XMLOutputStream (OutputStream os) {			super (os);		}				public OutputStream getUnderlyingStream () {			return out;		}				public void write (int b) throws IOException {			if (b == EOM) {				super.write (ESC);			} else if (b == ESC) {				super.write (ESC);			}			super.write (b);		}				public void close () throws IOException {			super.write (EOM);			super.flush ();		}			}}