Source Code Cross Referenced for Document.java in  » Net » Terracotta » com » tc » admin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Terracotta » com.tc.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.admin;
005:
006:        import java.util.HashMap;
007:        import java.util.Iterator;
008:        import java.util.Map;
009:
010:        public class Document {
011:            private StringBuffer out;
012:            int indent = 0;
013:
014:            private Map fontParamMap = new HashMap();
015:            private StringBuffer fontParams = new StringBuffer();
016:
017:            public Document() {
018:                this (new StringBuffer());
019:            }
020:
021:            public Document(Document parent) {
022:                this (new StringBuffer());
023:                this .indent = parent.indent;
024:                this .fontParamMap.putAll(parent.fontParamMap);
025:                bakeFontParams();
026:            }
027:
028:            public Document(StringBuffer out) {
029:                this .out = out;
030:            }
031:
032:            public String toString() {
033:                return out.toString();
034:            }
035:
036:            public Document otag(Object name) {
037:                return otag(name, "");
038:            }
039:
040:            public Document otag(Object name, Object params) {
041:                indent();
042:                print("<" + name);
043:                if (params != null) {
044:                    print(params);
045:                }
046:                return println(">");
047:            }
048:
049:            public Document ctag(Object name) {
050:                return outdent().println("</" + name + ">");
051:            }
052:
053:            public Document octag(Object name) {
054:                return octag(name, "");
055:            }
056:
057:            public Document octag(Object name, Object params) {
058:                return print("<" + name + (params == null ? "" : params) + "/>");
059:            }
060:
061:            public Document html() {
062:                return otag("html");
063:            }
064:
065:            public Document chtml() {
066:                return ctag("html");
067:            }
068:
069:            public Document head() {
070:                return otag("head");
071:            }
072:
073:            public Document chead() {
074:                return ctag("head");
075:            }
076:
077:            public Document title(Object title) {
078:                return otag("title").println(title).ctag("title");
079:            }
080:
081:            public Document body() {
082:                return otag("body");
083:            }
084:
085:            public Document cbody() {
086:                return ctag("body");
087:            }
088:
089:            public Document comment(Object comment) {
090:                return println("<!--" + comment + "-->");
091:            }
092:
093:            public String param(Object name, Object value) {
094:                return " " + name + "=\"" + value + "\"";
095:            }
096:
097:            public Document text(Object text) {
098:                if (text != null) {
099:                    return print(escape(text.toString()));
100:                } else {
101:                    return this ;
102:                }
103:            }
104:
105:            private String escape(String source) {
106:                if (source == null)
107:                    return null;
108:
109:                StringBuffer myOut = new StringBuffer();
110:                char[] sourceChars = source.toCharArray();
111:                for (int i = 0; i < sourceChars.length; ++i) {
112:                    char theChar = sourceChars[i];
113:                    String toAppend = new String(new char[] { theChar });
114:
115:                    if (theChar == '<')
116:                        toAppend = "&lt;";
117:                    if (theChar == '>')
118:                        toAppend = "&gt;";
119:                    if (theChar == '&')
120:                        toAppend = "&amp;";
121:                    if (theChar > 0x7E || theChar < 0x20)
122:                        toAppend = "&#" + Integer.toHexString(theChar) + ";";
123:
124:                    myOut.append(toAppend);
125:                }
126:
127:                return myOut.toString();
128:            }
129:
130:            public Document img(Object url) {
131:                return img(url, " border=0");
132:            }
133:
134:            public Document img(Object url, Object params) {
135:                return otag("img src=\"" + url + "\" ", params);
136:            }
137:
138:            public Document href(Object url, String text) {
139:                return otag("a href=\"" + url + "\"").print(text).ctag("a");
140:            }
141:
142:            public Document br() {
143:                return octag("br");
144:            }
145:
146:            public Document hr() {
147:                return octag("hr");
148:            }
149:
150:            public Document ul() {
151:                return ul("");
152:            }
153:
154:            public Document ul(String params) {
155:                return otag("ul", params);
156:            }
157:
158:            public Document cul() {
159:                return ctag("ul");
160:            }
161:
162:            public Document li() {
163:                return li("");
164:            }
165:
166:            public Document li(String params) {
167:                return otag("li", params);
168:            }
169:
170:            public Document cli() {
171:                return ctag("li");
172:            }
173:
174:            public Document style() {
175:                return style("");
176:            }
177:
178:            public Document style(Object params) {
179:                return otag("style", params);
180:            }
181:
182:            public Document cstyle() {
183:                return ctag("style");
184:            }
185:
186:            private void bakeFontParams() {
187:                fontParams.delete(0, fontParams.length());
188:                Object key;
189:                for (Iterator iter = fontParamMap.keySet().iterator(); iter
190:                        .hasNext();) {
191:                    key = iter.next();
192:                    fontParams.append(param(key, fontParamMap.get(key)));
193:                }
194:            }
195:
196:            public Document fontparam(Object name, Object value) {
197:                fontParamMap.put(name, value);
198:                bakeFontParams();
199:                return this ;
200:            }
201:
202:            public Document dfontparam(Object name) {
203:                fontParamMap.remove(name);
204:                bakeFontParams();
205:                return this ;
206:            }
207:
208:            public Document fontclear() {
209:                fontParamMap.clear();
210:                bakeFontParams();
211:                return this ;
212:            }
213:
214:            public Document font() {
215:                return font(fontParams);
216:            }
217:
218:            public Document font(Object params) {
219:                return otag("font", params);
220:            }
221:
222:            public Document cfont() {
223:                return ctag("font");
224:            }
225:
226:            public Document table() {
227:                return table("");
228:            }
229:
230:            public Document table(String params) {
231:                return otag("table", params);
232:            }
233:
234:            public Document ctable() {
235:                return ctag("table");
236:            }
237:
238:            public Document row(String data) {
239:                tr().print(data).ctr();
240:                return this ;
241:            }
242:
243:            public Document cell(Object o) {
244:                return cell(o == null ? "" : o.toString());
245:            }
246:
247:            public Document cell(String data) {
248:                td().println(data).ctd();
249:                return this ;
250:            }
251:
252:            public Document tr() {
253:                return otag("tr");
254:            }
255:
256:            public Document ctr() {
257:                return ctag("tr");
258:            }
259:
260:            public Document th() {
261:                return th("");
262:            }
263:
264:            public Document th(Object params) {
265:                return otag("th", params);
266:            }
267:
268:            public Document cth() {
269:                return ctag("th");
270:            }
271:
272:            public Document td() {
273:                return td("");
274:            }
275:
276:            public Document td(Object params) {
277:                return otag("td", params);
278:            }
279:
280:            public Document ctd() {
281:                return ctag("td");
282:            }
283:
284:            Document indent() {
285:                indent += 2;
286:                return this ;
287:            }
288:
289:            Document outdent() {
290:                indent = indent - 2;
291:                return this ;
292:            }
293:
294:            public Document newline() {
295:                out.append("\n");
296:                for (int i = 0; i < indent; i++) {
297:                    out.append(" ");
298:                }
299:                return this ;
300:            }
301:
302:            public Document println(Object data) {
303:                print(data);
304:                newline();
305:                return this ;
306:            }
307:
308:            public Document print(Object data) {
309:                out.append(data);
310:                return this;
311:            }
312:
313:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.