Source Code Cross Referenced for Notifier.java in  » 6.0-JDK-Modules » j2me » com » sun » satsa » jcrmic » utils » 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 » j2me » com.sun.satsa.jcrmic.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package com.sun.satsa.jcrmic.utils;
028:
029:        import java.util.*;
030:        import java.io.*;
031:
032:        /**
033:         *  This class is responsible for reporting any messages (error, warning,
034:         *  progress, banner and status messages) during the compilation.
035:         */
036:        public class Notifier {
037:
038:            /**
039:             * The stream where error messages are printed.
040:             */
041:            OutputStream out;
042:
043:            /**
044:             * Constructor.
045:             * @param out output stream
046:             */
047:            public Notifier(OutputStream out) {
048:
049:                this .out = out;
050:            }
051:
052:            /**
053:             * Output a message.
054:             * @param msg the message
055:             */
056:            public void output(String msg) {
057:
058:                if (this .out instanceof  PrintStream) {
059:                    ((PrintStream) out).println(msg);
060:                } else {
061:                    OutputStreamWriter osw = new OutputStreamWriter(this .out);
062:                    PrintWriter pw = new PrintWriter(osw, true);
063:                    pw.println(msg);
064:                    try {
065:                        osw.flush();
066:                    } catch (IOException phooey) {
067:                    }
068:                }
069:            }
070:
071:            /**
072:             * Prints error message.
073:             * @param msg the message
074:             */
075:            public void error(String msg) {
076:                output(getText(msg));
077:            }
078:
079:            /**
080:             * Prints error message.
081:             * @param msg the message
082:             * @param arg1 argument
083:             */
084:            public void error(String msg, String arg1) {
085:                output(getText(msg, arg1));
086:            }
087:
088:            /**
089:             * Prints error message.
090:             * @param msg the message
091:             * @param arg1 argument
092:             * @param arg2 argument
093:             */
094:            public void error(String msg, String arg1, String arg2) {
095:                output(getText(msg, arg1, arg2));
096:            }
097:
098:            /**
099:             * Prints error message.
100:             * @param msg the message
101:             * @param arg1 argument
102:             * @param arg2 argument
103:             * @param arg3 argument
104:             */
105:            public void error(String msg, String arg1, String arg2, String arg3) {
106:                output(getText(msg, arg1, arg2, arg3));
107:            }
108:
109:            /**
110:             * Return the string value of a named resource in the rmic.properties
111:             * resource bundle.  If the resource is not found, null is returned.
112:             * @param key resource name
113:             * @return the value
114:             */
115:            public static String getString(String key) {
116:
117:                if (!resourcesInitialized) {
118:                    initResources();
119:                }
120:
121:                try {
122:                    return resources.getString(key);
123:                } catch (MissingResourceException ignore) {
124:                }
125:                return null;
126:            }
127:
128:            /**
129:             * Flag that indicates that resoyrces were initialized.
130:             */
131:            private static boolean resourcesInitialized = false;
132:
133:            /**
134:             * Resource bundle.
135:             */
136:            private static ResourceBundle resources;
137:
138:            /**
139:             * Initializes resource bundle.
140:             */
141:            private static void initResources() {
142:
143:                try {
144:                    resources = ResourceBundle
145:                            .getBundle("com/sun/satsa/jcrmic/jcrmic");
146:                    resourcesInitialized = true;
147:                } catch (MissingResourceException e) {
148:                    throw new Error("fatal: missing resource bundle: "
149:                            + e.getClassName());
150:                }
151:            }
152:
153:            /**
154:             * Returns the string for given key.
155:             * @param key the key
156:             * @return the string
157:             */
158:            public static String getText(String key) {
159:
160:                String message = getString(key);
161:
162:                if (message == null) {
163:                    message = "no text found: \"" + key + "\"";
164:                }
165:
166:                return message;
167:            }
168:
169:            /**
170:             * Returns the message.
171:             * @param key the key
172:             * @param num parameter
173:             * @return the message
174:             */
175:            public static String getText(String key, int num) {
176:                return getText(key, Integer.toString(num), null, null);
177:            }
178:
179:            /**
180:             * Returns the message.
181:             * @param key the key
182:             * @param arg0 parameter
183:             * @return the message
184:             */
185:            public static String getText(String key, String arg0) {
186:                return getText(key, arg0, null, null);
187:            }
188:
189:            /**
190:             * Returns the message.
191:             * @param key the key
192:             * @param arg0 parameter
193:             * @param arg1 parameter
194:             * @return the message
195:             */
196:            public static String getText(String key, String arg0, String arg1) {
197:                return getText(key, arg0, arg1, null);
198:            }
199:
200:            /**
201:             * Returns the message.
202:             * @param key the key
203:             * @param arg0 parameter
204:             * @param arg1 parameter
205:             * @param arg2 parameter
206:             * @return the message
207:             */
208:            public static String getText(String key, String arg0, String arg1,
209:                    String arg2) {
210:
211:                String format = getString(key);
212:                if (format == null) {
213:                    format = "no text found: "
214:                            + "key = \"{0}\", arguments = \"{1}\", \"{2}\", \"{3}\"";
215:                }
216:
217:                String[] args = new String[3];
218:                args[0] = (arg0 != null ? arg0.toString() : "null");
219:                args[1] = (arg1 != null ? arg1.toString() : "null");
220:                args[2] = (arg2 != null ? arg2.toString() : "null");
221:
222:                return java.text.MessageFormat.format(format, args);
223:            }
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.