author | mkos |
Sun, 30 Dec 2012 00:00:00 +0100 | |
changeset 22678 | ac1ea46be942 |
parent 12009 | 4abb694f273a |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
22678
ac1ea46be942
8029237: Update copyright year to match last edit in jaxws repository for 2012
mkos
parents:
12009
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.tools.internal.xjc.reader.dtd.bindinfo; |
|
27 |
||
28 |
import org.w3c.dom.Element; |
|
29 |
import org.xml.sax.Locator; |
|
30 |
||
31 |
class DOMLocator { |
|
32 |
private static final String locationNamespace = |
|
33 |
"http://www.sun.com/xmlns/jaxb/dom-location"; |
|
34 |
private static final String systemId = "systemid"; |
|
35 |
private static final String column = "column"; |
|
36 |
private static final String line = "line"; |
|
37 |
||
38 |
/** Sets the location information to a specified element. */ |
|
39 |
public static void setLocationInfo( Element e, Locator loc ) { |
|
40 |
e.setAttributeNS(locationNamespace,"loc:"+systemId,loc.getSystemId()); |
|
41 |
e.setAttributeNS(locationNamespace,"loc:"+column,Integer.toString(loc.getLineNumber())); |
|
42 |
e.setAttributeNS(locationNamespace,"loc:"+line,Integer.toString(loc.getColumnNumber())); |
|
43 |
} |
|
44 |
||
45 |
/** |
|
46 |
* Gets the location information from an element. |
|
47 |
* |
|
48 |
* <p> |
|
49 |
* For this method to work, the setLocationInfo method has to be |
|
50 |
* called before. |
|
51 |
*/ |
|
52 |
public static Locator getLocationInfo( final Element e ) { |
|
53 |
if(DOMUtil.getAttribute(e,locationNamespace,systemId)==null) |
|
54 |
return null; // no location information |
|
55 |
||
56 |
return new Locator(){ |
|
57 |
public int getLineNumber() { |
|
58 |
return Integer.parseInt(DOMUtil.getAttribute(e,locationNamespace,line)); |
|
59 |
} |
|
60 |
public int getColumnNumber() { |
|
61 |
return Integer.parseInt(DOMUtil.getAttribute(e,locationNamespace,column)); |
|
62 |
} |
|
63 |
public String getSystemId() { |
|
64 |
return DOMUtil.getAttribute(e,locationNamespace,systemId); |
|
65 |
} |
|
66 |
// we are not interested in PUBLIC ID. |
|
67 |
public String getPublicId() { return null; } |
|
68 |
}; |
|
69 |
} |
|
70 |
} |