FileDocCategorySizeDatePackage
LoopPrinterSafe.javaAPI DocExample2624Thu Feb 04 16:10:44 GMT 1999None

LoopPrinterSafe

public class LoopPrinterSafe extends Object

Fields Summary
private Vector[]
pStorage
private int
growSize
Constructors Summary
public LoopPrinterSafe(int initSize, int growSize)

		pStorage = new Vector[initSize];
		this.growSize = growSize;
	
public LoopPrinterSafe()

		this(100, 0);
	
Methods Summary
private synchronized voidenlargeStorage(int minSize)

		int oldSize = pStorage.length;
		if (oldSize < minSize) {
			int newSize = (growSize > 0) ?
				oldSize + growSize : 2 * oldSize;
			if (newSize < minSize) {
				newSize = minSize;
			}	
			Vector newVec[] = new Vector[newSize];
			System.arraycopy(pStorage, 0, newVec, 0, oldSize);
			pStorage = newVec;
		}
	
public synchronized voidprint(int index, java.lang.Object obj)

		if (index >= pStorage.length) {
			enlargeStorage(index+1);
		}
		if (pStorage[index] == null) {
			pStorage[index] = new Vector();
		}
		pStorage[index].addElement(obj.toString());
	
public synchronized voidprintln(int index, java.lang.Object obj)

		print(index, obj);
		print(index, "\n");
	
public synchronized voidsend2stream(java.io.PrintStream ps)

		for (int i = 0; i < pStorage.length; i++) {
			if (pStorage[i] != null) {
				Enumeration e = pStorage[i].elements();
				while (e.hasMoreElements()) {
					ps.print(e.nextElement());
				}
			}	
		}