KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xpath > impl > XPathCoreFunctionImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.xpath.impl;
21
22 import org.netbeans.modules.xml.xpath.XPathCoreFunction;
23 import org.netbeans.modules.xml.xpath.function.core.visitor.XPathCoreFunctionVisitor;
24 import org.netbeans.modules.xml.xpath.visitor.XPathVisitor;
25
26
27
28 /**
29  * Represents a core XPath function.
30  *
31  * @author Enrico Lelina
32  * @version $Revision: 1.4 $
33  */

34 public class XPathCoreFunctionImpl
35     extends XPathOperatorOrFunctionImpl
36     implements XPathCoreFunction {
37         
38     /** The function code. */
39     int mFunction;
40     
41     
42     /**
43      * Constructor. Instantiates a new XPathCoreFunction with the given code.
44      * @param function the function code
45      */

46     public XPathCoreFunctionImpl(int function) {
47         super();
48         setFunction(function);
49     }
50     
51     
52     /**
53      * Gets the function code.
54      * @return the function code
55      */

56     public int getFunction() {
57         return mFunction;
58     }
59     
60     
61     /**
62      * Sets the function code.
63      * @param function the function code
64      */

65     public void setFunction(int function) {
66         mFunction = function;
67     }
68     
69     
70     /**
71      * Gets the name of the function.
72      * @return the function name or null if invalid
73      */

74     public String JavaDoc getName() {
75         int code = getFunction();
76
77         switch (code) {
78         case XPathCoreFunction.FUNC_LAST:
79             return "last";
80         case XPathCoreFunction.FUNC_POSITION:
81             return "position";
82         case XPathCoreFunction.FUNC_COUNT:
83             return "count";
84         case XPathCoreFunction.FUNC_ID:
85             return "id";
86         case XPathCoreFunction.FUNC_LOCAL_NAME:
87             return "local-name";
88         case XPathCoreFunction.FUNC_NAMESPACE_URI:
89             return "namespace-uri";
90         case XPathCoreFunction.FUNC_NAME:
91             return "name";
92         case XPathCoreFunction.FUNC_STRING:
93             return "string";
94         case XPathCoreFunction.FUNC_CONCAT:
95             return "concat";
96         case XPathCoreFunction.FUNC_STARTS_WITH:
97             return "starts-with";
98         case XPathCoreFunction.FUNC_CONTAINS:
99             return "contains";
100         case XPathCoreFunction.FUNC_SUBSTRING_BEFORE:
101             return "substring-before";
102         case XPathCoreFunction.FUNC_SUBSTRING_AFTER:
103             return "substring-after";
104         case XPathCoreFunction.FUNC_SUBSTRING:
105             return "substring";
106         case XPathCoreFunction.FUNC_STRING_LENGTH:
107             return "string-length";
108         case XPathCoreFunction.FUNC_NORMALIZE_SPACE:
109             return "normalize-space";
110         case XPathCoreFunction.FUNC_TRANSLATE:
111             return "translate";
112         case XPathCoreFunction.FUNC_BOOLEAN:
113             return "boolean";
114         case XPathCoreFunction.FUNC_NOT:
115             return "not";
116         case XPathCoreFunction.FUNC_TRUE:
117             return "true";
118         case XPathCoreFunction.FUNC_FALSE:
119             return "false";
120         case XPathCoreFunction.FUNC_LANG:
121             return "lang";
122         case XPathCoreFunction.FUNC_NUMBER:
123             return "number";
124         case XPathCoreFunction.FUNC_SUM:
125             return "sum";
126         case XPathCoreFunction.FUNC_FLOOR:
127             return "floor";
128         case XPathCoreFunction.FUNC_CEILING:
129             return "ceiling";
130         case XPathCoreFunction.FUNC_ROUND:
131             return "round";
132         case XPathCoreFunction.FUNC_NULL:
133             return "null";
134         case XPathCoreFunction.FUNC_KEY:
135             return "key";
136         case XPathCoreFunction.FUNC_FORMAT_NUMBER:
137             return "format-number";
138         case XPathCoreFunction.FUNC_EXISTS:
139             return "exists";
140         }
141         
142         return null;
143     }
144     
145
146     /**
147      * Calls the visitor.
148      * @param visitor the visitor
149      */

150     public void accept(XPathVisitor visitor) {
151         visitor.visit(this);
152     }
153
154
155     public void accept(XPathCoreFunctionVisitor visitor) {
156         //do nothing
157

158     }
159     
160     
161 }
162
Popular Tags