Source Code Cross Referenced for ValidationEventLocatorImpl.java in  » 6.0-JDK-Modules » jaxb-api » javax » xml » bind » helpers » 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 » jaxb api » javax.xml.bind.helpers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
003:         * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
004:         */
005:        package javax.xml.bind.helpers;
006:
007:        import java.net.URL;
008:        import java.net.MalformedURLException;
009:        import java.text.MessageFormat;
010:
011:        import javax.xml.bind.ValidationEventLocator;
012:        import org.w3c.dom.Node;
013:        import org.xml.sax.Locator;
014:        import org.xml.sax.SAXParseException;
015:
016:        /**
017:         * Default implementation of the ValidationEventLocator interface.
018:         * 
019:         * <p>
020:         * JAXB providers are allowed to use whatever class that implements
021:         * the ValidationEventLocator interface. This class is just provided for a
022:         * convenience.
023:         *
024:         * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li></ul> 
025:         * @version $Revision: 1.2 $
026:         * @see javax.xml.bind.Validator
027:         * @see javax.xml.bind.ValidationEventHandler
028:         * @see javax.xml.bind.ValidationEvent
029:         * @see javax.xml.bind.ValidationEventLocator
030:         * @since JAXB1.0
031:         */
032:        public class ValidationEventLocatorImpl implements 
033:                ValidationEventLocator {
034:            /**
035:             * Creates an object with all fields unavailable.
036:             */
037:            public ValidationEventLocatorImpl() {
038:            }
039:
040:            /** 
041:             * Constructs an object from an org.xml.sax.Locator. 
042:             * 
043:             * The object's ColumnNumber, LineNumber, and URL become available from the 
044:             * values returned by the locator's getColumnNumber(), getLineNumber(), and
045:             * getSystemId() methods respectively. Node, Object, and Offset are not 
046:             * available. 
047:             * 
048:             * @param loc the SAX Locator object that will be used to populate this
049:             * event locator.
050:             * @throws IllegalArgumentException if the Locator is null
051:             */
052:            public ValidationEventLocatorImpl(Locator loc) {
053:                if (loc == null) {
054:                    throw new IllegalArgumentException(Messages.format(
055:                            Messages.MUST_NOT_BE_NULL, "loc"));
056:                }
057:
058:                this .url = toURL(loc.getSystemId());
059:                this .columnNumber = loc.getColumnNumber();
060:                this .lineNumber = loc.getLineNumber();
061:            }
062:
063:            /** 
064:             * Constructs an object from the location information of a SAXParseException. 
065:             * 
066:             * The object's ColumnNumber, LineNumber, and URL become available from the 
067:             * values returned by the locator's getColumnNumber(), getLineNumber(), and
068:             * getSystemId() methods respectively. Node, Object, and Offset are not 
069:             * available. 
070:             * 
071:             * @param e the SAXParseException object that will be used to populate this
072:             * event locator.
073:             * @throws IllegalArgumentException if the SAXParseException is null
074:             */
075:            public ValidationEventLocatorImpl(SAXParseException e) {
076:                if (e == null) {
077:                    throw new IllegalArgumentException(Messages.format(
078:                            Messages.MUST_NOT_BE_NULL, "e"));
079:                }
080:
081:                this .url = toURL(e.getSystemId());
082:                this .columnNumber = e.getColumnNumber();
083:                this .lineNumber = e.getLineNumber();
084:            }
085:
086:            /** 
087:             * Constructs an object that points to a DOM Node. 
088:             * 
089:             * The object's Node becomes available.  ColumnNumber, LineNumber, Object, 
090:             * Offset, and URL are not available.
091:             * 
092:             * @param _node the DOM Node object that will be used to populate this
093:             * event locator.
094:             * @throws IllegalArgumentException if the Node is null
095:             */
096:            public ValidationEventLocatorImpl(Node _node) {
097:                if (_node == null) {
098:                    throw new IllegalArgumentException(Messages.format(
099:                            Messages.MUST_NOT_BE_NULL, "_node"));
100:                }
101:
102:                this .node = _node;
103:            }
104:
105:            /** 
106:             * Constructs an object that points to a JAXB content object. 
107:             * 
108:             * The object's Object becomes available. ColumnNumber, LineNumber, Node, 
109:             * Offset, and URL are not available.
110:             * 
111:             * @param _object the Object that will be used to populate this
112:             * event locator.
113:             * @throws IllegalArgumentException if the Object is null
114:             */
115:            public ValidationEventLocatorImpl(Object _object) {
116:                if (_object == null) {
117:                    throw new IllegalArgumentException(Messages.format(
118:                            Messages.MUST_NOT_BE_NULL, "_object"));
119:                }
120:
121:                this .object = _object;
122:            }
123:
124:            /** Converts a system ID to an URL object. */
125:            private static URL toURL(String systemId) {
126:                try {
127:                    return new URL(systemId);
128:                } catch (MalformedURLException e) {
129:                    // TODO: how should we handle system id here?
130:                    return null; // for now
131:                }
132:            }
133:
134:            private URL url = null;
135:            private int offset = -1;
136:            private int lineNumber = -1;
137:            private int columnNumber = -1;
138:            private Object object = null;
139:            private Node node = null;
140:
141:            /**
142:             * @see javax.xml.bind.ValidationEventLocator#getURL()
143:             */
144:            public URL getURL() {
145:                return url;
146:            }
147:
148:            /**
149:             * Set the URL field on this event locator.  Null values are allowed.
150:             * 
151:             * @param _url the url
152:             */
153:            public void setURL(URL _url) {
154:                this .url = _url;
155:            }
156:
157:            /**
158:             * @see javax.xml.bind.ValidationEventLocator#getOffset()
159:             */
160:            public int getOffset() {
161:                return offset;
162:            }
163:
164:            /**
165:             * Set the offset field on this event locator.  
166:             * 
167:             * @param _offset the offset
168:             */
169:            public void setOffset(int _offset) {
170:                this .offset = _offset;
171:            }
172:
173:            /**
174:             * @see javax.xml.bind.ValidationEventLocator#getLineNumber()
175:             */
176:            public int getLineNumber() {
177:                return lineNumber;
178:            }
179:
180:            /**
181:             * Set the lineNumber field on this event locator.
182:             * 
183:             * @param _lineNumber the line number
184:             */
185:            public void setLineNumber(int _lineNumber) {
186:                this .lineNumber = _lineNumber;
187:            }
188:
189:            /**
190:             * @see javax.xml.bind.ValidationEventLocator#getColumnNumber()
191:             */
192:            public int getColumnNumber() {
193:                return columnNumber;
194:            }
195:
196:            /**
197:             * Set the columnNumber field on this event locator.
198:             * 
199:             * @param _columnNumber the column number
200:             */
201:            public void setColumnNumber(int _columnNumber) {
202:                this .columnNumber = _columnNumber;
203:            }
204:
205:            /**
206:             * @see javax.xml.bind.ValidationEventLocator#getObject()
207:             */
208:            public Object getObject() {
209:                return object;
210:            }
211:
212:            /**
213:             * Set the Object field on this event locator.  Null values are allowed.
214:             * 
215:             * @param _object the java content object
216:             */
217:            public void setObject(Object _object) {
218:                this .object = _object;
219:            }
220:
221:            /**
222:             * @see javax.xml.bind.ValidationEventLocator#getNode()
223:             */
224:            public Node getNode() {
225:                return node;
226:            }
227:
228:            /**
229:             * Set the Node field on this event locator.  Null values are allowed.
230:             * 
231:             * @param _node the Node
232:             */
233:            public void setNode(Node _node) {
234:                this .node = _node;
235:            }
236:
237:            /**
238:             * Returns a string representation of this object in a format
239:             * helpful to debugging.
240:             * 
241:             * @see Object#equals(Object)
242:             */
243:            public String toString() {
244:                return MessageFormat
245:                        .format(
246:                                "[node={0},object={1},url={2},line={3},col={4},offset={5}]",
247:                                getNode(), getObject(), getURL(), String
248:                                        .valueOf(getLineNumber()), String
249:                                        .valueOf(getColumnNumber()), String
250:                                        .valueOf(getOffset()));
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.