KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > ui > nodes > ExFilterFactory


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

19
20 package org.netbeans.modules.java.ui.nodes;
21
22 import org.openide.src.nodes.ElementNodeFactory;
23 import org.openide.src.nodes.FilterFactory;
24 import org.openide.src.*;
25 import org.openide.nodes.Node;
26 import org.netbeans.jmi.javamodel.JavaEnum;
27 import org.netbeans.jmi.javamodel.AnnotationType;
28 import org.netbeans.jmi.javamodel.EnumConstant;
29 import org.netbeans.jmi.javamodel.Attribute;
30
31 /**
32  * extended {@link FilterFactory} to support jdk1.5 features
33  */

34 public final class ExFilterFactory implements ExElementNodeFactory {
35
36     private ExElementNodeFactory delegate;
37     private final ElementNodeFactory impl;
38     
39     private ExFilterFactory() {
40         this.impl = null;
41     }
42     
43     public ExFilterFactory(ElementNodeFactory f) {
44         this.impl = f;
45     }
46     
47     public void attach(ExElementNodeFactory f) {
48         if (!(impl instanceof FilterFactory)) {
49             throw new UnsupportedOperationException JavaDoc();
50         }
51         ((FilterFactory) impl).attachTo(f);
52         this.delegate = f;
53     }
54     
55     public Node createEnumNode(JavaEnum element) {
56         checkAttached();
57         return delegate.createEnumNode(element);
58     }
59
60     public Node createEnumConstantNode(EnumConstant element) {
61         checkAttached();
62         return delegate.createEnumConstantNode(element);
63     }
64
65     public Node createAnnotationTypeNode(AnnotationType element) {
66         checkAttached();
67         return delegate.createAnnotationTypeNode(element);
68     }
69
70     public Node createAnnotationTypeMethodNode(Attribute element) {
71         checkAttached();
72         return delegate.createAnnotationTypeMethodNode(element);
73     }
74
75     public Node createClassNode(ClassElement element) {
76         return impl.createClassNode(element);
77     }
78
79     public Node createConstructorNode(ConstructorElement element) {
80         return impl.createConstructorNode(element);
81     }
82
83     public Node createErrorNode() {
84         return impl.createErrorNode();
85     }
86
87     public Node createFieldNode(FieldElement element) {
88         return impl.createFieldNode(element);
89     }
90
91     public Node createInitializerNode(InitializerElement element) {
92         return impl.createInitializerNode(element);
93     }
94
95     public Node createMethodNode(MethodElement element) {
96         return impl.createMethodNode(element);
97     }
98
99     public Node createWaitNode() {
100         return impl.createWaitNode();
101     }
102
103     private void checkAttached() throws IllegalStateException JavaDoc {
104         if (delegate == null) {
105             throw new IllegalStateException JavaDoc("factory is not attached"); // NOI18N
106
}
107     }
108 }
109
Popular Tags