01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * 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: package org.netbeans.modules.bpel.model.api.support;
20:
21: import java.util.Collection;
22: import java.util.HashMap;
23: import javax.xml.namespace.QName;
24: import org.netbeans.modules.xml.xpath.ext.XPathExtensionFunction;
25: import org.netbeans.modules.xml.xpath.ext.XPathModel;
26: import org.netbeans.modules.xml.xpath.ext.metadata.ExtFunctionMetadata;
27: import org.netbeans.modules.xml.xpath.ext.spi.ExtensionFunctionResolver;
28: import org.netbeans.modules.xml.xpath.ext.spi.validation.XPathValidationContext;
29: import org.netbeans.modules.xml.xam.spi.Validator.ResultType;
30: import org.openide.util.NbBundle;
31:
32: /**
33: * Provides information about BPEL extension functions for XPath.
34: *
35: * TODO: It's necessary to figure out which functions are still required.
36: * Only 2 functions are described in the BPEL specification
37: *
38: * @author nk160297
39: */
40: public class BpelXpathExtFunctionResolver implements
41: ExtensionFunctionResolver, BpelXPathExtFunctionMetadata {
42:
43: private static HashMap<QName, ExtFunctionMetadata> mValidFunctions = new HashMap<QName, ExtFunctionMetadata>();
44:
45: static {
46: //
47: // Standard BPEL Extensions.
48: mValidFunctions.put(GET_VARIABLE_PROPERTY_METADATA.getName(),
49: GET_VARIABLE_PROPERTY_METADATA);
50: mValidFunctions.put(DO_XSL_TRANSFORM_METADATA.getName(),
51: DO_XSL_TRANSFORM_METADATA);
52: //
53: // Runtime specific extensions.
54: mValidFunctions.put(CURRENT_TIME_METADATA.getName(),
55: CURRENT_TIME_METADATA);
56: mValidFunctions.put(CURRENT_DATE_METADATA.getName(),
57: CURRENT_DATE_METADATA);
58: mValidFunctions.put(CURRENT_DATE_TIME_METADATA.getName(),
59: CURRENT_DATE_TIME_METADATA);
60: mValidFunctions.put(DO_MARSHAL_METADATA.getName(),
61: DO_MARSHAL_METADATA);
62: mValidFunctions.put(DO_UNMARSHAL_METADATA.getName(),
63: DO_UNMARSHAL_METADATA);
64: //
65: }
66:
67: public BpelXpathExtFunctionResolver() {
68: }
69:
70: public ExtFunctionMetadata getFunctionMetadata(QName name) {
71: return mValidFunctions.get(name);
72: }
73:
74: public Collection<QName> getSupportedExtFunctions() {
75: return mValidFunctions.keySet();
76: }
77:
78: public XPathExtensionFunction newInstance(XPathModel model,
79: QName name) {
80: return null;
81: }
82:
83: public void validateFunction(XPathExtensionFunction function,
84: XPathValidationContext context) {
85: assert context != null
86: && context instanceof PathValidationContext;
87: QName funcQName = function.getMetadata().getName();
88: if (GET_VARIABLE_PROPERTY_METADATA.getName().equals(funcQName)) {
89: String funcName = funcQName.getLocalPart();
90: PathValidationContext vContext = (PathValidationContext) context;
91: vContext.addResultItem(ResultType.WARNING, NbBundle
92: .getMessage(BpelVariableResolver.class,
93: "RUNTIME_NOT_SUPPORT_EXT_FUNC"), funcName); // NOI18N
94: }
95: }
96:
97: }
|