alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.java.ui.nodes;

import org.openide.src.nodes.ElementNodeFactory;
import org.openide.src.nodes.FilterFactory;
import org.openide.src.*;
import org.openide.nodes.Node;
import org.netbeans.jmi.javamodel.JavaEnum;
import org.netbeans.jmi.javamodel.AnnotationType;
import org.netbeans.jmi.javamodel.EnumConstant;
import org.netbeans.jmi.javamodel.Attribute;

/**
 * extended {@link FilterFactory} to support jdk1.5 features
 */
public final class ExFilterFactory implements ExElementNodeFactory {
    
    private ExElementNodeFactory delegate;
    private final ElementNodeFactory impl;
    
    private ExFilterFactory() {
        this.impl = null;
    }
    
    public ExFilterFactory(ElementNodeFactory f) {
        this.impl = f;
    }
    
    public void attach(ExElementNodeFactory f) {
        if (!(impl instanceof FilterFactory)) {
            throw new UnsupportedOperationException();
        }
        ((FilterFactory) impl).attachTo(f);
        this.delegate = f;
    }
    
    public Node createEnumNode(JavaEnum element) {
        checkAttached();
        return delegate.createEnumNode(element);
    }

    public Node createEnumConstantNode(EnumConstant element) {
        checkAttached();
        return delegate.createEnumConstantNode(element);
    }

    public Node createAnnotationTypeNode(AnnotationType element) {
        checkAttached();
        return delegate.createAnnotationTypeNode(element);
    }

    public Node createAnnotationTypeMethodNode(Attribute element) {
        checkAttached();
        return delegate.createAnnotationTypeMethodNode(element);
    }

    public Node createClassNode(ClassElement element) {
        return impl.createClassNode(element);
    }

    public Node createConstructorNode(ConstructorElement element) {
        return impl.createConstructorNode(element);
    }

    public Node createErrorNode() {
        return impl.createErrorNode();
    }

    public Node createFieldNode(FieldElement element) {
        return impl.createFieldNode(element);
    }

    public Node createInitializerNode(InitializerElement element) {
        return impl.createInitializerNode(element);
    }

    public Node createMethodNode(MethodElement element) {
        return impl.createMethodNode(element);
    }

    public Node createWaitNode() {
        return impl.createWaitNode();
    }

    private void checkAttached() throws IllegalStateException {
        if (delegate == null) {
            throw new IllegalStateException("factory is not attached"); // NOI18N
        }
    }
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.