|
What this is
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-2002 Sun * Microsystems, Inc. All Rights Reserved. */ package org.openide.loaders; import java.io.*; import java.util.*; import org.openide.filesystems.FileObject; import org.openide.util.Utilities; /** Property class that collects a modifiable list of file extensions * and permits checking of whether a name or a file object has a given extension. * It comes with a property editor to allow the user to modify the extensions. * * @author Jaroslav Tulach */ public class ExtensionList extends Object implements Cloneable, java.io.Serializable { /** if true, ignore case of file extensions (not MIME types tho!) */ private static final boolean CASE_INSENSITIVE = Utilities.isWindows() || Utilities.getOperatingSystem() == Utilities.OS_VMS; /** set of extensions to recognize */ private TreeSet list; /** set of mime types to recognize */ private TreeSet mimeTypes; static final long serialVersionUID =8868581349510386291L; /** Default constructor. */ public ExtensionList () { } /** Clone new object. */ public synchronized Object clone () { try { ExtensionList l = (ExtensionList)super.clone (); if (list != null) { l.list = createExtensionSet (); l.list.addAll (list); } l.mimeTypes = mimeTypes == null ? null : (TreeSet)mimeTypes.clone (); return l; } catch (CloneNotSupportedException ex) { // has to be supported we implement the right interface throw new InternalError (); } } /** Add a new extension. * @param ext the extension */ public synchronized void addExtension (String ext) { if (list == null) { list = createExtensionSet (); } list.add (ext); } /** Remove an extension. * @param ext the extension */ public void removeExtension (String ext) { if (list != null) { list.remove (ext); } } /** Adds new mime type. * @param mime the mime type */ public synchronized void addMimeType (String mime) { if (mimeTypes == null) { mimeTypes = new TreeSet (); } mimeTypes.add (mime); } /** Removes a mime type. * @param mime the name of the type */ public void removeMimeType (String mime) { if (mimeTypes != null) { mimeTypes.remove(mime); } } /** Test whether the name in the string is acceptable. * It should end with a dot and be one of the registered extenstions. * @param s the name * @return |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
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.