1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.core.metapath.cst.items;
7   
8   import dev.metaschema.core.metapath.cst.AbstractExpression;
9   import dev.metaschema.core.metapath.item.function.IArrayItem;
10  import dev.metaschema.core.metapath.item.function.IKeySpecifier;
11  import dev.metaschema.core.metapath.item.function.IMapItem;
12  import edu.umd.cs.findbugs.annotations.NonNull;
13  
14  /**
15   * An implementation of
16   * <a href="https://www.w3.org/TR/xpath-31/#id-lookup">Lookup Operators</a>
17   * supporting access to items in Metapath maps and arrays.
18   * <p>
19   * Provides support for various types of key- and index-based lookups related to
20   * {@link IMapItem} and {@link IArrayItem} objects.
21   */
22  public abstract class AbstractLookup
23      extends AbstractExpression {
24    @NonNull
25    private final IKeySpecifier keySpecifier;
26  
27    /**
28     * Construct a new lookup expression that uses the provided key specifier.
29     *
30     * @param text
31     *          the parsed text of the expression
32     * @param keySpecifier
33     *          the key specifier that identifies how to lookup entries
34     */
35    protected AbstractLookup(@NonNull String text, @NonNull IKeySpecifier keySpecifier) {
36      super(text);
37      this.keySpecifier = keySpecifier;
38    }
39  
40    /**
41     * Get the key specifier implementation.
42     *
43     * @return the key specifier
44     */
45    @NonNull
46    public IKeySpecifier getKeySpecifier() {
47      return keySpecifier;
48    }
49  }