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.vcscore.cache;

/**
 *
 * @author  mkleint
 */

import java.util.EventObject;
import java.util.Collections;
import java.util.Set;

public class CacheHandlerEvent extends java.util.EventObject {

    private boolean recursive = false;
    private boolean ignoreList = false;
    
    private static final long serialVersionUID = 385684866008914174L;
    
    /** Creates new CacheHandlerEvent */
    public CacheHandlerEvent(CacheFile cacheFile) {
        this(cacheFile, false);
    }
    
    public CacheHandlerEvent(CacheFile cacheFile, boolean recursive) {
        this(cacheFile, recursive, false);
    }
    
    public CacheHandlerEvent(CacheFile cacheFile, boolean recursive, boolean ignoreList) {
        super(cacheFile);
        this.recursive = recursive;
        this.ignoreList = ignoreList;
    }
    
    public CacheHandlerEvent(Set cacheFiles) {
        this(cacheFiles, false);
    }
    
    public CacheHandlerEvent(Set cacheFiles, boolean recursive) {
        this(cacheFiles, recursive, false);
    }
    
    public CacheHandlerEvent(Set cacheFiles, boolean recursive, boolean ignoreList) {
        super(Collections.unmodifiableSet(cacheFiles));
        this.recursive = recursive;
        this.ignoreList = ignoreList;
    }
    
    /**
     * Get the changed cache file. If more files were changed, return the first
     * one in the set or null if the set is empty.
     */
    public CacheFile getCacheFile() {
        Object source = getSource();
        if (source instanceof CacheFile) {
            return (CacheFile) source;
        } else {
            Set sources = (Set) source;
            if (sources.size() > 0) {
                return (CacheFile) sources.iterator().next();
            } else {
                return null;
            }
        }
    }
    
    /**
     * Get all the changed cache files.
     */
    public Set getCacheFiles() {
        Object source = getSource();
        if (source instanceof Set) {
            return (Set) source;
        } else {
            return Collections.singleton(source);
        }
    }
    
    public boolean isRecursive() {
        return recursive;
    }
    
    public boolean isIgnoreListChange() {
        return ignoreList;
    }
    
}
... 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.