Source Code Cross Referenced for ReportFormat.java in  » Scripting » Kawa » gnu » text » 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 » Scripting » Kawa » gnu.text 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package gnu.text;
002:
003:        import java.text.Format;
004:        import java.text.FieldPosition;
005:        import java.io.Writer;
006:        import java.io.CharArrayWriter;
007:        import gnu.lists.Consumer;
008:
009:        public abstract class ReportFormat extends Format {
010:            /** Some Formats use this to indicate a parameter that is the
011:             * extracted from the argment list. */
012:            public static final int PARAM_FROM_LIST = 0xA0000000;
013:
014:            /** Some Formats use this to indicate a parameter that is the
015:             * number of remaining paramaters. */
016:            public static final int PARAM_FROM_COUNT = 0xB0000000;
017:
018:            /** Some Formats use this to indicate an unspecified parameter. */
019:            public static final int PARAM_UNSPECIFIED = 0xC0000000;
020:
021:            public static int result(int resultCode, int nextArg) {
022:                return (resultCode << 24) | nextArg;
023:            }
024:
025:            public static int nextArg(int result) {
026:                return result & 0xffffff;
027:            }
028:
029:            public static int resultCode(int result) {
030:                return result >>> 24;
031:            }
032:
033:            /** Format an array of arguments, and write out the result.
034:             * @param dst where to write the result
035:             * @param args the objects to be formatted
036:             * @param start the index (in args) of the argument to start with
037:             * @return an integer result(resultCode, nextArg), where
038:             * nextArg is the index following the last argument processed, and
039:             * code is a result code (normally 0, or negative if early termintation)
040:             */
041:            public abstract int format(Object[] args, int start, Writer dst,
042:                    FieldPosition fpos) throws java.io.IOException;
043:
044:            public int format(Object arg, int start, Writer dst,
045:                    FieldPosition fpos) throws java.io.IOException {
046:                if (arg instanceof  Object[])
047:                    return format((Object[]) arg, start, dst, fpos);
048:                else {
049:                    Object[] args = { arg };
050:                    return format(args, start, dst, fpos);
051:                }
052:            }
053:
054:            public StringBuffer format(Object obj, StringBuffer sbuf,
055:                    FieldPosition fpos) {
056:                format((Object[]) obj, 0, sbuf, fpos);
057:                return sbuf;
058:            }
059:
060:            public int format(Object[] args, int start, StringBuffer sbuf,
061:                    FieldPosition fpos) {
062:                CharArrayWriter wr = new CharArrayWriter();
063:                try {
064:                    start = format(args, start, wr, fpos);
065:                    if (start < 0)
066:                        return start;
067:                } catch (java.io.IOException ex) {
068:                    throw new Error("unexpected exception: " + ex);
069:                }
070:                sbuf.append(wr.toCharArray());
071:                return start;
072:            }
073:
074:            public static int format(Format fmt, Object[] args, int start,
075:                    Writer dst, FieldPosition fpos) throws java.io.IOException {
076:                if (fmt instanceof  ReportFormat)
077:                    return ((ReportFormat) fmt).format(args, start, dst, fpos);
078:                StringBuffer sbuf = new StringBuffer();
079:                if (fmt instanceof  java.text.MessageFormat)
080:                    start = format(fmt, args, start, sbuf, fpos);
081:                else
082:                    fmt.format(args[start++], sbuf, fpos);
083:                int slen = sbuf.length();
084:                char[] cbuf = new char[slen];
085:                sbuf.getChars(0, slen, cbuf, 0);
086:                dst.write(cbuf);
087:                return start;
088:            }
089:
090:            public static int format(Format fmt, Object[] args, int start,
091:                    StringBuffer sbuf, FieldPosition fpos) {
092:                if (fmt instanceof  ReportFormat)
093:                    return ((ReportFormat) fmt).format(args, start, sbuf, fpos);
094:                int nargs;
095:                Object arg;
096:                if (fmt instanceof  java.text.MessageFormat) {
097:                    nargs = args.length - start;
098:                    if (start > 0) {
099:                        Object[] subarr = new Object[args.length - start];
100:                        System.arraycopy(args, start, subarr, 0, subarr.length);
101:                        arg = subarr;
102:                    } else
103:                        arg = args;
104:                } else {
105:                    arg = args[start];
106:                    nargs = 1;
107:                }
108:                fmt.format(arg, sbuf, fpos);
109:                return start + nargs;
110:            }
111:
112:            /** (Parameters in non-standard order.) */
113:            public static void print(Writer dst, String str)
114:                    throws java.io.IOException {
115:                if (dst instanceof  java.io.PrintWriter)
116:                    ((java.io.PrintWriter) dst).print(str);
117:                else
118:                    dst.write(str.toCharArray());
119:            }
120:
121:            public static void print(Object value, Consumer out) {
122:                if (value instanceof  Printable)
123:                    ((Printable) value).print(out);
124:                else
125:                    // Should we use out.writeObject?
126:                    // We need make consistent rules to avoid infinite recursion.
127:                    out.write(value == null ? "null" : value.toString());
128:            }
129:
130:            public Object parseObject(String text,
131:                    java.text.ParsePosition status) {
132:                throw new Error("ReportFormat.parseObject - not implemented");
133:            }
134:
135:            public static int getParam(Object arg, int defaultValue) {
136:                if (arg instanceof  Number)
137:                    return ((Number) arg).intValue();
138:                if (arg instanceof  Character)
139:                    return ((Character) arg).charValue();
140:                if (arg instanceof  Char)
141:                    return ((Char) arg).charValue();
142:                //if (arg == null || arg == Boolean.FALSE || arg == Special.dfault)
143:                return defaultValue;
144:            }
145:
146:            protected static int getParam(int param, int defaultValue,
147:                    Object[] args, int start) {
148:                if (param == PARAM_FROM_COUNT)
149:                    return args.length - start;
150:                if (param == PARAM_FROM_LIST)
151:                    return args == null ? defaultValue : getParam(args[start],
152:                            defaultValue);
153:                if (param == PARAM_UNSPECIFIED)
154:                    return defaultValue;
155:                // Need to mask off flags etc?
156:                return param;
157:            }
158:
159:            protected static char getParam(int param, char defaultValue,
160:                    Object[] args, int start) {
161:                return (char) getParam(param, (int) defaultValue, args, start);
162:            }
163:
164:            /** Get the index'th parameter for the conversion specification specs[speci].
165:             * Note that parameters are numbered from 1 to numParams(speci).
166:             * The list of arguments to be converted is args, with the current index
167:             * (as of the start of this conversion, i.e. not taking into account
168:             * earlier PARAM_FROM_LIST paramaters for this conversion) in start.
169:             * The default value (used if PARAM_UNSPECIFIED) is defaultValue.
170:             */
171:            /*
172:            int getParam(int speci, int index, int defaultValue, Object[] args, int start)
173:            {
174:              int num_params = numParams(speci);
175:              int param = index <= num_params ? specs[speci+index] : PARAM_UNSPECIFIED;
176:              if (param == PARAM_FROM_LIST || param == PARAM_FROM_COUNT)
177:                start += adjustArgsStart(speci, index);
178:              return getParam(param, defaultValue, args, start);
179:            }
180:             */
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.