/** Initialize a reference with parsed element. * @param currentRef the reference * @param resElem the new element * @return ret&0x01 if content changed, ret&0x02 if attributes changed. */ private int initializeReference(FileObjRef currentRef, ResourceElem resElem) { if (!currentRef.isInitialized()) { currentRef.initialize(resElem); return 0x00; } else { boolean attrDiff = currentRef.attacheAttrs(resElem.getAttr(false)); currentRef.setUrlContext(resElem.getUrlContext()); boolean diff = false; if (resElem.getContent() != null) { diff = !(currentRef.content instanceof byte[]) || !java.util.Arrays.equals((byte[])currentRef.content, resElem.getContent()); currentRef.content = resElem.getContent(); } else if (resElem.getURI() != null) { diff = !resElem.getURI().equals(currentRef.content); currentRef.content = resElem.getURI(); } return (diff ? 0x01 : 0x00) + (attrDiff ? 0x02 : 0x00); } }
public Enumeration<String> attributes(String name) { FileObjRef<? extends FileObject> ref = (FileObjRef<? extends FileObject>) fs.findReference(name); if ((ref == null) && (name.length() == 0) && (fs.rootRef != null)) { ref = fs.rootRef; } if (ref == null) { return Enumerations.empty(); } return ref.attributes(); }
URL[] all = getLayers(); url = (all != null && all.length > 0) ? all[0] : null; } else { try { url = createAbsoluteUrl(name); } catch (IOException iex) { url = null; retval = timeFromDateHeaderField(url);
/** * Get input stream. * * @return an input stream to read the contents of this file * @param context * @param name the file to test * @exception FileNotFoundException if the file does not exists or is invalid */ public InputStream getInputStream(String name) throws java.io.FileNotFoundException { InputStream is = null; if (content == null) return new ByteArrayInputStream (new byte[] {}); if (content instanceof String) { URL absURL = createAbsoluteUrl (name); try { is = absURL.openStream(); } catch (IOException iox) { FileNotFoundException x = new FileNotFoundException (name); ExternalUtil.copyAnnotation (x,iox); throw x; } } if (content instanceof byte[]){ is = new ByteArrayInputStream((byte[])content); } if (is == null) throw new FileNotFoundException (name); return is; }
/** * Get input stream. * * @return an input stream to read the contents of this file * @param context * @param name the file to test * @exception FileNotFoundException if the file does not exists or is invalid */ public InputStream getInputStream(String name) throws java.io.FileNotFoundException { InputStream is = null; if (content == null) return new ByteArrayInputStream (new byte[] {}); if (content instanceof String) { URL absURL = createAbsoluteUrl (name); try { is = absURL.openStream(); } catch (IOException iox) { FileNotFoundException x = new FileNotFoundException (name); ExternalUtil.copyAnnotation (x,iox); throw x; } } if (content instanceof byte[]){ is = new ByteArrayInputStream((byte[])content); } if (is == null) throw new FileNotFoundException (name); return is; }
/** refreshes children recursively.*/ private void refreshChildren (AbstractFolder fo, ResourceElem resElem) { if (fo.isRoot()) initializeReference (rootRef = new FileObjRef (fo), resElem); java.util.List nameList = resElem.getChildren (); String[] names = new String[nameList.size ()]; ResourceElem[] children = new ResourceElem[names.length]; nameList.toArray(names); for (int i = 0; i < names.length; i++) children[i] = resElem.getChild (names[i]); fo.refresh(null, null, true, true, names); for (int i = 0; i < children.length; i++) { AbstractFolder fo2 = (AbstractFolder)fo.getFileObject (names[i]); FileObjRef currentRef = (FileObjRef )findReference (fo2.getPath ()); initializeReference (currentRef, children[i]); fo2.lastModified(); if (fo2.isFolder()) refreshChildren (fo2,children[i]); } }
/** refreshes children recursively.*/ private void refreshChildren (AbstractFolder fo, ResourceElem resElem) { if (fo.isRoot()) initializeReference (rootRef = new FileObjRef (fo), resElem); java.util.List nameList = resElem.getChildren (); String[] names = new String[nameList.size ()]; ResourceElem[] children = new ResourceElem[names.length]; nameList.toArray(names); for (int i = 0; i < names.length; i++) children[i] = resElem.getChild (names[i]); fo.refresh(null, null, true, true, names); for (int i = 0; i < children.length; i++) { AbstractFolder fo2 = (AbstractFolder)fo.getFileObject (names[i]); FileObjRef currentRef = (FileObjRef )findReference (fo2.getPath ()); initializeReference (currentRef, children[i]); fo2.lastModified(); if (fo2.isFolder()) refreshChildren (fo2,children[i]); } }
public long getSize (String name) { if (content == null) return 0; if (content instanceof byte[]) return ((byte[])content).length; if (content instanceof String) { try { URL absURL = createAbsoluteUrl (name); URLConnection urlConnection = absURL.openConnection(); try { return urlConnection.getContentLength(); } finally { urlConnection.getInputStream().close(); } } catch (IOException iex) { } } return 0; }
public long getSize (String name) { if (content == null) return 0; if (content instanceof byte[]) return ((byte[])content).length; if (content instanceof String) { try { URL absURL = createAbsoluteUrl (name); URLConnection urlConnection = absURL.openConnection(); try { return urlConnection.getContentLength(); } finally { urlConnection.getInputStream().close(); } } catch (IOException iex) { } } return 0; }
public Object readAttribute(String attrName) { if (attrName.equals("layers")) { //NOI18N return getLayers(); } if (foAttrs == null) return null; FileObject topFO = (FileObject) MultiFileObject.attrAskedFileObject.get(); FileObject f = topFO == null ? fo : topFO; MultiFileObject.attrAskedFileObject.set(null); try { Object[] objs = new Object[] {f,attrName}; return foAttrs.get(attrName,objs); } finally { MultiFileObject.attrAskedFileObject.set(topFO); } }
protected Reference createReference(FileObject fo) { return new FileObjRef (fo); }
protected Reference createReference(FileObject fo) { return new FileObjRef (fo); }
public Date lastModified(String name) { if (content == null || !(content instanceof String)) return timeFromDateHeaderField (getLayers ()); URL url; try { url = createAbsoluteUrl (name); } catch (IOException iex) { return timeFromDateHeaderField (getLayers ()); } File localFile = getLocalFile (url); if (localFile != null) return new Date (localFile.lastModified()); return timeFromDateHeaderField (url); }
public Object readAttribute(String attrName) { if (attrName.equals("layers")) { //NOI18N return getLayers(); } if (foAttrs == null) return null; FileObject topFO = (FileObject) MultiFileObject.attrAskedFileObject.get(); FileObject f = topFO == null ? fo : topFO; MultiFileObject.attrAskedFileObject.set(null); try { Object[] objs = new Object[] {f,attrName}; return foAttrs.get(attrName,objs); } finally { MultiFileObject.attrAskedFileObject.set(topFO); } }
private URL createAbsoluteUrl (String name) throws java.io.FileNotFoundException { if (!(content instanceof String)) return null; String uri = (String)content; try { URL[] uc = getLayers(); URL retVal = (uc == null || uc.length == 0)?new URL (uri):new URL (uc[0],uri); return retVal; } catch(IOException ex) {// neni koser osetreni - RM FileNotFoundException x = new FileNotFoundException (name); ExternalUtil.copyAnnotation (x,ex); throw x; } }
/** * Get input stream. * * @param name the file to test * @return an input stream to read the contents of this file * @exception FileNotFoundException if the file does not exists or is invalid */ private InputStream getInputStream(String name) throws java.io.FileNotFoundException { Reference ref = findReference(name); if (ref != null && (ref instanceof FileObjRef ) ) { return (((FileObjRef) ref).getInputStream(name)); } throw new FileNotFoundException (NbBundle.getMessage(XMLFileSystem.class, "EXC_CanntRead", name));// NOI18N }
public Date lastModified(String name) { if (content == null || !(content instanceof String)) return timeFromDateHeaderField (getLayers ()); URL url; try { url = createAbsoluteUrl (name); } catch (IOException iex) { return timeFromDateHeaderField (getLayers ()); } File localFile = getLocalFile (url); if (localFile != null) return new Date (localFile.lastModified()); return timeFromDateHeaderField (url); }
private URL createAbsoluteUrl (String name) throws java.io.FileNotFoundException { if (!(content instanceof String)) return null; String uri = (String)content; try { URL[] uc = getLayers(); URL retVal = (uc == null || uc.length == 0)?new URL (uri):new URL (uc[0],uri); return retVal; } catch(IOException ex) {// neni koser osetreni - RM FileNotFoundException x = new FileNotFoundException (name); ExternalUtil.copyAnnotation (x,ex); throw x; } }
/** * Get input stream. * * @param name the file to test * @return an input stream to read the contents of this file * @exception FileNotFoundException if the file does not exists or is invalid */ private InputStream getInputStream(String name) throws java.io.FileNotFoundException { Reference ref = findReference(name); if (ref != null && (ref instanceof FileObjRef ) ) { return (((FileObjRef) ref).getInputStream(name)); } throw new FileNotFoundException (NbBundle.getMessage(XMLFileSystem.class, "EXC_CanntRead", name));// NOI18N }
/** Get size of stream*/ private long getSize (String name) { Reference ref = findReference(name); if (ref != null && (ref instanceof FileObjRef ) ) { return ((FileObjRef) ref).getSize(name); } return 0; }