Source Code Cross Referenced for BridgeException.java in  » Graphic-Library » batik » org » apache » batik » bridge » 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.bridge 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Licensed to the Apache Software Foundation (ASF) under one or more
004:           contributor license agreements.  See the NOTICE file distributed with
005:           this work for additional information regarding copyright ownership.
006:           The ASF licenses this file to You under the Apache License, Version 2.0
007:           (the "License"); you may not use this file except in compliance with
008:           the License.  You may obtain a copy of the License at
009:
010:               http://www.apache.org/licenses/LICENSE-2.0
011:
012:           Unless required by applicable law or agreed to in writing, software
013:           distributed under the License is distributed on an "AS IS" BASIS,
014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:           See the License for the specific language governing permissions and
016:           limitations under the License.
017:
018:         */
019:        package org.apache.batik.bridge;
020:
021:        import org.apache.batik.dom.svg.LiveAttributeException;
022:        import org.apache.batik.gvt.GraphicsNode;
023:
024:        import org.w3c.dom.Element;
025:        import org.w3c.dom.svg.SVGDocument;
026:
027:        /**
028:         * Thrown when the bridge has detected an error.
029:         *
030:         * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
031:         * @version $Id: BridgeException.java 501922 2007-01-31 17:47:47Z dvholten $
032:         */
033:        public class BridgeException extends RuntimeException {
034:
035:            /** The element on which the error occured. */
036:            protected Element e;
037:
038:            /** The error code. */
039:            protected String code;
040:
041:            /**
042:             * The message.
043:             */
044:            protected String message;
045:
046:            /** The paramters to use for the error message. */
047:            protected Object[] params;
048:
049:            /** The line number on which the error occured. */
050:            protected int line;
051:
052:            /** The graphics node that represents the current state of the GVT tree. */
053:            protected GraphicsNode node;
054:
055:            /**
056:             * Constructs a new <tt>BridgeException</tt> based on the specified
057:             * <tt>LiveAttributeException</tt>.
058:             *
059:             * @param ctx the bridge context to use for determining the element's
060:             *            source position
061:             * @param ex the {@link LiveAttributeException}
062:             */
063:            public BridgeException(BridgeContext ctx, LiveAttributeException ex) {
064:                switch (ex.getCode()) {
065:                case LiveAttributeException.ERR_ATTRIBUTE_MISSING:
066:                    this .code = ErrorConstants.ERR_ATTRIBUTE_MISSING;
067:                    break;
068:                case LiveAttributeException.ERR_ATTRIBUTE_MALFORMED:
069:                    this .code = ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED;
070:                    break;
071:                case LiveAttributeException.ERR_ATTRIBUTE_NEGATIVE:
072:                    this .code = ErrorConstants.ERR_LENGTH_NEGATIVE;
073:                    break;
074:                default:
075:                    throw new IllegalStateException(
076:                            "Unknown LiveAttributeException error code "
077:                                    + ex.getCode());
078:                }
079:                this .e = ex.getElement();
080:                this .params = new Object[] { ex.getAttributeName(),
081:                        ex.getValue() };
082:                if (e != null && ctx != null) {
083:                    this .line = ctx.getDocumentLoader().getLineNumber(e);
084:                }
085:            }
086:
087:            /**
088:             * Constructs a new <tt>BridgeException</tt> with the specified parameters.
089:             *
090:             * @param ctx the bridge context to use for determining the element's
091:             *            source position
092:             * @param e the element on which the error occurred
093:             * @param code the error code
094:             * @param params the parameters to use for the error message
095:             */
096:            public BridgeException(BridgeContext ctx, Element e, String code,
097:                    Object[] params) {
098:
099:                this .e = e;
100:                this .code = code;
101:                this .params = params;
102:                if (e != null && ctx != null) {
103:                    this .line = ctx.getDocumentLoader().getLineNumber(e);
104:                }
105:            }
106:
107:            /**
108:             * Constructs a new <tt>BridgeException</tt> with the specified parameters.
109:             *
110:             * @param ctx the bridge context to use for determining the element's
111:             *            source position
112:             * @param e the element on which the error occurred
113:             * @param ex the exception which was the root-cause for this exception
114:             * @param code the error code
115:             * @param params the parameters to use for the error message
116:             */
117:            public BridgeException(BridgeContext ctx, Element e, Exception ex,
118:                    String code, Object[] params) {
119:
120:                // todo ex can be chained in jdk >= 1.4
121:                this .e = e;
122:
123:                message = ex.getMessage();
124:                this .code = code;
125:                this .params = params;
126:                if (e != null && ctx != null) {
127:                    this .line = ctx.getDocumentLoader().getLineNumber(e);
128:                }
129:            }
130:
131:            /**
132:             * Constructs a new <tt>BridgeException</tt> with the specified parameters.
133:             *
134:             * @param ctx the bridge context to use for determining the element's
135:             *            source position
136:             * @param e the element on which the error occurred
137:             * @param message the error message
138:             */
139:            public BridgeException(BridgeContext ctx, Element e, String message) {
140:                this .e = e;
141:                this .message = message;
142:                if (e != null && ctx != null) {
143:                    this .line = ctx.getDocumentLoader().getLineNumber(e);
144:                }
145:            }
146:
147:            /**
148:             * Returns the element on which the error occurred.
149:             */
150:            public Element getElement() {
151:                return e;
152:            }
153:
154:            /**
155:             * Sets the graphics node that represents the current GVT tree built.
156:             *
157:             * @param node the graphics node
158:             */
159:            public void setGraphicsNode(GraphicsNode node) {
160:                this .node = node;
161:            }
162:
163:            /**
164:             * Returns the graphics node that represents the current GVT tree built.
165:             */
166:            public GraphicsNode getGraphicsNode() {
167:                return node;
168:            }
169:
170:            /**
171:             * Returns the error message according to the error code and parameters.
172:             */
173:            public String getMessage() {
174:                if (message != null) {
175:                    return message;
176:                }
177:
178:                String uri;
179:                String lname = "<Unknown Element>";
180:                SVGDocument doc = null;
181:                if (e != null) {
182:                    doc = (SVGDocument) e.getOwnerDocument();
183:                    lname = e.getLocalName();
184:                }
185:                if (doc == null)
186:                    uri = "<Unknown Document>";
187:                else
188:                    uri = doc.getURL();
189:                Object[] fullparams = new Object[params.length + 3];
190:                fullparams[0] = uri;
191:                fullparams[1] = new Integer(line);
192:                fullparams[2] = lname;
193:                System.arraycopy(params, 0, fullparams, 3, params.length);
194:                return Messages.formatMessage(code, fullparams);
195:            }
196:
197:            /**
198:             * Returns the exception's error code
199:             */
200:            public String getCode() {
201:                return code;
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.