001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.xml.xpath.ext.metadata;
021:
022: import java.util.List;
023: import javax.swing.Icon;
024: import javax.xml.namespace.QName;
025: import org.netbeans.modules.xml.xpath.ext.XPathExtensionFunction;
026: import org.netbeans.modules.xml.xpath.ext.XPathModel;
027: import org.netbeans.modules.xml.xpath.ext.XPathOperationOrFuntion;
028: import org.netbeans.modules.xml.xpath.ext.metadata.GeneralFunctionMetadata.FunctionType;
029: import org.netbeans.modules.xml.xpath.ext.metadata.impl.images.IconLoader;
030: import org.netbeans.modules.xml.xpath.ext.visitor.XPathVisitor;
031:
032: /**
033: * This extension function is used as special stub to generate a valid XPath
034: * expression in case when required arguments of operation or function is skipped.
035: *
036: * The function is declared in empty namespace! So a prefix is not requiered.
037: *
038: * The class is declared as final because the functin is very specific and
039: * is not intended to be inherited.
040: *
041: * @author nk160297
042: */
043: public final class StubExtFunction extends XPathExtensionFunction {
044:
045: private static final MyMetadata STUB_FUNC_METADATA = new MyMetadata();
046: public static final QName STUB_FUNC_NAME = new QName("stub"); // NOI18N
047:
048: public StubExtFunction(XPathModel model) {
049: super (model, STUB_FUNC_METADATA);
050: }
051:
052: /**
053: * Calls the visitor.
054: * @param visitor the visitor
055: */
056: @Override
057: public void accept(XPathVisitor visitor) {
058: visitor.visit(this );
059: }
060:
061: private static class MyMetadata implements ExtFunctionMetadata {
062:
063: public boolean isContextItemRequired(
064: XPathOperationOrFuntion func) {
065: return false;
066: }
067:
068: public QName getName() {
069: return STUB_FUNC_NAME;
070: }
071:
072: public Icon getIcon() {
073: return IconLoader.UNKNOWN_ICON;
074: }
075:
076: public String getDisplayName() {
077: return "Stub"; // NOI18N
078: }
079:
080: public String getShortDescription() {
081: return "Mandatory argument stub"; // NOI18N
082: }
083:
084: public String getLongDescription() {
085: return "This function is used as special stub to generate"
086: + " a valid XPath expression in case when required arguments"
087: + " of operation or function is skipped"; // NOI18N
088: }
089:
090: public FunctionType getFunctionType() {
091: return FunctionType.EXT_FUNCTION;
092: }
093:
094: public List<AbstractArgument> getArguments() {
095: return null;
096: }
097:
098: public XPathType getResultType() {
099: return XPathType.ANY_TYPE;
100: }
101:
102: public ResultTypeCalculator getResultTypeCalculator() {
103: return null;
104: }
105:
106: public String toStrign() {
107: return "Stub function metadata"; // NOI18N
108: }
109: }
110:
111: }
|