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.xslt.tmap.model.impl;
20:
21: import javax.xml.XMLConstants;
22: import javax.xml.namespace.QName;
23: import org.netbeans.modules.xml.wsdl.model.ReferenceableWSDLComponent;
24: import org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent;
25: import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
26: import org.netbeans.modules.xslt.tmap.model.api.WSDLReference;
27: import org.netbeans.modules.xslt.tmap.model.impl.AttributesType.AttrType;
28:
29: /**
30: *
31: * @author Vitaly Bychkov
32: * @version 1.0
33: */
34: public class WSDLReferenceImpl<T extends ReferenceableWSDLComponent>
35: extends AbstractNamedComponentReference<T> implements
36: NamedComponentReference<T>, WSDLReference<T> {
37:
38: WSDLReferenceImpl(T target, Class<T> type,
39: AbstractDocumentComponent parent, String refString,
40: WSDLReferenceBuilder.WSDLResolver resolver) {
41: super (type, parent, refString);
42: setReferenced(target);
43: myResolver = resolver;
44: }
45:
46: /* (non-Javadoc)
47: * @see org.netbeans.modules.xml.xam.Reference#get()
48: */
49: public T get() {
50: if (getReferenced() == null) {
51: T ret = myResolver.resolve(this );
52: setReferenced(ret);
53: return ret;
54: }
55: return getReferenced();
56: }
57:
58: @Override
59: public AbstractDocumentComponent getParent() {
60: return super .getParent();
61: }
62:
63: /* (non-Javadoc)
64: * @see org.netbeans.modules.xml.xam.NamedComponentReference#getEffectiveNamespace()
65: */
66: public String getEffectiveNamespace() {
67: if (isBroken()) {
68: return XMLConstants.NULL_NS_URI;
69: }
70: return getReferenced().getModel().getDefinitions()
71: .getTargetNamespace();
72: }
73:
74: /* (non-Javadoc)
75: * @see org.netbeans.modules.xml.xam.AbstractNamedComponentReference#getRefString()
76: */
77: @Override
78: public String getRefString() {
79: return refString;
80: }
81:
82: /* (non-Javadoc)
83: * @see org.netbeans.modules.xml.xam.dom.AbstractNamedComponentReference#getQName()
84: */
85: @Override
86: public QName getQName() {
87: return new QName(getEffectiveNamespace(), getRefString());
88: }
89:
90: /* (non-Javadoc)
91: * @see org.netbeans.modules.bpel.model.impl.references.BpelAttributesType#getAttributeType()
92: */
93: public AttrType getAttributeType() {
94: return AttrType.NCNAME;
95: }
96:
97: private WSDLReferenceBuilder.WSDLResolver myResolver;
98: }
|