628
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.helium.ant.data;
|
|
19 |
|
|
20 |
import org.dom4j.DocumentFactory;
|
|
21 |
import org.dom4j.Element;
|
|
22 |
import org.dom4j.QName;
|
|
23 |
import org.xml.sax.Locator;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* A dom4j DocumentFactory that supports adding location information into Element objects.
|
|
27 |
*/
|
|
28 |
@SuppressWarnings("serial")
|
|
29 |
public class DocumentFactoryWithLocator extends DocumentFactory {
|
|
30 |
|
|
31 |
private SAXContentHandlerExt contentHandler;
|
|
32 |
|
|
33 |
public Element createElement(QName qname) {
|
|
34 |
ElementWithLocation element = new ElementWithLocation(qname);
|
|
35 |
Locator locator = contentHandler.getDocumentLocator();
|
|
36 |
element.setLocation(locator.getLineNumber(), locator.getColumnNumber());
|
|
37 |
return element;
|
|
38 |
}
|
|
39 |
|
|
40 |
public void setContentHandler(SAXContentHandlerExt contentHandler) {
|
|
41 |
this.contentHandler = contentHandler;
|
|
42 |
}
|
|
43 |
}
|