| 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.wrapper; |
| 9 | |
| 10 | import net.sf.saxon.Configuration; |
| 11 | import net.sf.saxon.om.GenericTreeInfo; |
| 12 | |
| 13 | import java.util.Iterator; |
| 14 | |
| 15 | /** |
| 16 | * Implementation of TreeInfo for a Virtual Copy tree |
| 17 | */ |
| 18 | public class VirtualTreeInfo extends GenericTreeInfo { |
| 19 | |
| 20 | private boolean copyAccumulators; |
| 21 | |
| 22 | |
| 23 | public VirtualTreeInfo(Configuration config) { |
| 24 | super(config); |
| 25 | } |
| 26 | |
| 27 | public VirtualTreeInfo(Configuration config, VirtualCopy vc) { |
| 28 | super(config, vc); |
| 29 | } |
| 30 | |
| 31 | public void setCopyAccumulators(boolean copy) { |
| 32 | this.copyAccumulators = copy; |
| 33 | } |
| 34 | |
| 35 | public boolean isCopyAccumulators() { |
| 36 | return copyAccumulators; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Get the list of unparsed entities defined in this document |
| 41 | * |
| 42 | * @return an Iterator, whose items are of type String, containing the names of all |
| 43 | * unparsed entities defined in this document. If there are no unparsed entities or if the |
| 44 | * information is not available then an empty iterator is returned |
| 45 | * @since 9.1 |
| 46 | */ |
| 47 | @Override |
| 48 | public Iterator<String> getUnparsedEntityNames() { |
| 49 | return ((VirtualCopy)getRootNode()).getOriginalNode().getTreeInfo().getUnparsedEntityNames(); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Get the unparsed entity with a given name |
| 54 | * |
| 55 | * @param name the name of the entity |
| 56 | * @return if the entity exists, return an array of two Strings, the first |
| 57 | * holding the system ID of the entity (as an absolute URI if possible), |
| 58 | * the second holding the public ID if there is one, or null if not. |
| 59 | * If the entity does not exist, the method returns null. |
| 60 | * Applications should be written on the assumption that this array may |
| 61 | * be extended in the future to provide additional information. |
| 62 | * @since 8.4 |
| 63 | */ |
| 64 | @Override |
| 65 | public String[] getUnparsedEntity(String name) { |
| 66 | return ((VirtualCopy) getRootNode()).getOriginalNode().getTreeInfo().getUnparsedEntity(name); |
| 67 | } |
| 68 | } |
| 69 |