void registerChild(String name) { synchronized (this) { if (map == null) { check(); } Reference<AbstractFolder> o = map.put(name, new WeakReference<AbstractFolder>(null)); if (o != null) { map.put(name, o); } else { String[] newChildren = new String[children.length + 1]; System.arraycopy(children, 0, newChildren, 0, children.length); newChildren[children.length] = name; children = newChildren; } } }
private synchronized FileObject getFileObjectImpl(String name, String ext) { check(); if ((ext == null) || ext.equals("")) { // NOI18N return getChild(name); } else { StringBuffer sb = new StringBuffer(name.length() + 1 + ((ext == null) ? 0 : ext.length())); sb.append(name).append(EXT_SEP).append(ext); return getChild(sb.toString()); } }
public final synchronized FileObject[] getChildren() { check(); if (children == null) { return new FileObject[0]; } int size = children.length; ArrayList<FileObject> aList = new ArrayList<FileObject>(); for (int i = 0; i < size; i++) { FileObject f = getChild(children[i]); if (f != null) { aList.add(f); } } return aList.toArray(new FileObject[0]); }
/** Tries to find a resource. * @param en enumeration of strings to scan * @return found object or null */ final FileObject find(Enumeration<String> en) { AbstractFolder fo = this; while ((fo != null) && en.hasMoreElements()) { // try to go on // lock to provide safety for getChild synchronized (fo) { // JST: Better to call the check only here, // than in getChild, than it is not called // so often. fo.check(); final String next = en.nextElement(); if ("..".equals(next)) { fo = (AbstractFolder)fo.getParent(); } else { fo = fo.getChild(next); } } } // no next requirements or not found return fo; }
void registerChild (String name) { synchronized (this) { if (map == null) check (); Object o = map.put(name, new WeakReference(null)); if (o != null) { map.put(name, o); } else { String newChildren[] = new String [children.length + 1]; System.arraycopy(children, 0, newChildren, 0, children.length); newChildren [children.length] = name; children = newChildren; } } }
void registerChild (String name) { synchronized (this) { if (map == null) check (); Object o = map.put(name, new WeakReference(null)); if (o != null) { map.put(name, o); } else { String newChildren[] = new String [children.length + 1]; System.arraycopy(children, 0, newChildren, 0, children.length); newChildren [children.length] = name; children = newChildren; } } }
public final synchronized FileObject[] getChildren () { check (); if (children == null) { return new FileObject[0]; } int size = children.length; ArrayList aList = new ArrayList(); for (int i = 0; i < size; i++) { FileObject f = getChild (children[i]); if (f != null) aList.add(f); } return (FileObject [])aList.toArray(new FileObject [0]); }
public final synchronized FileObject[] getChildren () { check (); if (children == null) { return new FileObject[0]; } int size = children.length; ArrayList aList = new ArrayList(); for (int i = 0; i < size; i++) { FileObject f = getChild (children[i]); if (f != null) aList.add(f); } return (FileObject [])aList.toArray(new FileObject [0]); }
/** Tries to find a resource. * @param en enumeration of strings to scan * @return found object or null */ final FileObject find (Enumeration en) { AbstractFolder fo = this; while (fo != null && en.hasMoreElements ()) { // try to go on // lock to provide safety for getChild synchronized (fo) { // JST: Better to call the check only here, // than in getChild, than it is not called // so often. fo.check (); fo = fo.getChild ((String)en.nextElement ()); } } // no next requirements or not found return fo; }
/** Retrieve file or folder contained in this folder by name. * <em>Note</em> that neither file nor folder is created on disk. * @param name basename of the file or folder (in this folder) * @param ext extension of the file; <CODE>null</CODE> or <code>""</code> * if the file should have no extension or if folder is requested * @return the object representing this file or <CODE>null</CODE> if the file * or folder does not exist * @exception IllegalArgumentException if <code>this</code> is not a folder */ public final synchronized FileObject getFileObject (String name, String ext) { check (); if (ext == null || ext.equals ("")) { // NOI18N return getChild (name); } else { StringBuffer sb = new StringBuffer(name.length() + 1 + ((ext == null) ? 0 : ext.length())); sb.append(name).append(EXT_SEP).append(ext); return getChild (sb.toString()); } }
/** Tries to find a resource. * @param en enumeration of strings to scan * @return found object or null */ final FileObject find (Enumeration en) { AbstractFolder fo = this; while (fo != null && en.hasMoreElements ()) { // try to go on // lock to provide safety for getChild synchronized (fo) { // JST: Better to call the check only here, // than in getChild, than it is not called // so often. fo.check (); fo = fo.getChild ((String)en.nextElement ()); } } // no next requirements or not found return fo; }
/** Retrieve file or folder contained in this folder by name. * <em>Note</em> that neither file nor folder is created on disk. * @param name basename of the file or folder (in this folder) * @param ext extension of the file; <CODE>null</CODE> or <code>""</code> * if the file should have no extension or if folder is requested * @return the object representing this file or <CODE>null</CODE> if the file * or folder does not exist * @exception IllegalArgumentException if <code>this</code> is not a folder */ public final synchronized FileObject getFileObject (String name, String ext) { check (); if (ext == null || ext.equals ("")) { // NOI18N return getChild (name); } else { StringBuffer sb = new StringBuffer(name.length() + 1 + ((ext == null) ? 0 : ext.length())); sb.append(name).append(EXT_SEP).append(ext); return getChild (sb.toString()); } }