Source Code Cross Referenced for PropertyManagerTest.java in  » Graphic-Library » batik » org » apache » batik » css » engine » value » 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 » batik » org.apache.batik.css.engine.value 
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:        package org.apache.batik.css.engine.value;
019:
020:        import java.util.StringTokenizer;
021:
022:        import org.w3c.css.sac.LexicalUnit;
023:
024:        import org.apache.batik.css.engine.value.svg.MarkerManager;
025:        import org.apache.batik.css.engine.value.svg.OpacityManager;
026:        import org.apache.batik.css.engine.value.svg.SVGColorManager;
027:        import org.apache.batik.css.engine.value.svg.SVGPaintManager;
028:        import org.apache.batik.css.engine.value.svg.SpacingManager;
029:        import org.apache.batik.css.parser.Parser;
030:        import org.apache.batik.test.AbstractTest;
031:        import org.apache.batik.test.DefaultTestReport;
032:        import org.apache.batik.test.TestReport;
033:        import org.apache.batik.util.CSSConstants;
034:
035:        /**
036:         * The class to test the CSS properties's manager.
037:         *
038:         * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
039:         * @version $Id: PropertyManagerTest.java 482118 2006-12-04 09:52:54Z dvholten $
040:         */
041:        public class PropertyManagerTest extends AbstractTest {
042:
043:            /**
044:             * The error code for the 'is inherited' test.
045:             */
046:            public static final String ERROR_IS_INHERITED = "PropertyManagerTest.error.inherited";
047:
048:            /**
049:             * The error code if the property does not support the 'inherit' value.
050:             */
051:            public static final String ERROR_INHERIT_VALUE = "PropertyManagerTest.error.inherit.value";
052:
053:            /**
054:             * The error code for the 'default value' test.
055:             */
056:            public static final String ERROR_INVALID_DEFAULT_VALUE = "PropertyManagerTest.error.invalid.default.value";
057:
058:            /**
059:             * The error code for an invalid property value.
060:             */
061:            public static final String ERROR_INVALID_VALUE = "PropertyManagerTest.error.invalid.value";
062:
063:            /**
064:             * The error code if an exception occured while creating the manager.
065:             */
066:            public static final String ERROR_INSTANTIATION = "PropertyManagerTest.error.instantiation";
067:
068:            /**
069:             * The class of the manager.
070:             */
071:            protected String managerClassName;
072:
073:            /**
074:             * This flag bit indicates whether or not the property is inherited.
075:             */
076:            protected Boolean isInherited;
077:
078:            /**
079:             * The candidate values of the property.
080:             */
081:            protected String[] identValues;
082:
083:            /**
084:             * The candidate default value of the property.
085:             */
086:            protected String defaultValue;
087:
088:            /**
089:             * Constructs a new test for the specified manager classname.
090:             *
091:             * @param managerClassName the classname of the manager to test
092:             * @param isInherited the expected flag to see if the property is inherited
093:             * @param defaultValue the default value
094:             * @param identValueList the list of possible identifiers
095:             */
096:            public PropertyManagerTest(String managerClassName,
097:                    Boolean isInherited, String defaultValue,
098:                    String identValueList) {
099:                this .managerClassName = managerClassName;
100:                this .isInherited = isInherited;
101:                this .defaultValue = defaultValue;
102:                StringTokenizer tokens = new StringTokenizer(identValueList,
103:                        "|");
104:                int nbIdentValue = tokens.countTokens();
105:                if (nbIdentValue > 0) {
106:                    identValues = new String[nbIdentValue];
107:                    for (int i = 0; tokens.hasMoreTokens(); ++i) {
108:                        identValues[i] = tokens.nextToken().trim();
109:                    }
110:                }
111:            }
112:
113:            /**
114:             * Creates the value manager.
115:             */
116:            protected ValueManager createValueManager() throws Exception {
117:                return (ValueManager) Class.forName(managerClassName)
118:                        .newInstance();
119:            }
120:
121:            /**
122:             * Runs this test. This method will only throw exceptions if some aspect of
123:             * the test's internal operation fails.
124:             */
125:            public TestReport runImpl() throws Exception {
126:                DefaultTestReport report = new DefaultTestReport(this );
127:
128:                ValueManager manager;
129:                try {
130:                    manager = createValueManager();
131:                } catch (Exception ex) {
132:                    report.setErrorCode(ERROR_INSTANTIATION);
133:                    report.setPassed(false);
134:                    report.addDescriptionEntry(ERROR_INSTANTIATION, ex
135:                            .getMessage());
136:                    return report;
137:                }
138:
139:                // test default value if any
140:                if (!defaultValue.equals("__USER_AGENT__")) {
141:                    String s = manager.getDefaultValue().getCssText();
142:                    if (!defaultValue.equalsIgnoreCase(s)) {
143:                        report.setErrorCode(ERROR_INVALID_DEFAULT_VALUE);
144:                        report.setPassed(false);
145:                        report.addDescriptionEntry(ERROR_INVALID_DEFAULT_VALUE,
146:                                "should be: " + defaultValue);
147:                    }
148:                }
149:
150:                // test if the property is inherited or not
151:                if (isInherited.booleanValue() != manager.isInheritedProperty()) {
152:                    report.setErrorCode(ERROR_IS_INHERITED);
153:                    report.setPassed(false);
154:                    report.addDescriptionEntry(ERROR_IS_INHERITED, "");
155:                }
156:
157:                Parser cssParser = new Parser();
158:                // see if the property supports the value 'inherit'
159:                try {
160:                    LexicalUnit lu = cssParser.parsePropertyValue("inherit");
161:                    Value v = manager.createValue(lu, null);
162:                    String s = v.getCssText();
163:                    if (!"inherit".equalsIgnoreCase(s)) {
164:                        report.setErrorCode(ERROR_INHERIT_VALUE);
165:                        report.setPassed(false);
166:                        report.addDescriptionEntry(ERROR_INHERIT_VALUE,
167:                                "inherit");
168:                    }
169:                } catch (Exception ex) {
170:                    report.setErrorCode(ERROR_INHERIT_VALUE);
171:                    report.setPassed(false);
172:                    report.addDescriptionEntry(ERROR_INHERIT_VALUE, ex
173:                            .getMessage());
174:                }
175:
176:                // test all possible identifiers
177:                if (identValues != null) {
178:                    try {
179:                        for (int i = 0; i < identValues.length; ++i) {
180:                            LexicalUnit lu = cssParser
181:                                    .parsePropertyValue(identValues[i]);
182:                            Value v = manager.createValue(lu, null);
183:                            String s = v.getCssText();
184:                            if (!identValues[i].equalsIgnoreCase(s)) {
185:                                report.setErrorCode(ERROR_INVALID_VALUE);
186:                                report.setPassed(false);
187:                                report.addDescriptionEntry(ERROR_INVALID_VALUE,
188:                                        identValues[i] + '/' + s);
189:                            }
190:                        }
191:                    } catch (Exception ex) {
192:                        report.setErrorCode(ERROR_INVALID_VALUE);
193:                        report.setPassed(false);
194:                        report.addDescriptionEntry(ERROR_INVALID_VALUE, ex
195:                                .getMessage());
196:                    }
197:                }
198:                return report;
199:            }
200:
201:            /**
202:             * Manager for 'fill'.
203:             */
204:            public static class FillManager extends SVGPaintManager {
205:                public FillManager() {
206:                    super (CSSConstants.CSS_FILL_PROPERTY);
207:                }
208:            }
209:
210:            /**
211:             * Manager for 'fill-opacity'.
212:             */
213:            public static class FillOpacityManager extends OpacityManager {
214:                public FillOpacityManager() {
215:                    super (CSSConstants.CSS_FILL_OPACITY_PROPERTY, true);
216:                }
217:            }
218:
219:            /**
220:             * Manager for 'flood-color'.
221:             */
222:            public static class FloodColorManager extends SVGColorManager {
223:                public FloodColorManager() {
224:                    super (CSSConstants.CSS_FLOOD_COLOR_PROPERTY);
225:                }
226:            }
227:
228:            /**
229:             * Manager for 'flood-opacity'.
230:             */
231:            public static class FloodOpacityManager extends OpacityManager {
232:                public FloodOpacityManager() {
233:                    super (CSSConstants.CSS_FLOOD_OPACITY_PROPERTY, false);
234:                }
235:            }
236:
237:            /**
238:             * Manager for 'letter-spacing'.
239:             */
240:            public static class LetterSpacingManager extends SpacingManager {
241:                public LetterSpacingManager() {
242:                    super (CSSConstants.CSS_LETTER_SPACING_PROPERTY);
243:                }
244:            }
245:
246:            /**
247:             * Manager for 'lighting-color'.
248:             */
249:            public static class LightingColorManager extends SVGColorManager {
250:                public LightingColorManager() {
251:                    super (CSSConstants.CSS_LIGHTING_COLOR_PROPERTY,
252:                            ValueConstants.WHITE_RGB_VALUE);
253:                }
254:            }
255:
256:            /**
257:             * Manager for 'marker-end'.
258:             */
259:            public static class MarkerEndManager extends MarkerManager {
260:                public MarkerEndManager() {
261:                    super (CSSConstants.CSS_MARKER_END_PROPERTY);
262:                }
263:            }
264:
265:            /**
266:             * Manager for 'marker-mid'.
267:             */
268:            public static class MarkerMidManager extends MarkerManager {
269:                public MarkerMidManager() {
270:                    super (CSSConstants.CSS_MARKER_MID_PROPERTY);
271:                }
272:            }
273:
274:            /**
275:             * Manager for 'marker-start'.
276:             */
277:            public static class MarkerStartManager extends MarkerManager {
278:                public MarkerStartManager() {
279:                    super (CSSConstants.CSS_MARKER_START_PROPERTY);
280:                }
281:            }
282:
283:            /**
284:             * Manager for 'opacity'.
285:             */
286:            public static class DefaultOpacityManager extends OpacityManager {
287:                public DefaultOpacityManager() {
288:                    super (CSSConstants.CSS_OPACITY_PROPERTY, false);
289:                }
290:            }
291:
292:            /**
293:             * Manager for 'stop-color'.
294:             */
295:            public static class StopColorManager extends SVGColorManager {
296:                public StopColorManager() {
297:                    super (CSSConstants.CSS_STOP_COLOR_PROPERTY);
298:                }
299:            }
300:
301:            /**
302:             * Manager for 'stop-opacity'.
303:             */
304:            public static class StopOpacityManager extends OpacityManager {
305:                public StopOpacityManager() {
306:                    super (CSSConstants.CSS_STOP_OPACITY_PROPERTY, false);
307:                }
308:            }
309:
310:            /**
311:             * Manager for 'stroke'.
312:             */
313:            public static class StrokeManager extends SVGPaintManager {
314:                public StrokeManager() {
315:                    super (CSSConstants.CSS_STROKE_PROPERTY,
316:                            ValueConstants.NONE_VALUE);
317:                }
318:            }
319:
320:            /**
321:             * Manager for 'stroke-opacity'.
322:             */
323:            public static class StrokeOpacityManager extends OpacityManager {
324:                public StrokeOpacityManager() {
325:                    super (CSSConstants.CSS_STROKE_OPACITY_PROPERTY, true);
326:                }
327:            }
328:
329:            /**
330:             * Manager for 'word-spacing'.
331:             */
332:            public static class WordSpacingManager extends SpacingManager {
333:                public WordSpacingManager() {
334:                    super(CSSConstants.CSS_WORD_SPACING_PROPERTY);
335:                }
336:            }
337:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.