public class StringBufferBitInput implements BitInput {		StringBuffer text;		// This is what comes next. 	int nextBitsSource;		// This is what is going out next.	int nextBitsPosition;		// This points to the bit to leave.			boolean atTheEndOfBuffer=false;		// Set to be true.	int textPosition=0;		// Where it is found.			public boolean atEnd(){		return atTheEndOfBuffer;	}			public void setText(StringBuffer s){		text = s;	}		public void loadNextBits(char c){		// This just inserts the right set of bits into place.		// This version uses an abreviated set of values between 0 and 31 to use only 5 bits.		// This is a short way of compressing things.				nextBitsPosition=0;		if (c==' ') {			double r=Math.random();			if (r<.25){				nextBitsSource=0;			} else if (r<.5) {				nextBitsSource=29;			} else if (r<.75) {				nextBitsSource=11;			} else {				nextBitsSource=31;		}} else {		switch(c){			case ' ': nextBitsSource=0; break;			case 'A': case 'a': nextBitsSource=1; break;			case 'B': case 'b': nextBitsSource=2; break;			case 'C': case 'c': nextBitsSource=3; break;						case 'D': case 'd': nextBitsSource=4; break;			case 'E': case 'e': nextBitsSource=5; break;			case 'F': case 'f': nextBitsSource=6; break;			case 'G': case 'g': nextBitsSource=7; break;			case 'H': case 'h': nextBitsSource=8; break;			case 'I': case 'i': nextBitsSource=9; break;			case 'J': case 'j': nextBitsSource=10; break;			case 'K': case 'k': nextBitsSource=30; break;			case 'L': case 'l': nextBitsSource=12; break;			case 'M': case 'm': nextBitsSource=13; break;			case 'N': case 'n': nextBitsSource=14; break;			case 'O': case 'o': nextBitsSource=15; break;			case 'P': case 'p': nextBitsSource=16; break;			case 'Q': case 'q': nextBitsSource=17; break;			case 'R': case 'r': nextBitsSource=18; break;			case 'S': case 's': nextBitsSource=19; break;			case 'T': case 't': nextBitsSource=20; break;			case 'U': case 'u': nextBitsSource=21; break;			case 'V': case 'v': nextBitsSource=22; break;			case 'W': case 'w': nextBitsSource=23; break;			case 'X': case 'x': nextBitsSource=24; break;			case 'Y': case 'y': nextBitsSource=25; break;			case 'Z': case 'z': nextBitsSource=26; break;			case '-':nextBitsSource=27;	 		default: nextBitsSource=28;	 	}	 }	}				public boolean nextBit(){		boolean answer;		if ((nextBitsSource & 1)!=0){			answer=true; 		} else {			answer = false;		}		nextBitsPosition++;		if (nextBitsPosition>=5) {			textPosition++;						if (textPosition>=text.length()){				atTheEndOfBuffer = true;				loadNextBits(' ');			} else {				loadNextBits(text.charAt(textPosition));			}		} else {			nextBitsSource = nextBitsSource>>1;		} 	/*	if (answer) {			System.out.print("T");		} else {			System.out.print("F");		} */ 		return answer;	}								public void startBitSource(){		textPosition=0;		text = new StringBuffer("hi mom.");		loadNextBits(text.charAt(textPosition));	}	public void startBitSource(String s){		textPosition=0;		text = new StringBuffer(s);		loadNextBits(text.charAt(textPosition));	}}												