FileDocCategorySizeDatePackage
FormattedWriter.javaAPI DocGlassfish v2 API4462Fri May 04 22:35:22 BST 2007com.sun.jdo.spi.persistence.utility.generator.io

FormattedWriter

public class FormattedWriter extends Object
author
raccah

Fields Summary
private static final String
lineSeparator
private static final String
indent
private StringBuffer
_buffer
private int
_initialIndents
Constructors Summary
FormattedWriter()
Creates new FormattedWriter


	    
	 
	
	
Methods Summary
private void_write(int indents, java.lang.String s)

		final StringBuffer buffer = getBuffer();

		if (!s.equals(lineSeparator))
		{
			for (int i = 0; i < indents; i++)
				buffer.append(indent);
		}

		buffer.append(s);
	
private java.lang.StringBuffergetBuffer()

		if (_buffer == null)
			_buffer = new StringBuffer();

		return _buffer;
	
private voidindent(int indents, java.lang.String s)

		if (s.indexOf(lineSeparator) != -1)
		{
			StringTokenizer tokenizer =
				new StringTokenizer(s, lineSeparator, true);

			while (tokenizer.hasMoreTokens())
				write(indents, tokenizer.nextToken());
		}
		else
			write(indents, s);
	
public java.lang.StringtoString()
Returns a string representation of the FormattedWriter.

return
The string representation of the internal StringBuffer used by this object.

 return getBuffer().toString(); 
voidwrite(int indents, java.lang.String s)

		_write(indents + _initialIndents, s);
	
voidwrite(java.lang.String s)

		_write(0, s);
	
voidwriteComments(java.lang.String[] comments)

		final int n = (comments != null ? comments.length : 0);

		for (int i = 0; i < n; i++)
		{
			final String s = comments[i];

			writeln("// " + (s != null ? s : ""));	// NOI18N
		}
	
voidwriteList(int indents, java.util.List list, boolean addSeparator)

		if ((list != null) && (list.size() > 0))
		{
			Iterator iterator = list.iterator();
	
			while (iterator.hasNext())
			{
				indent(indents, iterator.next().toString());

				if (addSeparator)
					writeln();
			}

			if (!addSeparator)
				writeln();
		}
	
voidwriteList(int indents, java.util.List list)

		writeList(indents, list, false);
	
voidwriteList(java.util.List list)

		writeList(0, list);
	
voidwriteln()

		writeln(0, "");			// NOI18N
	
voidwriteln(int indents, java.lang.String s)

		if (_initialIndents > 0)
			_write(_initialIndents, "");	// NOI18N

		_write(indents, s + lineSeparator);
	
voidwriteln(java.lang.String s)

		writeln(0, s);