| 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.trace; |
| 9 | |
| 10 | import net.sf.saxon.expr.parser.Location; |
| 11 | import net.sf.saxon.om.StructuredQName; |
| 12 | |
| 13 | import java.util.Iterator; |
| 14 | |
| 15 | |
| 16 | /** |
| 17 | * Information about an instruction in the stylesheet or a construct in a Query, made |
| 18 | * available at run-time to a TraceListener. Although the class is mainly used to provide |
| 19 | * information for diagnostics, it also has a role in detecting circularities among |
| 20 | * global variables. |
| 21 | */ |
| 22 | |
| 23 | public interface InstructionInfo extends Location { |
| 24 | |
| 25 | /** |
| 26 | * Get the type of construct. This will either be the fingerprint of a standard XSLT instruction name |
| 27 | * (values in {@link net.sf.saxon.om.StandardNames}: all less than 1024) |
| 28 | * or it will be a constant in class {@link LocationKind}. |
| 29 | * |
| 30 | * @return an integer identifying the kind of construct |
| 31 | */ |
| 32 | |
| 33 | int getConstructType(); |
| 34 | |
| 35 | /** |
| 36 | * Get a name identifying the object of the expression, for example a function name, template name, |
| 37 | * variable name, key name, element name, etc. This is used only where the name is known statically. |
| 38 | * |
| 39 | * @return the QName of the object declared or manipulated by this instruction or expression |
| 40 | */ |
| 41 | |
| 42 | /*@Nullable*/ |
| 43 | StructuredQName getObjectName(); |
| 44 | |
| 45 | /** |
| 46 | * Get the value of a particular property of the instruction. Properties |
| 47 | * of XSLT instructions are generally known by the name of the stylesheet attribute |
| 48 | * that defines them. |
| 49 | * |
| 50 | * @param name The name of the required property |
| 51 | * @return The value of the requested property, or null if the property is not available |
| 52 | */ |
| 53 | |
| 54 | /*@Nullable*/ |
| 55 | Object getProperty(String name); |
| 56 | |
| 57 | /** |
| 58 | * Get an iterator over all the properties available. The values returned by the iterator |
| 59 | * will be of type String, and each string can be supplied as input to the getProperty() |
| 60 | * method to retrieve the value of the property. The iterator may return properties whose |
| 61 | * value is null. |
| 62 | * |
| 63 | * @return an iterator over the properties. |
| 64 | */ |
| 65 | |
| 66 | Iterator<String> getProperties(); |
| 67 | |
| 68 | } |
| 69 |