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

package org.netbeans.modules.java.bridge;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.openide.src.Element;
import org.openide.src.Identifier;

/**
 * Support for multivalued properties holding identifier arrays and advanced change
 * detection and property firing. The support is implemented as a flyweight, so it does
 * not contain any state-specific fields, but is bound to a property and bean class.
 * Concrete subclass will add methods for accessing state of the bean.
 *
 * @author  sdedic
 * @version 
 */
abstract class IdentifierArrayProperty extends FlyweightIndexedProperty {
    /** Tag value (and performance enhancement) for properties with no identifiers
     * in them.
     */
    static final Identifier[] EMPTY = new Identifier[0];

    /** Constructs the flyweight and binds it to a property name.
     */
    public IdentifierArrayProperty(String propName) {
        super(propName);
    }

    /** Returns the tag value for an empty array of identifiers.
     */
    protected final Object[] createValue(int size) {
        return size == 0 ? EMPTY : new Identifier[size];
    }
    
    protected final Object[] createEmpty() {
        return EMPTY;
    }

    protected boolean compareValues(Object one, Object two) {
        // assume both are identifiers.
        Identifier id1 = (Identifier)one;
        Identifier id2 = (Identifier)two;

        return MemberElementImpl.compareSourceIdentifiers(id1, id2);
    }
    
    protected boolean compareValuesForRemove(Object one, Object two) {
        Identifier id1 = (Identifier)one;
        Identifier id2 = (Identifier)two;
        return id1.compareTo(id2, false);
    }
}

... 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.