FileDocCategorySizeDatePackage
SimpleCacheResponse.javaAPI DocExample1445Sun Dec 12 10:55:20 GMT 2004None

SimpleCacheResponse

public class SimpleCacheResponse extends CacheResponse

Fields Summary
private Map
headers
private SimpleCacheRequest
request
private Date
expires
Constructors Summary
public SimpleCacheResponse(SimpleCacheRequest request, URLConnection uc)

    
    this.request = request;
    
    // deliberate shadowing; we need to fill the map and
    // then make it unmodifiable 
    Map<String,List<String>> headers = new HashMap<String,List<String>>();
    String value = "";
    for (int i = 0;; i++) {
       String name = uc.getHeaderFieldKey(i);
       value = uc.getHeaderField(i);
       if (value == null) break;
       List<String> values = headers.get(name);
       if (values == null) {
         values = new ArrayList<String>(1);
         headers.put(name, values);
       }
       values.add(value);
    }
    long expiration = uc.getExpiration();
    if (expiration != 0) {
      this.expires = new Date(expiration); 
    }

    this.headers = Collections.unmodifiableMap(headers);

  
Methods Summary
public java.io.InputStreamgetBody()

    return new ByteArrayInputStream(request.getData()); 
  
public java.util.MapgetHeaders()

    return headers;
  
public booleanisExpired()

    if (expires == null) return false;
    else {
      Date now = new Date();
      return expires.before(now);
    }