My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.uibinder.rebind;

import java.io.PrintWriter;

/**
* Pleasant wrapper for PrintWriter, manages indentation levels.
* Name is a misnomer, as this doesn't implement Writer.
*/
public class IndentedWriter {
private final PrintWriter pw;

private int indent;

public IndentedWriter(PrintWriter pw) {
super();
this.pw = pw;
}

/**
* Indents the generated code.
*/
public void indent() {
++indent;
}

/**
* Outputs a new line.
*/
public void newline() {
// Unix-style line endings for consistent behavior across platforms.
pw.print('\n');
}

/**
* Un-indents the generated code.
*/
public void outdent() {
if (indent == 0) {
throw new IllegalStateException("Tried to outdent below zero");
}
--indent;
}

/**
* Outputs the given string.
*/
public void write(String format) {
printIndent();
pw.print(format);
newline();
}

/**
* Outputs the given string with replacements, using the Java message format.
*/
public void write(String format, Object... args) {
printIndent();
pw.printf(format, args);
newline();
}

private void printIndent() {
for (int i = 0; i < indent; ++i) {
pw.print(" ");
}
}
}

Change log

r8605 by sco...@google.com on Aug 20, 2010   Diff
Always use unix-style line endings in
Generators.

This makes for consistent output across
operating systems.  In particular, it
makes Windows output unix-style.

http://gwt-code-
reviews.appspot.com/776803/show
Review by: bobv,rjrjr
Go to: 
Project members, sign in to write a code review

Older revisions

r6510 by sco...@google.com on Oct 28, 2009   Diff
Fixing svn props on many java files
where this was missing.

r5896 by rj...@google.com on Aug 5, 2009   Diff
Hello UiBinder

Reviewed by: jgw et al.
All revisions of this file

File info

Size: 1855 bytes, 82 lines

File properties

svn:mime-type
text/x-java
svn:eol-style
native
Powered by Google Project Hosting