author | joehw |
Mon, 17 Apr 2017 16:24:10 -0700 | |
changeset 44797 | 8b3b3b911b8a |
parent 25868 | 686eef1e7a79 |
permissions | -rw-r--r-- |
6 | 1 |
/* |
2 |
* reserved comment block |
|
3 |
* DO NOT REMOVE OR ALTER! |
|
4 |
*/ |
|
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 | 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 | 14 |
* |
15 |
* Unless required by applicable law or agreed to in writing, software |
|
16 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
17 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
18 |
* See the License for the specific language governing permissions and |
|
19 |
* limitations under the License. |
|
20 |
*/ |
|
44797
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
21 |
|
6 | 22 |
package com.sun.org.apache.xpath.internal.functions; |
23 |
||
24 |
import com.sun.org.apache.xml.internal.dtm.DTM; |
|
25 |
import com.sun.org.apache.xml.internal.dtm.DTMIterator; |
|
26 |
import com.sun.org.apache.xpath.internal.XPathContext; |
|
27 |
import com.sun.org.apache.xpath.internal.axes.LocPathIterator; |
|
28 |
import com.sun.org.apache.xpath.internal.axes.PredicatedNodeTest; |
|
29 |
import com.sun.org.apache.xpath.internal.objects.XNodeSet; |
|
30 |
import com.sun.org.apache.xpath.internal.objects.XObject; |
|
31 |
import com.sun.org.apache.xpath.internal.axes.SubContextList; |
|
32 |
import com.sun.org.apache.xpath.internal.patterns.StepPattern; |
|
33 |
import com.sun.org.apache.xalan.internal.res.XSLMessages; |
|
34 |
import com.sun.org.apache.xalan.internal.res.XSLTErrorResources; |
|
35 |
||
36 |
||
37 |
/** |
|
38 |
* Execute the current() function. |
|
39 |
* @xsl.usage advanced |
|
40 |
*/ |
|
41 |
public class FuncCurrent extends Function |
|
42 |
{ |
|
43 |
static final long serialVersionUID = 5715316804877715008L; |
|
44 |
||
45 |
/** |
|
46 |
* Execute the function. The function must return |
|
47 |
* a valid object. |
|
48 |
* @param xctxt The current execution context. |
|
49 |
* @return A valid XObject. |
|
50 |
* |
|
51 |
* @throws javax.xml.transform.TransformerException |
|
52 |
*/ |
|
53 |
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException |
|
54 |
{ |
|
55 |
||
56 |
SubContextList subContextList = xctxt.getCurrentNodeList(); |
|
57 |
int currentNode = DTM.NULL; |
|
58 |
||
59 |
if (null != subContextList) { |
|
60 |
if (subContextList instanceof PredicatedNodeTest) { |
|
61 |
LocPathIterator iter = ((PredicatedNodeTest)subContextList) |
|
62 |
.getLocPathIterator(); |
|
63 |
currentNode = iter.getCurrentContextNode(); |
|
64 |
} else if(subContextList instanceof StepPattern) { |
|
65 |
throw new RuntimeException(XSLMessages.createMessage( |
|
66 |
XSLTErrorResources.ER_PROCESSOR_ERROR,null)); |
|
67 |
} |
|
68 |
} else { |
|
69 |
// not predicate => ContextNode == CurrentNode |
|
70 |
currentNode = xctxt.getContextNode(); |
|
71 |
} |
|
72 |
return new XNodeSet(currentNode, xctxt.getDTMManager()); |
|
73 |
} |
|
74 |
||
75 |
/** |
|
76 |
* No arguments to process, so this does nothing. |
|
77 |
*/ |
|
78 |
public void fixupVariables(java.util.Vector vars, int globalsSize) |
|
79 |
{ |
|
80 |
// no-op |
|
81 |
} |
|
82 |
||
83 |
} |