/** Creates enumeration of existing subfiles in all tree * of files. * * @param rec should it be recursive or not * @return enumeration of AbstractFolders */ final Enumeration<AbstractFolder> existingSubFiles(boolean rec) { if (!rec) { return Enumerations.array(subfiles()); } else { class P implements org.openide.util.Enumerations.Processor<AbstractFolder, AbstractFolder> { public AbstractFolder process(AbstractFolder af, Collection<AbstractFolder> toAdd) { toAdd.addAll(Arrays.asList(af.subfiles())); return af; } } return Enumerations.queue(Enumerations.singleton(this), new P()); } }
/** Get all file attribute names for this file. * @return enumeration of keys (as strings) */ public Enumeration<String> getAttributes() { return Enumerations.empty(); }
@Deprecated // have to override for compat public @Override FileObject find(String aPackage, String name, String ext) { // create enumeration of name to look for Enumeration<String> st = NbCollections.checkedEnumerationByFilter(new StringTokenizer(aPackage, "."), String.class, true); // NOI18N Enumeration<String> en; if ((name == null) || (ext == null)) { en = st; } else { en = Enumerations.concat(st, Enumerations.singleton(name + '.' + ext)); } // tries to find it (can return null) return getMultiRoot().find(en); }
/** Computes a list of FileObjects in the right order * that can represent this instance. * * @param name of resource to find * @return enumeration of FileObject */ Enumeration<FileObject> delegates(final String name) { Enumeration<FileSystem> en = Enumerations.array(systems); // XXX order (stably) by weight class Resources implements Enumerations.Processor<FileSystem, FileObject> { public @Override FileObject process(FileSystem fs, Collection<FileSystem> ignore) { if (fs == null) { return null; } else { return findResourceOn(fs, name); } } } return Enumerations.filter(en, new Resources()); }
public @Override Enumeration<String> getKeys() { return Enumerations.removeDuplicates(Enumerations.concat(sub1.getKeys(), sub2.getKeys())); }
if (n.children == null) { return n.items == null ? org.openide.util.Enumerations.empty() : Collections.enumeration (n.items); Enumeration en = org.openide.util.Enumerations.queue ( org.openide.util.Enumerations.singleton (n), new DeepAndItems () ); return new NeedsSortEnum (org.openide.util.Enumerations.concat (en));
/** Queries for instances of given class. * @param clazz the class to check * @return enumeration of Item * @see #unsorted */ public Enumeration lookup (final Class clazz) { class CheckEn implements org.openide.util.Enumerations.Processor { public Object process (Object o, Collection ignore) { boolean ok; if (o instanceof AbstractLookup.Pair) { ok = clazz == null || ((AbstractLookup.Pair)o).instanceOf(clazz); } else { ok = false; } return ok ? o : null; } } if (content instanceof Object[]) { Enumeration all = org.openide.util.Enumerations.array ( (Object[])content ); return org.openide.util.Enumerations.filter (all, new CheckEn ()); } else { return org.openide.util.Enumerations.empty(); } }
/** * Filters the input enumeration to new one that should contain * each of the provided elements just once. * The elements are compared * using their default <code>equals</code> and <code>hashCode</code> methods. * * @param en enumeration to filter * @return enumeration without duplicated items */ public static <T> Enumeration<T> removeDuplicates(Enumeration<T> en) { class RDupls implements Processor<T,T> { private Set<T> set = new HashSet<T>(); public T process(T o, Collection<T> nothing) { return set.add(o) ? o : null; } } return filter(en, new RDupls()); }
/** Get the nodes as an enumeration. * @return enumeration of nodes */ public final Enumeration<Node> nodes() { return Enumerations.array(getNodes()); }
if (preferredLoader == null) { return Enumerations.concat ( Enumerations.array ( new Enumeration[] { Enumerations.array (getSystemLoaders ()), loaders (), Enumerations.array (getDefaultLoaders ()) } ) ); } else { return Enumerations.concat ( Enumerations.array ( new Enumeration[] { Enumerations.singleton (preferredLoader), Enumerations.array (getSystemLoaders ()), loaders (), Enumerations.array (getDefaultLoaders ()) } ) );
/** @return enumeration of all listeners. */ private final Enumeration listeners () { if (listeners == null) { return Enumerations.empty(); } else { return Enumerations.removeNulls ( Enumerations.array (listeners.getAllListeners ()) ); } }
final Enumeration<? extends FileObject> existingFileObjects(AbstractFolder fo) { class OnlyValidAndDeep implements org.openide.util.Enumerations.Processor<Reference<AbstractFolder>,FileObject> { public FileObject process(Reference<AbstractFolder> obj, Collection<Reference<AbstractFolder>> toAdd) { AbstractFolder file = obj.get(); if (file != null) { AbstractFolder[] arr = file.subfiles(); // make the array weak for (int i = 0; i < arr.length; i++) { toAdd.add(new WeakReference<AbstractFolder>(arr[i])); } return file.isValid() ? file : null; } return null; } } Reference<AbstractFolder> ref = new WeakReference<AbstractFolder>(fo); Enumeration<Reference<AbstractFolder>> singleEn = org.openide.util.Enumerations.<Reference<AbstractFolder>>singleton(ref); return org.openide.util.Enumerations.removeNulls( org.openide.util.Enumerations.queue(singleEn, new OnlyValidAndDeep()) ); }
public Enumeration<String> getKeys() { return Enumerations.singleton(LOC_MSG_PLACEHOLDER); } };
private Object[] getObjects() { if (objects == null) { class Coll2Enum implements org.openide.util.Enumerations.Processor { public Object process (Object obj, java.util.Collection ignore) { return Collections.enumeration((Collection) obj); } } Enumeration sequenced = org.openide.util.Enumerations.concat ( org.openide.util.Enumerations.convert ( Collections.enumeration (queue), new Coll2Enum () ) ); Enumeration result = org.openide.util.Enumerations.removeDuplicates (sequenced); ArrayList objectList = new ArrayList(); for (int i = 0; result.hasMoreElements(); i++) { objectList.add(result.nextElement()); } objects = objectList.toArray(); } return objects; }
protected Enumeration<String> attributes(String name) { Attributes attr1 = getManifest().getAttributes(name); if (attr1 != null) { class ToString implements org.openide.util.Enumerations.Processor<Object, String> { public String process(Object obj, Collection<Object> ignore) { return obj.toString(); } } return org.openide.util.Enumerations.convert(Collections.enumeration(attr1.keySet()), new ToString()); } else { return org.openide.util.Enumerations.empty(); } }
/** Changes the order of data objects. */ public synchronized void setOrder (DataObject[] arr) throws IOException { if (arr != null) { order = new HashMap (arr.length * 4 / 3 + 1); // each object only once Enumeration en = org.openide.util.Enumerations.removeDuplicates ( org.openide.util.Enumerations.array (arr) ); int i = 0; while (en.hasMoreElements ()) { DataObject obj = (DataObject)en.nextElement (); FileObject fo = obj.getPrimaryFile (); if (folder.equals (fo.getParent ())) { // object for my folder order.put (fo.getNameExt (), new Integer (i++)); } } // Explicit order has been set, if written please clear affected // order markings. ignorePartials = true; } else { order = null; } write (); // writes attribute EA_ORDER -> updates FolderList // FolderList.changedFolderOrder (folder); }
return Enumerations.concat(Collections.enumeration(sub));
en = org.openide.util.Enumerations.removeDuplicates (en);
if (n.children == null) { return n.items == null ? org.openide.util.Enumerations.empty() : Collections.enumeration (n.items); Enumeration en = org.openide.util.Enumerations.queue ( org.openide.util.Enumerations.singleton (n), new DeepAndItems () ); return new NeedsSortEnum (org.openide.util.Enumerations.concat (en));