Source Code Cross Referenced for MessageRetriever.java in  » 6.0-JDK-Modules-com.sun » tools » com » sun » tools » doclets » internal » toolkit » util » 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 » 6.0 JDK Modules com.sun » tools » com.sun.tools.doclets.internal.toolkit.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:        package com.sun.tools.doclets.internal.toolkit.util;
026:
027:        import com.sun.javadoc.*;
028:        import com.sun.tools.doclets.internal.toolkit.Configuration;
029:        import java.util.*;
030:        import java.text.MessageFormat;
031:
032:        /**
033:         * Retrieve and format messages stored in a resource.
034:         *
035:         * This code is not part of an API.
036:         * It is implementation that is subject to change.
037:         * Do not use it as an API
038:         * 
039:         * @since 1.2
040:         * @author Atul M Dambalkar
041:         * @author Robert Field
042:         */
043:        public class MessageRetriever {
044:            /**
045:             * The global configuration information for this run.
046:             */
047:            private final Configuration configuration;
048:
049:            /**
050:             * The location from which to lazily fetch the resource..
051:             */
052:            private final String resourcelocation;
053:
054:            /**
055:             * The lazily fetched resource..
056:             */
057:            private ResourceBundle messageRB;
058:
059:            /**
060:             * Initilize the ResourceBundle with the given resource.
061:             *
062:             * @param rb the esource bundle to read.
063:             */
064:            public MessageRetriever(ResourceBundle rb) {
065:                this .configuration = null;
066:                this .messageRB = rb;
067:                this .resourcelocation = null;
068:            }
069:
070:            /**
071:             * Initilize the ResourceBundle with the given resource.
072:             *
073:             * @param configuration the configuration
074:             * @param resourcelocation Resource.
075:             */
076:            public MessageRetriever(Configuration configuration,
077:                    String resourcelocation) {
078:                this .configuration = configuration;
079:                this .resourcelocation = resourcelocation;
080:            }
081:
082:            /**
083:             * get and format message string from resource
084:             *
085:             * @param key selects message from resource
086:             */
087:            public String getText(String key) {
088:                return getText(key, (String) null);
089:            }
090:
091:            /**
092:             * Get and format message string from resource
093:             *
094:             * @param key selects message from resource
095:             * @param a1 Argument, to be repalced in the message.
096:             */
097:            public String getText(String key, String a1) {
098:                return getText(key, a1, null);
099:            }
100:
101:            /**
102:             * Get and format message string from resource
103:             *
104:             * @param key selects message from resource
105:             * @param a1 first argument to be replaced in the message.
106:             * @param a2 second argument to be replaced in the message.
107:             */
108:            public String getText(String key, String a1, String a2) {
109:                return getText(key, a1, a2, null);
110:            }
111:
112:            /**
113:             * Get and format message string from resource
114:             *
115:             * @param key selects message from resource
116:             * @param a1 first argument to be replaced in the message.
117:             * @param a2 second argument to be replaced in the message.
118:             * @param a3 third argument to be replaced in the message.
119:             * @throws MissingResourceException when the key does not
120:             * exist in the properties file.
121:             */
122:            public String getText(String key, String a1, String a2, String a3)
123:                    throws MissingResourceException {
124:                if (messageRB == null) {
125:                    try {
126:                        messageRB = ResourceBundle.getBundle(resourcelocation);
127:                    } catch (MissingResourceException e) {
128:                        throw new Error("Fatal: Resource (" + resourcelocation
129:                                + ") for javadoc doclets is missing.");
130:                    }
131:                }
132:                String message = messageRB.getString(key);
133:                return MessageFormat.format(message, a1, a2, a3);
134:            }
135:
136:            /**
137:             * Print error message, increment error count.
138:             *
139:             * @param pos the position of the source
140:             * @param msg message to print
141:             */
142:            private void printError(SourcePosition pos, String msg) {
143:                configuration.root.printError(pos, msg);
144:            }
145:
146:            /**
147:             * Print error message, increment error count.
148:             *
149:             * @param msg message to print
150:             */
151:            private void printError(String msg) {
152:                configuration.root.printError(msg);
153:            }
154:
155:            /**
156:             * Print warning message, increment warning count.
157:             *
158:             * @param pos the position of the source
159:             * @param msg message to print
160:             */
161:            private void printWarning(SourcePosition pos, String msg) {
162:                configuration.root.printWarning(pos, msg);
163:            }
164:
165:            /**
166:             * Print warning message, increment warning count.
167:             *
168:             * @param msg message to print
169:             */
170:            private void printWarning(String msg) {
171:                configuration.root.printWarning(msg);
172:            }
173:
174:            /**
175:             * Print a message.
176:             *
177:             * @param pos the position of the source
178:             * @param msg message to print
179:             */
180:            private void printNotice(SourcePosition pos, String msg) {
181:                configuration.root.printNotice(pos, msg);
182:            }
183:
184:            /**
185:             * Print a message.
186:             *
187:             * @param msg message to print
188:             */
189:            private void printNotice(String msg) {
190:                configuration.root.printNotice(msg);
191:            }
192:
193:            /**
194:             * Print error message, increment error count.
195:             *
196:             * @param pos the position of the source
197:             * @param key selects message from resource
198:             */
199:            public void error(SourcePosition pos, String key) {
200:                printError(pos, getText(key));
201:            }
202:
203:            /**
204:             * Print error message, increment error count.
205:             *
206:             * @param key selects message from resource
207:             */
208:            public void error(String key) {
209:                printError(getText(key));
210:            }
211:
212:            /**
213:             * Print error message, increment error count.
214:             *
215:             * @param pos the position of the source
216:             * @param key selects message from resource
217:             * @param a1 first argument to be replaced in the message.
218:             */
219:            public void error(SourcePosition pos, String key, String a1) {
220:                printError(pos, getText(key, a1));
221:            }
222:
223:            /**
224:             * Print error message, increment error count.
225:             *
226:             * @param key selects message from resource
227:             * @param a1 first argument to be replaced in the message.
228:             */
229:            public void error(String key, String a1) {
230:                printError(getText(key, a1));
231:            }
232:
233:            /**
234:             * Print error message, increment error count.
235:             *
236:             * @param pos the position of the source
237:             * @param key selects message from resource
238:             * @param a1 first argument to be replaced in the message.
239:             * @param a2 second argument to be replaced in the message.
240:             */
241:            public void error(SourcePosition pos, String key, String a1,
242:                    String a2) {
243:                printError(pos, getText(key, a1, a2));
244:            }
245:
246:            /**
247:             * Print error message, increment error count.
248:             *
249:             * @param key selects message from resource
250:             * @param a1 first argument to be replaced in the message.
251:             * @param a2 second argument to be replaced in the message.
252:             */
253:            public void error(String key, String a1, String a2) {
254:                printError(getText(key, a1, a2));
255:            }
256:
257:            /**
258:             * Print error message, increment error count.
259:             *
260:             * @param pos the position of the source
261:             * @param key selects message from resource
262:             * @param a1 first argument to be replaced in the message.
263:             * @param a2 second argument to be replaced in the message.
264:             * @param a3 third argument to be replaced in the message.
265:             */
266:            public void error(SourcePosition pos, String key, String a1,
267:                    String a2, String a3) {
268:                printError(pos, getText(key, a1, a2, a3));
269:            }
270:
271:            /**
272:             * Print error message, increment error count.
273:             *
274:             * @param key selects message from resource
275:             * @param a1 first argument to be replaced in the message.
276:             * @param a2 second argument to be replaced in the message.
277:             * @param a3 third argument to be replaced in the message.
278:             */
279:            public void error(String key, String a1, String a2, String a3) {
280:                printError(getText(key, a1, a2, a3));
281:            }
282:
283:            /**
284:             * Print warning message, increment warning count.
285:             *
286:             * @param pos the position of the source
287:             * @param key selects message from resource
288:             */
289:            public void warning(SourcePosition pos, String key) {
290:                printWarning(pos, getText(key));
291:            }
292:
293:            /**
294:             * Print warning message, increment warning count.
295:             *
296:             * @param key selects message from resource
297:             */
298:            public void warning(String key) {
299:                printWarning(getText(key));
300:            }
301:
302:            /**
303:             * Print warning message, increment warning count.
304:             *
305:             * @param pos the position of the source
306:             * @param key selects message from resource
307:             * @param a1 first argument to be replaced in the message.
308:             */
309:            public void warning(SourcePosition pos, String key, String a1) {
310:                printWarning(pos, getText(key, a1));
311:            }
312:
313:            /**
314:             * Print warning message, increment warning count.
315:             *
316:             * @param key selects message from resource
317:             * @param a1 first argument to be replaced in the message.
318:             */
319:            public void warning(String key, String a1) {
320:                printWarning(getText(key, a1));
321:            }
322:
323:            /**
324:             * Print warning message, increment warning count.
325:             *
326:             * @param pos the position of the source
327:             * @param key selects message from resource
328:             * @param a1 first argument to be replaced in the message.
329:             * @param a2 second argument to be replaced in the message.
330:             */
331:            public void warning(SourcePosition pos, String key, String a1,
332:                    String a2) {
333:                printWarning(pos, getText(key, a1, a2));
334:            }
335:
336:            /**
337:             * Print warning message, increment warning count.
338:             *
339:             * @param key selects message from resource
340:             * @param a1 first argument to be replaced in the message.
341:             * @param a2 second argument to be replaced in the message.
342:             */
343:            public void warning(String key, String a1, String a2) {
344:                printWarning(getText(key, a1, a2));
345:            }
346:
347:            /**
348:             * Print warning message, increment warning count.
349:             *
350:             * @param pos the position of the source
351:             * @param key selects message from resource
352:             * @param a1 first argument to be replaced in the message.
353:             * @param a2 second argument to be replaced in the message.
354:             * @param a3 third argument to be replaced in the message.
355:             */
356:            public void warning(SourcePosition pos, String key, String a1,
357:                    String a2, String a3) {
358:                printWarning(pos, getText(key, a1, a2, a3));
359:            }
360:
361:            /**
362:             * Print warning message, increment warning count.
363:             *
364:             * @param key selects message from resource
365:             * @param a1 first argument to be replaced in the message.
366:             * @param a2 second argument to be replaced in the message.
367:             * @param a3 third argument to be replaced in the message.
368:             */
369:            public void warning(String key, String a1, String a2, String a3) {
370:                printWarning(getText(key, a1, a2, a3));
371:            }
372:
373:            /**
374:             * Print a message.
375:             *
376:             * @param pos the position of the source
377:             * @param key selects message from resource
378:             */
379:            public void notice(SourcePosition pos, String key) {
380:                printNotice(pos, getText(key));
381:            }
382:
383:            /**
384:             * Print a message.
385:             *
386:             * @param key selects message from resource
387:             */
388:            public void notice(String key) {
389:                printNotice(getText(key));
390:            }
391:
392:            /**
393:             * Print a message.
394:             * @param pos the position of the source
395:             * @param key selects message from resource
396:             * @param a1 first argument to be replaced in the message.
397:             */
398:            public void notice(SourcePosition pos, String key, String a1) {
399:                printNotice(pos, getText(key, a1));
400:            }
401:
402:            /**
403:             * Print a message.
404:             *
405:             * @param key selects message from resource
406:             * @param a1 first argument to be replaced in the message.
407:             */
408:            public void notice(String key, String a1) {
409:                printNotice(getText(key, a1));
410:            }
411:
412:            /**
413:             * Print a message.
414:             *
415:             * @param pos the position of the source
416:             * @param key selects message from resource
417:             * @param a1 first argument to be replaced in the message.
418:             * @param a2 second argument to be replaced in the message.
419:             */
420:            public void notice(SourcePosition pos, String key, String a1,
421:                    String a2) {
422:                printNotice(pos, getText(key, a1, a2));
423:            }
424:
425:            /**
426:             * Print a message.
427:             *
428:             * @param key selects message from resource
429:             * @param a1 first argument to be replaced in the message.
430:             * @param a2 second argument to be replaced in the message.
431:             */
432:            public void notice(String key, String a1, String a2) {
433:                printNotice(getText(key, a1, a2));
434:            }
435:
436:            /**
437:             * Print a message.
438:             *
439:             * @param pos the position of the source
440:             * @param key selects message from resource
441:             * @param a1 first argument to be replaced in the message.
442:             * @param a2 second argument to be replaced in the message.
443:             * @param a3 third argument to be replaced in the message.
444:             */
445:            public void notice(SourcePosition pos, String key, String a1,
446:                    String a2, String a3) {
447:                printNotice(pos, getText(key, a1, a2, a3));
448:            }
449:
450:            /**
451:             * Print a message.
452:             *
453:             * @param key selects message from resource
454:             * @param a1 first argument to be replaced in the message.
455:             * @param a2 second argument to be replaced in the message.
456:             * @param a3 third argument to be replaced in the message.
457:             */
458:            public void notice(String key, String a1, String a2, String a3) {
459:                printNotice(getText(key, a1, a2, a3));
460:            }
461:        }
w__w__w.__j___ava__2__s.c_o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.