Source Code Cross Referenced for TextTag.java in  » Portal » Open-Portal » com » sun » portal » wireless » htmlconversion » processors » 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 » Portal » Open Portal » com.sun.portal.wireless.htmlconversion.processors 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Feb 10, 2005
003:         */
004:        package com.sun.portal.wireless.htmlconversion.processors;
005:
006:        import java.util.HashMap;
007:
008:        /**
009:         * Used to specify how AmlText should be rendered for a given HTML text tag.
010:         * Instances are split up into statically defined styles (defined on this class),
011:         * which map to HTML tags and dynamically constructed instances (which must
012:         * have a parent TextTag), which are used to maintain a formatting context 
013:         * while processing text.
014:         * 
015:         * @author ashwin.mathew@sun.com
016:         */
017:        public class TextTag {
018:            public static final String TEXT_SIZE_BIG = "big";
019:            public static final String TEXT_SIZE_NORMAL = "normal";
020:            public static final String TEXT_SIZE_SMALL = "small";
021:
022:            public static final String HALIGN_LEFT = "left";
023:            public static final String HALIGN_RIGHT = "right";
024:            public static final String HALIGN_CENTER = "center";
025:
026:            public static final String VALIGN_TOP = "top";
027:            public static final String VALIGN_BOTTOM = "bottom";
028:            public static final String VALIGN_MIDDLE = "middle";
029:
030:            private static HashMap styleRegistry = new HashMap();
031:
032:            private String tagName;
033:
034:            private boolean isBold;
035:
036:            private boolean isItalics;
037:
038:            private boolean isUnderlined;
039:
040:            private String textSize;
041:
042:            private String halign;
043:
044:            private String valign;
045:
046:            private String colour;
047:
048:            private String font;
049:
050:            private boolean followingLineBreak;
051:
052:            private boolean leadingLineBreak;
053:
054:            // Only for use by non-static TextTags
055:            private TextTag parent = null;
056:
057:            private TextTag(String tagName, boolean isBold, boolean isItalics,
058:                    boolean isUnderlined, String textSize, String halign,
059:                    String valign, boolean followingLineBreak,
060:                    boolean leadingLineBreak) {
061:                this .tagName = tagName;
062:                this .isBold = isBold;
063:                this .isItalics = isItalics;
064:                this .isUnderlined = isUnderlined;
065:
066:                this .textSize = textSize;
067:                this .halign = halign;
068:                this .valign = valign;
069:
070:                this .followingLineBreak = followingLineBreak;
071:                this .leadingLineBreak = leadingLineBreak;
072:
073:                styleRegistry.put(tagName, this );
074:            }
075:
076:            /**
077:             * Inherits properties from a parent text tag, overriding where appropriate
078:             * on the style (statically defined TextTag instance), and setting on the 
079:             * new TextTag instance.
080:             * 
081:             * @param parent
082:             * @param style
083:             */
084:            public TextTag(TextTag parent, TextTag style) {
085:                this .tagName = parent.getTagName() + style.getTagName();
086:
087:                this .isBold = parent.isBold() || style.isBold();
088:                this .isItalics = parent.isItalics() || style.isItalics();
089:                this .isUnderlined = parent.isUnderlined()
090:                        || style.isUnderlined();
091:
092:                // Use style properties only for these, since we don't want
093:                // nested styles picking up line break settings
094:                this .leadingLineBreak = style.hasLeadingLineBreak();
095:                this .followingLineBreak = style.hasFollowingLineBreak();
096:
097:                // Style overrides Parent
098:
099:                this .textSize = (style.getTextSize() == null) ? parent
100:                        .getTextSize() : style.getTextSize();
101:
102:                this .halign = (style.getHalign() == null) ? parent.getHalign()
103:                        : style.getHalign();
104:
105:                this .valign = (style.getValign() == null) ? parent.getValign()
106:                        : style.getValign();
107:
108:                this .colour = (style.getColour() == null) ? parent.getColour()
109:                        : style.getColour();
110:
111:                this .font = (style.getFont() == null) ? parent.getFont()
112:                        : style.getFont();
113:
114:                this .parent = parent;
115:            }
116:
117:            /**
118:             * Specialized constructor for use when font tags are encountered.
119:             * 
120:             * @param font
121:             * @param colour
122:             * @param size
123:             */
124:            public TextTag(String font, String colour, String textSize) {
125:                this .font = font;
126:                this .colour = colour;
127:                this .textSize = textSize;
128:                this .tagName = FONT.getTagName();
129:            }
130:
131:            /**
132:             * Returns a TextTag style for the specified tag name.
133:             * 
134:             * @param tagName
135:             * @return
136:             */
137:            public static TextTag getStyle(String tagName) {
138:                return (TextTag) styleRegistry.get(tagName);
139:            }
140:
141:            /**
142:             * Returns the list of registered style tag names.
143:             * @return
144:             */
145:            public static String[] getStyleTagNames() {
146:                return (String[]) styleRegistry.keySet().toArray(new String[0]);
147:            }
148:
149:            /**
150:             * Returns the tag name.
151:             * @return
152:             */
153:            public String getTagName() {
154:                return tagName;
155:            }
156:
157:            /**
158:             * @return Returns the colour.
159:             */
160:            public String getColour() {
161:                return colour;
162:            }
163:
164:            /**
165:             * @return Returns the font.
166:             */
167:            public String getFont() {
168:                return font;
169:            }
170:
171:            /**
172:             * @return Returns the halign.
173:             */
174:            public String getHalign() {
175:                return halign;
176:            }
177:
178:            /**
179:             * @return Returns the isBold.
180:             */
181:            public boolean isBold() {
182:                return isBold;
183:            }
184:
185:            /**
186:             * @return Returns the isItalics.
187:             */
188:            public boolean isItalics() {
189:                return isItalics;
190:            }
191:
192:            /**
193:             * @return Returns the isUnderlined.
194:             */
195:            public boolean isUnderlined() {
196:                return isUnderlined;
197:            }
198:
199:            /**
200:             * @return Returns the textSize.
201:             */
202:            public String getTextSize() {
203:                return textSize;
204:            }
205:
206:            /**
207:             * @return Returns the valign.
208:             */
209:            public String getValign() {
210:                return valign;
211:            }
212:
213:            /**
214:             * @return Returns the followingLineBreak.
215:             */
216:            public boolean hasFollowingLineBreak() {
217:                return followingLineBreak;
218:            }
219:
220:            /**
221:             * @return Returns the leadingLineBreak.
222:             */
223:            public boolean hasLeadingLineBreak() {
224:                return leadingLineBreak;
225:            }
226:
227:            /**
228:             * Returns the parent for this tag.
229:             * @return
230:             */
231:            public TextTag getParent() {
232:                return parent;
233:            }
234:
235:            // Definition of styles, assume all tag names in lower case
236:
237:            // Used for text sections without any special formatting, and for AmlText
238:            // tags generated as part of an enclosing tag, e.g., AmlListItem from li.
239:            public static final TextTag NOSTYLE = new TextTag("NOSTYLE", false,
240:                    false, false, TextTag.TEXT_SIZE_NORMAL, null, null, false,
241:                    false);
242:
243:            public static final TextTag H1 = new TextTag("h1", true, false,
244:                    false, TextTag.TEXT_SIZE_BIG, null, null, true, true);
245:            public static final TextTag H2 = new TextTag("h2", true, true,
246:                    false, TextTag.TEXT_SIZE_BIG, null, null, true, true);
247:            public static final TextTag H3 = new TextTag("h3", true, false,
248:                    true, TextTag.TEXT_SIZE_NORMAL, null, null, true, true);
249:            public static final TextTag H4 = new TextTag("h4", false, true,
250:                    true, TextTag.TEXT_SIZE_NORMAL, null, null, true, true);
251:            public static final TextTag H5 = new TextTag("h5", false, false,
252:                    false, TextTag.TEXT_SIZE_NORMAL, null, null, true, true);
253:            public static final TextTag H6 = new TextTag("h6", false, false,
254:                    false, TextTag.TEXT_SIZE_NORMAL, null, null, true, true);
255:
256:            public static final TextTag PRE = new TextTag("pre", false, false,
257:                    false, null, null, null, false, false);
258:            public static final TextTag BLOCKQUOTE = new TextTag("blockquote",
259:                    false, false, false, null, null, null, true, true);
260:            public static final TextTag BDO = new TextTag("bdo", false, false,
261:                    false, null, null, null, false, false);
262:            public static final TextTag EM = new TextTag("em", false, true,
263:                    false, null, null, null, false, false);
264:            public static final TextTag STRONG = new TextTag("strong", true,
265:                    false, false, null, null, null, false, false);
266:            public static final TextTag DFN = new TextTag("dfn", false, true,
267:                    false, null, null, null, false, false);
268:            public static final TextTag CODE = new TextTag("code", false,
269:                    false, false, TextTag.TEXT_SIZE_SMALL, null, null, false,
270:                    false);
271:            public static final TextTag SAMP = new TextTag("samp", false,
272:                    false, false, TextTag.TEXT_SIZE_SMALL, null, null, false,
273:                    false);
274:            public static final TextTag KBD = new TextTag("kbd", false, false,
275:                    false, TextTag.TEXT_SIZE_SMALL, null, null, false, false);
276:            public static final TextTag VAR = new TextTag("var", false, true,
277:                    false, null, null, null, false, false);
278:            public static final TextTag CITE = new TextTag("cite", false, true,
279:                    false, null, null, null, false, false);
280:            public static final TextTag ABBR = new TextTag("abbr", false,
281:                    false, false, null, null, null, false, false);
282:            public static final TextTag ACRONYM = new TextTag("acronym", false,
283:                    true, false, null, null, null, false, false);
284:            public static final TextTag Q = new TextTag("q", false, false,
285:                    false, null, null, null, false, false);
286:            public static final TextTag SUB = new TextTag("sub", false, true,
287:                    false, TextTag.TEXT_SIZE_SMALL, null, null, false, false);
288:            public static final TextTag SUP = new TextTag("sup", false, true,
289:                    false, TextTag.TEXT_SIZE_SMALL, null, null, false, false);
290:            public static final TextTag TT = new TextTag("tt", false, false,
291:                    false, TextTag.TEXT_SIZE_SMALL, null, null, false, false);
292:            public static final TextTag I = new TextTag("i", false, true,
293:                    false, null, null, null, false, false);
294:            public static final TextTag B = new TextTag("b", true, false,
295:                    false, null, null, null, false, false);
296:            public static final TextTag U = new TextTag("u", false, false,
297:                    true, null, null, null, false, false);
298:            public static final TextTag BIG = new TextTag("big", false, false,
299:                    false, TextTag.TEXT_SIZE_BIG, null, null, false, false);
300:            public static final TextTag SMALL = new TextTag("sub", false,
301:                    false, false, TextTag.TEXT_SIZE_SMALL, null, null, false,
302:                    false);
303:            public static final TextTag CENTER = new TextTag("center", false,
304:                    false, false, null, TextTag.HALIGN_CENTER, null, false,
305:                    false);
306:
307:            public static final TextTag DT = new TextTag("dt", false, false,
308:                    false, null, null, null, false, false);
309:            public static final TextTag DD = new TextTag("dd", false, true,
310:                    false, null, null, null, false, false);
311:
312:            public static final TextTag FONT = new TextTag("font", false,
313:                    false, false, null, null, null, false, false);
314:
315:            public static final TextTag ADDRESS = new TextTag("address", false,
316:                    true, false, null, null, null, true, true);
317:
318:            public static final TextTag LABEL = new TextTag("label", false,
319:                    false, false, null, null, null, false, false);
320:            public static final TextTag LEGEND = new TextTag("legend", false,
321:                    false, false, null, null, null, true, true);
322:            public static final TextTag CAPTION = new TextTag("caption", false,
323:                    false, false, null, null, null, true, true);
324:
325:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.