KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > pull > DocumentEventIgnorer


1 package net.sf.saxon.pull;
2
3 import net.sf.saxon.trans.XPathException;
4
5 /**
6  * This is a filter that can be added to a pull pipeline to remove START_DOCUMENT and END_DOCUMENT
7  * events.
8  */

9 public class DocumentEventIgnorer extends PullFilter {
10
11     public DocumentEventIgnorer(PullProvider base) {
12         super(base);
13     }
14
15     /**
16      * Get the next event.
17      * <p/>
18      * <p>Note that a subclass that overrides this method is responsible for ensuring
19      * that current() works properly. This can be achieved by setting the field
20      * currentEvent to the event returned by any call on next().</p>
21      *
22      * @return an integer code indicating the type of event. The code
23      * {@link #END_OF_INPUT} is returned at the end of the sequence.
24      */

25
26     public int next() throws XPathException {
27         do {
28             currentEvent = super.next();
29         } while (currentEvent == START_DOCUMENT || currentEvent == END_DOCUMENT);
30         return currentEvent;
31     }
32 }
33
34 //
35
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
36
// you may not use this file except in compliance with the License. You may obtain a copy of the
37
// License at http://www.mozilla.org/MPL/
38
//
39
// Software distributed under the License is distributed on an "AS IS" basis,
40
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
41
// See the License for the specific language governing rights and limitations under the License.
42
//
43
// The Original Code is: all this file.
44
//
45
// The Initial Developer of the Original Code is Michael H. Kay.
46
//
47
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
48
//
49
// Contributor(s): none.
50
//
51
Popular Tags