Source Code Cross Referenced for RtfAttributes.java in  » Graphic-Library » fop » org » apache » fop » render » rtf » rtflib » rtfdoc » 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 » Graphic Library » fop » org.apache.fop.render.rtf.rtflib.rtfdoc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id: RtfAttributes.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020:        package org.apache.fop.render.rtf.rtflib.rtfdoc;
021:
022:        /*
023:         * This file is part of the RTF library of the FOP project, which was originally
024:         * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
025:         * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
026:         * the FOP project.
027:         */
028:
029:        import java.util.HashMap;
030:        import java.util.Iterator;
031:        import org.xml.sax.Attributes;
032:        import org.xml.sax.helpers.AttributesImpl;
033:
034:        /**  Attributes for RtfText
035:         *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
036:         */
037:
038:        public class RtfAttributes implements  java.lang.Cloneable {
039:            private HashMap values = new HashMap();
040:
041:            /**
042:             * Set attributes from another attributes object
043:             * @param attrs RtfAttributes object whose elements will be copied into this
044:             *        instance
045:             * @return this object, for chaining calls
046:             */
047:            public RtfAttributes set(RtfAttributes attrs) {
048:                if (attrs != null) {
049:                    Iterator it = attrs.nameIterator();
050:                    while (it.hasNext()) {
051:                        String name = (String) it.next();
052:                        if (attrs.getValue(name) instanceof  Integer) {
053:                            Integer value = (Integer) attrs.getValue(name);
054:                            if (value == null) {
055:                                set(name);
056:                            } else {
057:                                set(name, value.intValue());
058:                            }
059:                        } else if (attrs.getValue(name) instanceof  String) {
060:                            String value = (String) attrs.getValue(name);
061:                            if (value == null) {
062:                                set(name);
063:                            } else {
064:                                set(name, value);
065:                            }
066:                        } else {
067:                            set(name);
068:                        }
069:
070:                    }
071:                    // indicate the XSL attributes used to build the Rtf attributes
072:                    setXslAttributes(attrs.getXslAttributes());
073:                }
074:                return this ;
075:            }
076:
077:            /**
078:             * set an attribute that has no value.
079:             * @param name name of attribute to set
080:             * @return this object, for chaining calls
081:             */
082:            public RtfAttributes set(String name) {
083:                values.put(name, null);
084:                return this ;
085:            }
086:
087:            /**
088:             * unset an attribute that has no value
089:             * @param name name of attribute to unset
090:             * @return this object, for chaining calls
091:             */
092:            public RtfAttributes unset(String name) {
093:                values.remove(name);
094:                return this ;
095:            }
096:
097:            /**
098:             * debugging log
099:             * @return String representation of object
100:             */
101:            public String toString() {
102:                return values.toString() + "(" + super .toString() + ")";
103:            }
104:
105:            /**
106:             * implement cloning
107:             * @return cloned Object
108:             */
109:            public Object clone() {
110:                final RtfAttributes result = new RtfAttributes();
111:                result.values = (HashMap) values.clone();
112:
113:                // Added by Normand Masse
114:                // indicate the XSL attributes used to build the Rtf attributes
115:                if (xslAttributes != null) {
116:                    result.xslAttributes = new org.xml.sax.helpers.AttributesImpl(
117:                            xslAttributes);
118:                }
119:
120:                return result;
121:            }
122:
123:            /**
124:             * Set an attribute that has an integer value
125:             * @param name name of attribute
126:             * @param value value of attribute
127:             * @return this (which now contains the new entry), for chaining calls
128:             */
129:            public RtfAttributes set(String name, int value) {
130:                values.put(name, new Integer(value));
131:                return this ;
132:            }
133:
134:            /**
135:             * Set an attribute that has a String value
136:             * @param name name of attribute
137:             * @param type value of attribute
138:             * @return this (which now contains the new entry)
139:             */
140:            public RtfAttributes set(String name, String type) {
141:                values.put(name, type);
142:                return this ;
143:            }
144:
145:            /**
146:             * Set an attribute that has nested attributes as value
147:             * @param name name of attribute
148:             * @param value value of the nested attributes
149:             * @return this (which now contains the new entry)
150:             */
151:            public RtfAttributes set(String name, RtfAttributes value) {
152:                values.put(name, value);
153:                return this ;
154:            }
155:
156:            /**
157:             * @param name String containing attribute name
158:             * @return the value of an attribute, null if not found
159:             */
160:            public Object getValue(String name) {
161:                return values.get(name);
162:            }
163:
164:            /**
165:             * @param name String containing attribute name
166:             * @return true if given attribute is set
167:             */
168:            public boolean isSet(String name) {
169:                return values.containsKey(name);
170:            }
171:
172:            /** @return an Iterator on all names that are set */
173:            public Iterator nameIterator() {
174:                return values.keySet().iterator();
175:            }
176:
177:            private Attributes xslAttributes = null;
178:
179:            /**
180:             * Added by Normand Masse
181:             * Used for attribute inheritance
182:             * @return Attributes
183:             */
184:            public Attributes getXslAttributes() {
185:                return xslAttributes;
186:            }
187:
188:            /**
189:             * Added by Normand Masse
190:             * Used for attribute inheritance
191:             * @param pAttribs attributes
192:             */
193:            public void setXslAttributes(Attributes pAttribs) {
194:                if (pAttribs == null) {
195:                    return;
196:                }
197:                // copy/replace the xsl attributes into the current attributes
198:                if (xslAttributes != null) {
199:                    for (int i = 0; i < pAttribs.getLength(); i++) {
200:                        String wKey = pAttribs.getQName(i);
201:                        int wPos = xslAttributes.getIndex(wKey);
202:                        if (wPos == -1) {
203:                            ((AttributesImpl) xslAttributes).addAttribute(
204:                                    pAttribs.getURI(i), pAttribs
205:                                            .getLocalName(i), pAttribs
206:                                            .getQName(i), pAttribs.getType(i),
207:                                    pAttribs.getValue(i));
208:                        } else {
209:                            ((AttributesImpl) xslAttributes).setAttribute(wPos,
210:                                    pAttribs.getURI(i), pAttribs
211:                                            .getLocalName(i), pAttribs
212:                                            .getQName(i), pAttribs.getType(i),
213:                                    pAttribs.getValue(i));
214:                        }
215:                    }
216:                } else {
217:                    xslAttributes = new org.xml.sax.helpers.AttributesImpl(
218:                            pAttribs);
219:                }
220:            }
221:
222:            /**
223:             * Add integer value <code>addValue</code> to attribute with name <code>name</code>.
224:             * If there is no such setted attribute, then value of this attribure is equal to 
225:             * <code>addValue</code>.
226:             * @param addValue the increment of value
227:             * @param name the name of attribute
228:             */
229:            public void addIntegerValue(int addValue, String name) {
230:                Integer value = (Integer) getValue(name);
231:                int v = (value != null) ? value.intValue() : 0;
232:                set(name, v + addValue);
233:            }
234:        }
ww___w.__j_av_a2___s___._c___om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.