Debian Codegraph @

net/sf/saxon/tree/iter/UnparsedTextIterator.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.tree.iter;
9
10 import net.sf.saxon.Configuration;
11 import net.sf.saxon.expr.XPathContext;
12 import net.sf.saxon.expr.parser.Location;
13 import net.sf.saxon.trans.XPathException;
14
15 import java.io.LineNumberReader;
16 import java.io.Reader;
17 import java.net.URI;
18
19 /**
20 * Class UnparsedTextIterator, iterates over a file line by line
21 */
22 public class UnparsedTextIterator extends TextLinesIterator {
23
24 XPathContext context;
25 String encoding = null;
26
27 /**
28 * Create a UnparsedTextIterator over a given file
29 *
30 * @param absoluteURI the URI identifying the file
31 * @param context the dynamic evaluation context
32 * @param encoding the expected encoding of the file
33 * @param location the location of the instruction being executed
34 * @throws XPathException if a dynamic error occurs
35 */
36
37 public UnparsedTextIterator(URI absoluteURI, /*@NotNull*/ XPathContext context, String encoding, Location location) throws XPathException {
38 Configuration config = context.getConfiguration();
39 Reader reader = context.getController().getUnparsedTextURIResolver().resolve(absoluteURI, encoding, config);
40 // Note: this relies on the fact that LineNumberReader use the same definition of line endings as the unparsed-text-lines()
41 // function.
42
43 this.reader = new LineNumberReader(reader);
44 this.uri = absoluteURI;
45 this.context = context;
46 this.checker = context.getConfiguration().getValidCharacterChecker();
47 this.encoding = encoding;
48 this.location = location;
49 }
50
51 public UnparsedTextIterator(LineNumberReader reader, URI absoluteURI, /*@NotNull*/ XPathContext context, String encoding) throws XPathException {
52 this.reader = reader;
53 this.uri = absoluteURI;
54 this.context = context;
55 this.checker = context.getConfiguration().getValidCharacterChecker();
56 this.encoding = encoding;
57 this.location = null;
58 }
59
60 }
61