KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitmodelext > policy > PolicyFactories


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 2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.wsitmodelext.policy;
21
22 import org.netbeans.modules.websvc.wsitmodelext.policy.impl.AllImpl;
23 import org.netbeans.modules.websvc.wsitmodelext.policy.impl.ExactlyOneImpl;
24 import org.netbeans.modules.websvc.wsitmodelext.policy.impl.PolicyImpl;
25 import org.netbeans.modules.websvc.wsitmodelext.policy.impl.PolicyReferenceImpl;
26 import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
27 import org.netbeans.modules.xml.wsdl.model.spi.ElementFactory;
28 import org.w3c.dom.Element JavaDoc;
29
30 import javax.xml.namespace.QName JavaDoc;
31 import java.util.Collections JavaDoc;
32 import java.util.Set JavaDoc;
33
34
35 public class PolicyFactories {
36             
37     public static class PolicyFactory extends ElementFactory {
38         @Override JavaDoc
39         public Set JavaDoc<QName JavaDoc> getElementQNames() {
40             return Collections.singleton(PolicyQName.POLICY.getQName());
41         }
42         public <C extends WSDLComponent> C create(WSDLComponent context, Class JavaDoc<C> type) {
43             return type.cast(new PolicyImpl(context.getModel()));
44         }
45         @Override JavaDoc
46         public WSDLComponent create(WSDLComponent context, Element JavaDoc element) {
47             return new PolicyImpl(context.getModel(), element);
48         }
49     }
50
51     public static class AllFactory extends ElementFactory {
52         @Override JavaDoc
53         public Set JavaDoc<QName JavaDoc> getElementQNames() {
54             return Collections.singleton(PolicyQName.ALL.getQName());
55         }
56         public <C extends WSDLComponent> C create(WSDLComponent context, Class JavaDoc<C> type) {
57             return type.cast(new AllImpl(context.getModel()));
58             
59         }
60         @Override JavaDoc
61         public WSDLComponent create(WSDLComponent context, Element JavaDoc element) {
62             return new AllImpl(context.getModel(), element);
63         }
64     }
65
66     public static class ExactlyOneFactory extends ElementFactory {
67         @Override JavaDoc
68         public Set JavaDoc<QName JavaDoc> getElementQNames() {
69             return Collections.singleton(PolicyQName.EXACTLYONE.getQName());
70         }
71         public <C extends WSDLComponent> C create(WSDLComponent context, Class JavaDoc<C> type) {
72             return type.cast(new ExactlyOneImpl(context.getModel()));
73             
74         }
75         @Override JavaDoc
76         public WSDLComponent create(WSDLComponent context, Element JavaDoc element) {
77             return new ExactlyOneImpl(context.getModel(), element);
78         }
79     }
80
81     public static class PolicyReferenceFactory extends ElementFactory {
82         @Override JavaDoc
83         public Set JavaDoc<QName JavaDoc> getElementQNames() {
84             return Collections.singleton(PolicyQName.POLICYREFERENCE.getQName());
85         }
86         public <C extends WSDLComponent> C create(WSDLComponent context, Class JavaDoc<C> type) {
87             return type.cast(new PolicyReferenceImpl(context.getModel()));
88             
89         }
90         @Override JavaDoc
91         public WSDLComponent create(WSDLComponent context, Element JavaDoc element) {
92             return new PolicyReferenceImpl(context.getModel(), element);
93         }
94     }
95
96 }
97
Popular Tags