@Override public long length() { return this.delegate.length(); }
public String getWeakETag(String suffix) { try { StringBuilder b = new StringBuilder(32); b.append("W/\""); String name=getName(); int length=name.length(); long lhash=0; for (int i=0; i<length;i++) lhash=31*lhash+name.charAt(i); B64Code.encode(lastModified()^lhash,b); B64Code.encode(length()^lhash,b); b.append(suffix); b.append('"'); return b.toString(); } catch (IOException e) { throw new RuntimeException(e); } }
r.writeTo(out, 0, r.length()); return true;
buf.append(" "); buf.append("</A></TD><TD ALIGN=right>"); buf.append(item.length()); buf.append(" bytes </TD><TD>"); buf.append(dfmt.format(new Date(item.lastModified())));
buf.append(deTag(ls[i])); buf.append("</A></TD><TD ALIGN=right>"); buf.append(item.length()); buf.append(" bytes </TD><TD>"); buf.append(dfmt.format(new Date(item.lastModified())));
public static ByteBuffer toBuffer(Resource resource,boolean direct) throws IOException { int len=(int)resource.length(); if (len<0) throw new IllegalArgumentException("invalid resource: "+String.valueOf(resource)+" len="+len); ByteBuffer buffer = direct?BufferUtil.allocateDirect(len):BufferUtil.allocate(len); int pos=BufferUtil.flipToFill(buffer); if (resource.getFile()!=null) BufferUtil.readFrom(resource.getFile(),buffer); else { try (InputStream is = resource.getInputStream();) { BufferUtil.readFrom(is,len,buffer); } } BufferUtil.flipToFlush(buffer,pos); return buffer; }
/** * @param resource * @return True if the resource is cacheable. The default implementation tests the cache sizes. */ protected boolean isCacheable(Resource resource) { long len = resource.length(); // Will it fit in the cache? return (len>0 && len<_maxCachedFileSize && len<_maxCacheSize); }
@Override public long getContentLengthValue() { return _resource.length(); }
/** * @param resource the resource to test * @return True if the resource is cacheable. The default implementation tests the cache sizes. */ protected boolean isCacheable(Resource resource) { if (_maxCachedFiles<=0) return false; long len = resource.length(); // Will it fit in the cache? return (len>0 && (_useFileMappedBuffer || (len<_maxCachedFileSize && len<_maxCacheSize))); }
@Override public long getContentLength() { return _resource.length(); }
@Override public long getContentLengthValue() { return _resource.length(); }
/** * @param resource * @return True if the resource is cacheable. The default implementation tests the cache sizes. */ protected boolean isCacheable(Resource resource) { long len = resource.length(); // Will it fit in the cache? return (len>0 && len<_maxCachedFileSize && len<_maxCacheSize); }
/** * @param resource * @return True if the resource is cacheable. The default implementation tests the cache sizes. */ protected boolean isCacheable(Resource resource) { long len = resource.length(); // Will it fit in the cache? return (len>0 && len<_maxCachedFileSize && len<_maxCacheSize); }
/** * @param resource * @return True if the resource is cacheable. The default implementation tests the cache sizes. */ protected boolean isCacheable(Resource resource) { long len = resource.length(); // Will it fit in the cache? return (len>0 && len<_maxCachedFileSize && len<_maxCacheSize); }
@Override public HttpField getContentLength() { long l=_resource.length(); return l==-1?null:new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH,l); }
boolean isValid() { if (_lastModified==_resource.lastModified() && _length==_resource.length()) { _lastAccessed=System.currentTimeMillis(); return true; } if (this==_cache.remove(_key)) invalidate(); return false; }
boolean isValid() { if (_lastModified==_resource.lastModified() && _length==_resource.length()) { _lastAccessed=System.currentTimeMillis(); return true; } if (this==_cache.remove(_key)) invalidate(); return false; }
boolean isValid() { if (_lastModified==_resource.lastModified() && _length==_resource.length()) { _lastAccessed=System.currentTimeMillis(); return true; } if (this==_cache.remove(_key)) invalidate(); return false; }
TracePostHandler(String tracevisBase) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Resource traceResource = Resource.newResource(tracevisBase).getResource("trace.html"); traceResource.writeTo(baos, 0, traceResource.length()); _traceHtml = baos.toString(); }