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