KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > event > LocationCopier


1 package net.sf.saxon.event;
2
3 /**
4  * A Receiver that can be inserted into an event pipeline to copy location information.
5  * The class acts as a LocationProvider, so it supports getSystemId() and getLineNumber() methods;
6  * the location returned can vary for each node, and is set by the class generating the events.
7  * The class is used when it is necessary to copy a subtree along with its location information;
8  * for example, when copying an inline schema within a stylesheet to a separate schema document.
9  */

10
11 public class LocationCopier extends ProxyReceiver implements LocationProvider {
12
13     public int lineNumber;
14
15     public void setPipelineConfiguration(PipelineConfiguration pipe) {
16         PipelineConfiguration pipe2 = new PipelineConfiguration(pipe);
17         pipe2.setLocationProvider(this);
18         super.setPipelineConfiguration(pipe2);
19     }
20
21     public void setLineNumber(int lineNumber) {
22         this.lineNumber = lineNumber;
23     }
24
25     public int getColumnNumber() {
26         return -1;
27     }
28
29     public int getLineNumber() {
30         return lineNumber;
31     }
32
33     public String JavaDoc getPublicId() {
34         return null;
35     }
36
37     public String JavaDoc getSystemId(int locationId) {
38         return getSystemId();
39     }
40
41     public int getLineNumber(int locationId) {
42         return getLineNumber();
43     }
44 }
45
46 //
47
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
48
// you may not use this file except in compliance with the License. You may obtain a copy of the
49
// License at http://www.mozilla.org/MPL/
50
//
51
// Software distributed under the License is distributed on an "AS IS" basis,
52
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
53
// See the License for the specific language governing rights and limitations under the License.
54
//
55
// The Original Code is: all this file.
56
//
57
// The Initial Developer of the Original Code is Michael H. Kay.
58
//
59
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
60
//
61
// Contributor(s): None
62
//
63
Popular Tags