src/java.xml/share/classes/com/sun/org/apache/xpath/internal/objects/XRTreeFragSelectWrapper.java
author joehw
Wed, 18 Oct 2017 13:25:49 -0700
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
permissions -rw-r--r--
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked Reviewed-by: lancea, rriggs, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
     3
 * @LastModified: Oct 2017
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     8
 * this work for additional information regarding copyright ownership.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    11
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 */
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    21
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
package com.sun.org.apache.xpath.internal.objects;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
import com.sun.org.apache.xalan.internal.res.XSLMessages;
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.org.apache.xml.internal.dtm.DTMIterator;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    26
import com.sun.org.apache.xml.internal.utils.QName;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import com.sun.org.apache.xml.internal.utils.XMLString;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import com.sun.org.apache.xpath.internal.Expression;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import com.sun.org.apache.xpath.internal.XPathContext;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    31
import java.util.List;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 * This class makes an select statement act like an result tree fragment.
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
public class XRTreeFragSelectWrapper extends XRTreeFrag implements Cloneable
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
    static final long serialVersionUID = -6526177905590461251L;
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
  public XRTreeFragSelectWrapper(Expression expr)
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
    super(expr);
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
   * This function is used to fixup variables from QNames to stack frame
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
   * indexes at stylesheet build time.
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
   * @param vars List of QNames that correspond to variables.  This list
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
   * should be searched backwards for the first qualified name that
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
   * corresponds to the variable reference qname.  The position of the
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
   * QName in the vector from the start of the vector will be its position
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
   * in the stack frame (but variables above the globalsTop value will need
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
   * to be offset to the current stack frame).
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
   */
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
    54
  public void fixupVariables(List<QName> vars, int globalsSize)
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
    ((Expression)m_obj).fixupVariables(vars, globalsSize);
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
   * For support of literal objects in xpaths.
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
   * @param xctxt The XPath execution context.
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
   * @return the result of executing the select expression
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
  public XObject execute(XPathContext xctxt)
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
          throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
         XObject m_selected;
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
     m_selected = ((Expression)m_obj).execute(xctxt);
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
     m_selected.allowDetachToRelease(m_allowRelease);
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
     if (m_selected.getType() == CLASS_STRING)
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
       return m_selected;
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
     else
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
       return new XString(m_selected.str());
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
   * Detaches the <code>DTMIterator</code> from the set which it iterated
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
   * over, releasing any computational resources and placing the iterator
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
   * in the INVALID state. After <code>detach</code> has been invoked,
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
   * calls to <code>nextNode</code> or <code>previousNode</code> will
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
   * raise a runtime exception.
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
   * In general, detach should only be called once on the object.
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
  public void detach()
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_DETACH_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER, null)); //"detach() not supported by XRTreeFragSelectWrapper!");
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
   * Cast result object to a number.
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
   * @return The result tree fragment as a number or NaN
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
  public double num()
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
    throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NUM_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER, null)); //"num() not supported by XRTreeFragSelectWrapper!");
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
   * Cast result object to an XMLString.
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
   * @return The document fragment node data or the empty string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
  public XMLString xstr()
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XSTR_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER, null)); //"xstr() not supported by XRTreeFragSelectWrapper!");
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
   * Cast result object to a string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
   * @return The document fragment node data or the empty string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
  public String str()
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_STR_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER, null)); //"str() not supported by XRTreeFragSelectWrapper!");
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
   * Tell what kind of class this is.
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
   * @return the string type
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
  public int getType()
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
    return CLASS_STRING;
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
   * Cast result object to a result tree fragment.
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
   * @return The document fragment this wraps
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
  public int rtf()
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_RTF_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER, null)); //"rtf() not supported by XRTreeFragSelectWrapper!");
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
   * Cast result object to a DTMIterator.
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
   * @return The document fragment as a DTMIterator
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
  public DTMIterator asNodeIterator()
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_RTF_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER, null)); //"asNodeIterator() not supported by XRTreeFragSelectWrapper!");
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
}