Package com.adobe.granite.httpcache.api
Class Headers
- java.lang.Object
-
- com.adobe.granite.httpcache.api.Headers
-
public class Headers extends Object
Container class for HTTP headers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Headers.Entry
A header entry.
-
Constructor Summary
Constructors Constructor Description Headers()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHeader(String name, int value)
Add a header.void
addHeader(String name, long value)
Add a header.void
addHeader(String name, String value)
Add a header.long
getDateHeader(String name)
Return the first header matching a given name.Headers.Entry[]
getEntries()
Return all entries.String
getHeader(String name)
Return the first header matching a given name.String[]
getHeaders(String name)
Return all headers matching a given name.int
getIntHeader(String name)
Return the first header matching a given name.void
load(InputStream in)
Load stored headers from an input stream.void
save(OutputStream out)
Store headers to an output stream.void
setHeader(String name, int value)
Set a header.void
setHeader(String name, long value)
Set a header.void
setHeader(String name, String value)
Set a header.String
toString()
-
-
-
Method Detail
-
getHeader
public String getHeader(String name)
Return the first header matching a given name.- Parameters:
name
- name- Returns:
- value of header or
null
-
getHeaders
public String[] getHeaders(String name)
Return all headers matching a given name.- Parameters:
name
- name- Returns:
- matching values or
null
-
getDateHeader
public long getDateHeader(String name)
Return the first header matching a given name.- Parameters:
name
- name- Returns:
- value of date header or
-1
-
getIntHeader
public int getIntHeader(String name)
Return the first header matching a given name.- Parameters:
name
- name- Returns:
- value of date header or
0
-
setHeader
public void setHeader(String name, String value)
Set a header. This will replace the first existing entry or add a new one.- Parameters:
name
- namevalue
- value, ifnull
remove an existing header
-
setHeader
public void setHeader(String name, long value)
Set a header. This will replace the first existing entry or add a new one.- Parameters:
name
- namevalue
- value
-
setHeader
public void setHeader(String name, int value)
Set a header. This will replace the first existing entry or add a new one.- Parameters:
name
- namevalue
- value
-
addHeader
public void addHeader(String name, String value)
Add a header.- Parameters:
name
- namevalue
- value
-
addHeader
public void addHeader(String name, long value)
Add a header.- Parameters:
name
- namevalue
- value
-
addHeader
public void addHeader(String name, int value)
Add a header.- Parameters:
name
- namevalue
- value
-
getEntries
public Headers.Entry[] getEntries()
Return all entries.- Returns:
- entries
-
save
public void save(OutputStream out) throws IOException
Store headers to an output stream.- Parameters:
out
- output stream- Throws:
IOException
- if an I/O error occurs
-
load
public void load(InputStream in) throws IOException
Load stored headers from an input stream.- Parameters:
in
- input stream- Throws:
IOException
- if an I/O error occurs
-
-