Source Code Cross Referenced for WmlText.java in  » J2EE » Sofia » com » salmonllc » wml » 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 » J2EE » Sofia » com.salmonllc.wml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //** Copyright Statement ***************************************************
002:        //The Salmon Open Framework for Internet Applications (SOFIA)
003:        // Copyright (C) 1999 - 2002, Salmon LLC
004:        //
005:        // This program is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU General Public License version 2
007:        // as published by the Free Software Foundation;
008:        // 
009:        // This program is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:        // GNU General Public License for more details.
013:        // 
014:        // You should have received a copy of the GNU General Public License
015:        // along with this program; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:        // 
018:        // For more information please visit http://www.salmonllc.com
019:        //** End Copyright Statement ***************************************************
020:        package com.salmonllc.wml;
021:
022:        /////////////////////////
023:        //$Archive: /SOFIA/SourceCode/com/salmonllc/wml/WmlText.java $
024:        //$Author: Srufle $
025:        //$Revision: 3 $
026:        //$Modtime: 4/15/03 3:11p $
027:        /////////////////////////
028:
029:        import com.salmonllc.html.HtmlComponent;
030:        import com.salmonllc.html.HtmlPage;
031:        import com.salmonllc.jsp.JspController;
032:        import com.salmonllc.sql.*;
033:
034:        /**
035:         * This type can be used to add text to your page.
036:         */
037:        public class WmlText extends HtmlComponent {
038:
039:            public boolean _bold = false;
040:            public boolean _big = false;
041:            public boolean _italic = false;
042:            public boolean _small = false;
043:            public boolean _strong = false;
044:            public boolean _underline = false;
045:
046:            public static final int AGGREGATE_SUM = DataStoreEvaluator.AGGREGATE_SUM;
047:            public static final int AGGREGATE_COUNT = DataStoreEvaluator.AGGREGATE_COUNT;
048:            public static final int AGGREGATE_AVERAGE = DataStoreEvaluator.AGGREGATE_AVERAGE;
049:
050:            private String _text;
051:            private int _aggregateType = -1;
052:
053:            private DataStoreEvaluator _dsEval = null;
054:            private boolean _fixSpecialWml = true;
055:
056:            /**
057:             * Constructs an wml text object for the page.
058:             * @param text The text to place in the page.
059:             * @param p The page to put the text in.
060:             */
061:            public WmlText(String text, HtmlPage p) {
062:                super ("", p);
063:                _text = text;
064:
065:            }
066:
067:            /**
068:             * Constructs an wml text object for the page.
069:             * @param text The text to place in the page.
070:             * @param p The page to put the text in.
071:             */
072:            public WmlText(String name, String text, HtmlPage p) {
073:                super (name, p);
074:                _text = text;
075:
076:            }
077:
078:            public void generateHTML(java.io.PrintWriter p, int rowNo)
079:                    throws Exception {
080:                if (!getVisible())
081:                    return;
082:
083:                if (_dsEval != null) {
084:                    if (_aggregateType != -1) {
085:                        _text = _dsEval.evaluateAggregateFormat(_aggregateType);
086:                    } else {
087:                        if (rowNo > -1)
088:                            _text = _dsEval.evaluateRowFormat(rowNo);
089:                        else
090:                            _text = _dsEval.evaluateRowFormat();
091:                    }
092:                }
093:
094:                String out = _text;
095:
096:                if (_fixSpecialWml)
097:                    out = fixSpecialHTMLCharacters(out);
098:
099:                String start = "";
100:                String end = "";
101:                if (_bold) {
102:                    start += "<b>";
103:                    end = "</b>" + end;
104:                }
105:                if (_big) {
106:                    start += "<big>";
107:                    end = "</big>" + end;
108:                }
109:                if (_italic) {
110:                    start += "<i>";
111:                    end = "</i>" + end;
112:                }
113:                if (_small) {
114:                    start += "<small>";
115:                    end = "</small>" + end;
116:                }
117:                if (_strong) {
118:                    start += "<strong>";
119:                    end = "</strong>" + end;
120:                }
121:                if (_underline) {
122:                    start += "<u>";
123:                    end = "</u>" + end;
124:                }
125:
126:                p.print(start + out + end);
127:            }
128:
129:            public void generateHTML(java.io.PrintWriter p, int rowStart,
130:                    int rowEnd) throws Exception {
131:                if (!getVisible())
132:                    return;
133:
134:                if (_dsEval != null) {
135:                    if (_aggregateType != -1) {
136:                        _text = _dsEval.evaluateAggregateFormat(_aggregateType,
137:                                rowStart, rowEnd);
138:                    } else {
139:                        if (rowStart > -1)
140:                            _text = _dsEval.evaluateRowFormat(rowStart);
141:                        else
142:                            _text = _dsEval.evaluateRowFormat();
143:                    }
144:                }
145:
146:                String out = _text;
147:
148:                if (_fixSpecialWml)
149:                    out = fixSpecialHTMLCharacters(out);
150:
151:                //-----------------------------------------------------------------------------------------------
152:
153:                String start = "";
154:                String end = "";
155:                if (_bold) {
156:                    start += "<b>";
157:                    end = "</b>" + end;
158:                }
159:                if (_big) {
160:                    start += "<big>";
161:                    end = "</big>" + end;
162:                }
163:                if (_italic) {
164:                    start += "<i>";
165:                    end = "</i>" + end;
166:                }
167:                if (_small) {
168:                    start += "<small>";
169:                    end = "</small>" + end;
170:                }
171:                if (_strong) {
172:                    start += "<strong>";
173:                    end = "</strong>" + end;
174:                }
175:                if (_underline) {
176:                    start += "<u>";
177:                    end = "</u>" + end;
178:                }
179:
180:                p.print(start + out + end);
181:            }
182:
183:            /**
184:             * Use this method to find out if the that the text will be bold.
185:             */
186:            public boolean getBold() {
187:                return _bold;
188:            }
189:
190:            /**
191:             * Use this method to find out if the that the text will be big.
192:             */
193:            public boolean getBig() {
194:                return _big;
195:            }
196:
197:            /**
198:             * Use this method to find out if the that the text will be italic.
199:             */
200:            public boolean getItalic() {
201:                return _italic;
202:            }
203:
204:            /**
205:             * Use this method to find out if the that the text will be small.
206:             */
207:            public boolean getSmall() {
208:                return _small;
209:            }
210:
211:            /**
212:             * Use this method to find out if the that the text will be strong.
213:             */
214:            public boolean getStrong() {
215:                return _strong;
216:            }
217:
218:            /**
219:             * Use this method to find out if the that the text will be underline.
220:             */
221:            public boolean getUnderline() {
222:                return _underline;
223:            }
224:
225:            /**
226:             * This method returns the DataStore Evaluator used to parse and evaluate the expression set in the setExpression method.
227:             */
228:            public DataStoreEvaluator getExpressionEvaluator() {
229:                return _dsEval;
230:            }
231:
232:            /**
233:             * Returns whether special html characters (<,>,&,; etc..) should be converted to Html Escape Sequences before being generated.
234:             */
235:            public boolean getFixSpecialWmlCharacters() {
236:                return _fixSpecialWml;
237:            }
238:
239:            /**
240:             * This method returns the text in the component.
241:             */
242:            public String getText() {
243:                return _text;
244:            }
245:
246:            public boolean processParms(java.util.Hashtable h, int row) {
247:                return false;
248:            }
249:
250:            /**
251:             * Use this method to indicate that the text should be bold.
252:             */
253:            public void setBold(boolean bold) {
254:                _bold = bold;
255:            }
256:
257:            /**
258:             * Use this method to indicate that the text should be big.
259:             */
260:            public void setBig(boolean big) {
261:                _big = big;
262:            }
263:
264:            /**
265:             * Use this method to indicate that the text should be italic.
266:             */
267:            public void setItalic(boolean italic) {
268:                _italic = italic;
269:            }
270:
271:            /**
272:             * Use this method to indicate that the text should be small.
273:             */
274:            public void setSmall(boolean small) {
275:                _small = small;
276:            }
277:
278:            /**
279:             * Use this method to indicate that the text should be strong.
280:             */
281:            public void setStrong(boolean strong) {
282:                _strong = strong;
283:            }
284:
285:            /**
286:             * Use this method to indicate that the text should be underline.
287:             */
288:            public void setUnderline(boolean underline) {
289:                _underline = underline;
290:            }
291:
292:            /**
293:             * Use this method to bind this component to an expression in a DataStore
294:             * @param ds The DataStore to bind to.
295:             * @param expression The expression to bind to.
296:             * @see DataStoreEvaluator
297:             */
298:            public void setExpression(DataStoreBuffer ds,
299:                    DataStoreExpression expression) throws Exception {
300:                _dsEval = new DataStoreEvaluator(ds, expression);
301:            }
302:
303:            /**
304:             * Use this method to bind this component to an expression in a DataStoreBuffer. The expression will be evaluated for all rows in the datastore.
305:             * @param ds The DataStore to bind to.
306:             * @param expression The expression to bind to.
307:             * @param aggregateType valid values are AGGREGATE_SUM and AGGREGATE_COUNT
308:             * @see DataStoreEvaluator
309:             */
310:            public void setExpression(DataStoreBuffer ds,
311:                    DataStoreExpression expression, int aggregateType)
312:                    throws Exception {
313:                _aggregateType = aggregateType;
314:                _dsEval = new DataStoreEvaluator(ds, expression);
315:            }
316:
317:            /**
318:             * Use this method to bind this component to an expression in a DataStoreBuffer. The expression will be evaluated for all rows in the datastore.
319:             * @param ds The DataStore to bind to.
320:             * @param expression The expression to bind to.
321:             * @param aggregateType valid values are AGGREGATE_SUM and AGGREGATE_COUNT
322:             * @param format The patter to use to format the result
323:             * @see DataStore#setFormat
324:             * @see DataStoreEvaluator
325:             */
326:            public void setExpression(DataStoreBuffer ds,
327:                    DataStoreExpression expression, int aggregateType,
328:                    String format) throws Exception {
329:                _aggregateType = aggregateType;
330:                _dsEval = new DataStoreEvaluator(ds, expression, format);
331:            }
332:
333:            /**
334:             * Use this method to bind this component to an expression in a DataStoreBuffer. The resulting expression wil be formatted according to the pattern specified.
335:             * @param ds The DataStore to bind to.
336:             * @param expression The expression to bind to.
337:             * @param format The patter to use to format the result
338:             * @see DataStore#setFormat
339:             * @see DataStoreEvaluator
340:             */
341:            public void setExpression(DataStoreBuffer ds,
342:                    DataStoreExpression expression, String format)
343:                    throws Exception {
344:                _dsEval = new DataStoreEvaluator(ds, expression, format);
345:            }
346:
347:            /**
348:             * Use this method to bind this component to an expression in a DataStore
349:             * @param ds The DataStore to bind to.
350:             * @param expression The expression to bind to.
351:             * @see DataStoreEvaluator
352:             */
353:            public void setExpression(DataStoreBuffer ds, String expression)
354:                    throws Exception {
355:                _dsEval = new DataStoreEvaluator(ds, expression);
356:            }
357:
358:            /**
359:             * Use this method to bind this component to an expression in a DataStoreBuffer. The expression will be evaluated for all rows in the datastore.
360:             * @param ds The DataStore to bind to.
361:             * @param expression The expression to bind to.
362:             * @param aggregateType valid values are AGGREGATE_SUM and AGGREGATE_COUNT
363:             * @see DataStoreEvaluator
364:             */
365:            public void setExpression(DataStoreBuffer ds, String expression,
366:                    int aggregateType) throws Exception {
367:                _aggregateType = aggregateType;
368:                _dsEval = new DataStoreEvaluator(ds, expression);
369:            }
370:
371:            /**
372:             * Use this method to bind this component to an expression in a DataStoreBuffer. The expression will be evaluated for all rows in the datastore.
373:             * @param ds The DataStore to bind to.
374:             * @param expression The expression to bind to.
375:             * @param aggregateType valid values are AGGREGATE_SUM and AGGREGATE_COUNT
376:             * @param format The patter to use to format the result
377:             * @see DataStore#setFormat
378:             * @see DataStoreEvaluator
379:             */
380:            public void setExpression(DataStoreBuffer ds, String expression,
381:                    int aggregateType, String format) throws Exception {
382:                _aggregateType = aggregateType;
383:                _dsEval = new DataStoreEvaluator(ds, expression, format);
384:            }
385:
386:            /**
387:             * Use this method to bind this component to an expression in a DataStoreBuffer. The resulting expression wil be formatted according to the pattern specified.
388:             * @param ds The DataStore to bind to.
389:             * @param expression The expression to bind to.
390:             * @param format The patter to use to format the result
391:             * @see DataStore#setFormat
392:             * @see DataStoreEvaluator
393:             */
394:            public void setExpression(DataStoreBuffer ds, String expression,
395:                    String format) throws Exception {
396:                _dsEval = new DataStoreEvaluator(ds, expression, format);
397:            }
398:
399:            /**
400:             * Specify whether special wml characters (<,>,&,; etc..) should be converted to Html Escape Sequences before being generated.
401:             */
402:            public void setFixSpecialWmlCharacters(boolean fix) {
403:                _fixSpecialWml = fix;
404:            }
405:
406:            /**
407:             * This method sets the text that the componnt will generate.
408:             */
409:            public void setText(String text) {
410:                _text = text;
411:            }
412:
413:            /**
414:             * This method returns the text in the component.
415:             */
416:            public String getText(int rowNo) {
417:                try {
418:                    if (_dsEval != null) {
419:                        if (_aggregateType != -1) {
420:                            _text = _dsEval
421:                                    .evaluateAggregateFormat(_aggregateType);
422:                        } else {
423:                            if (rowNo > -1)
424:                                _text = _dsEval.evaluateRowFormat(rowNo);
425:                            else
426:                                _text = _dsEval.evaluateRowFormat();
427:                        }
428:                    }
429:                } catch (Exception e) {
430:                    com.salmonllc.util.MessageLog.writeErrorMessage(e, this );
431:                }
432:                return _text;
433:            }
434:
435:            /**
436:             *Does the binding for the component. This method is called by the framework and should not be called directly
437:             */
438:
439:            public void doBinding() throws Exception {
440:                String dataSource = getDataSource();
441:                String dsName = null;
442:                String dsExp = null;
443:
444:                if (dataSource == null)
445:                    return;
446:
447:                int pos = dataSource.indexOf(":");
448:                if (pos == -1)
449:                    dsName = dataSource;
450:                else {
451:                    dsName = dataSource.substring(0, pos);
452:                    dsExp = dataSource.substring(pos + 1);
453:                }
454:
455:                DataStoreBuffer ds = ((JspController) getPage())
456:                        .getDataSource(dsName);
457:                if (ds == null)
458:                    return;
459:
460:                if (!ds.getAutoBind())
461:                    return;
462:
463:                int index = -1;
464:                if (dsExp != null)
465:                    index = ds.getColumnIndex(dsExp);
466:
467:                if (index != -1)
468:                    setExpression(ds, ds.getColumnName(index), ds
469:                            .getFormat(index));
470:                else
471:                    setExpression(ds, ((JspController) getPage())
472:                            .convertExpressionOperators(dsExp));
473:
474:            }
475:
476:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.