- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<String,List<String>>
-
- org.refcodes.web.AbstractHttpFields<T>
-
- org.refcodes.web.AbstractHeaderFields<ResponseCookie,ResponseHeaderFields>
-
- org.refcodes.web.ResponseHeaderFields
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,List<String>>,HeaderFields<ResponseCookie,ResponseHeaderFields>,HttpFields<ResponseHeaderFields>
public class ResponseHeaderFields extends AbstractHeaderFields<ResponseCookie,ResponseHeaderFields> implements HeaderFields<ResponseCookie,ResponseHeaderFields>
TheResponseHeaderFieldsreflect the structure of a HTTP header and may be used to represent a HTTP header.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
-
Fields inherited from interface org.refcodes.web.HeaderFields
BASIC_REALM
-
-
Constructor Summary
Constructors Constructor Description ResponseHeaderFields()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponseCookieaddCookie(String aHttpCookie)Adds an individual server-side cookie to be sent to the client to thisResponseHeaderFieldsinstance.protected ResponseCookiecreateCookie(String aHttpCookie)protected ResponseCookiecreateCookie(String aCookieName, String aValue)Creates a plainCookiewith the given name and value.protected StringgetCookieFieldName()The Header-Field name for theCookieelements.StringgetLocation()Gets the Location Response-Header-FieldHeaderField.LOCATION: "...StringputLocation(String aLocation)Sets the Location Response-Header-FieldHeaderField.LOCATION: "...StringremoveLocation()Removes the Location Response-Header-FieldHeaderField.LOCATION: "...ResponseHeaderFieldswitAddCookie(String aHttpCookie)Builder method forwithAddCookie(ResponseCookie)ResponseHeaderFieldswithAddCookie(ResponseCookie aCookie)Builder method for theHeaderFields.addCookie(Cookie)method.ResponseHeaderFieldswithLocation(String aLocation)Sets the Location Response-Header-FieldHeaderField.LOCATION: "...-
Methods inherited from class org.refcodes.web.AbstractHeaderFields
addCookie, addCookie, addTo, entrySet, get, getAllCookies, isCommaSeparatedHeaderField, keySet, put, putAll, toHeaderField, toHeaderFields
-
Methods inherited from class org.refcodes.web.AbstractHttpFields
copyHttpFields
-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, forEach, getOrDefault, isEmpty, merge, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.web.HeaderFields
addCookie, addCookie, addTo, addTo, addTo, get, getAcceptCharsets, getAcceptEncodings, getAcceptLanguages, getAcceptTypes, getAllCookies, getAllowMethods, getAuthenticate, getAuthorization, getBasicAuth, getBasicAuthCredentials, getBearerAuthCredentials, getContentEncoding, getContentLength, getContentType, getCookies, getFirst, getFirstCookie, getHost, getRequestId, getSessionId, getUnknownAcceptTypes, getUnknownContentTypes, getUserAgent, put, put, put, putAcceptCharsets, putAcceptCharsets, putAcceptEncodings, putAcceptEncodings, putAcceptLanguages, putAcceptLanguages, putAcceptTypes, putAcceptTypes, putAllowMethods, putAllowMethods, putAuthenticate, putAuthorization, putAuthorization, putAuthorization, putBasicAuthCredentials, putBasicAuthCredentials, putBasicAuthRequired, putBearerAuthCredentials, putBearerAuthCredentials, putContentEncoding, putContentLength, putContentType, putContentType, putHost, putRequestId, putSessionId, putUserAgent, remove, removeAcceptCharsets, removeAcceptEncodings, removeAcceptLanguages, removeAcceptTypes, removeAllowMethods, removeAuthenticate, removeAuthorization, removeBasicAuthCredentials, removeBasicAuthenticate, removeBearerAuthCredentials, removeContentEncoding, removeContentLength, removeContentType, removeHost, removeRequestId, removeSessionId, removeUserAgent, toBasicAuthRealm, toHeaderFields, toHttpCookies, withAcceptCharsets, withAcceptCharsets, withAcceptEncodings, withAcceptEncodings, withAcceptLanguages, withAcceptLanguages, withAcceptTypes, withAcceptTypes, withAddCookie, withAddTo, withAddTo, withAddTo, withAllowMethods, withAllowMethods, withAuthenticate, withAuthorization, withAuthorization, withAuthorization, withBasicAuthCredentials, withBasicAuthCredentials, withBasicAuthRequired, withBearerAuthCredentials, withBearerAuthCredentials, withContentEncoding, withContentLength, withContentType, withContentType, withHost, withPut, withPut, withPut, withRequestId, withSessionId, withUserAgent
-
Methods inherited from interface org.refcodes.web.HttpFields
addTo, addTo, addTo, addTo, addTo, addTo, getFirst, getFirst, put, put, put, put, toField, toField, withAddTo, withAddTo, withAddTo, withAddTo, withAddTo, withAddTo, withPut, withPut, withPut, withPut, withPut, withPut
-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Method Detail
-
addCookie
public ResponseCookie addCookie(String aHttpCookie)
Adds an individual server-side cookie to be sent to the client to thisResponseHeaderFieldsinstance. The server-side cookies are retrieved from theHeaderField.SET_COOKIEHeader-Field. WITH THE METHODHeaderFields.getAllCookies()andHeaderFields.getCookies(String)as well asHeaderFields.getFirstCookie(String)ONLY THE COOKIES SENT BY THE CLIENT CAN BE RETRIEVED (E.G. COOKIES RESIDING IN THE HEADER FIELDHeaderField.COOKIE). COOKIES SET VIAHeaderFields.addCookie(String, String)ORHeaderFields.withAddCookie(String, String)CANNOT BE RETRIEVED, AS THE COOKIES BEING SET SERVER-SIDE ARE PUT IN THEHeaderField.SET_COOKIEHeader-Field.- Specified by:
addCookiein interfaceHeaderFields<ResponseCookie,ResponseHeaderFields>- Parameters:
aHttpCookie- The HTTP-CookieStringto be paresd as a cookie.- Returns:
- The resulting cookie builder being added which can be modified
affecting(!) this
ResponseHeaderFieldsinstance!
-
witAddCookie
public ResponseHeaderFields witAddCookie(String aHttpCookie)
Builder method forwithAddCookie(ResponseCookie)- Parameters:
aHttpCookie- The cookie to be added.- Returns:
- The implementing instance as of the builder pattern.
-
withAddCookie
public ResponseHeaderFields withAddCookie(ResponseCookie aCookie)
Builder method for theHeaderFields.addCookie(Cookie)method. WITH THE METHODHeaderFields.getAllCookies()andHeaderFields.getCookies(String)as well asHeaderFields.getFirstCookie(String)ONLY THE COOKIES SENT BY THE CLIENT CAN BE RETRIEVED (E.G. COOKIES RESIDING IN THE HEADER FIELDHeaderField.COOKIE). COOKIES SET VIAHeaderFields.addCookie(String, String)ORHeaderFields.withAddCookie(String, String)CANNOT BE RETRIEVED, AS THE COOKIES BEING SET SERVER-SIDE ARE PUT IN THEHeaderField.SET_COOKIEHeader-Field.- Specified by:
withAddCookiein interfaceHeaderFields<ResponseCookie,ResponseHeaderFields>- Parameters:
aCookie- The cookie to be added.- Returns:
- This
ResponseHeaderFieldsinstance to continue building up the Header-Fields.
-
getLocation
public String getLocation()
Gets the Location Response-Header-FieldHeaderField.LOCATION: "... The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI. ..."
-
putLocation
public String putLocation(String aLocation)
Sets the Location Response-Header-FieldHeaderField.LOCATION: "... The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI. types ..."- Parameters:
aLocation- The according location.- Returns:
- The replaced element (if any, else null).
- See Also:
- "https://tools.ietf.org/html/rfc2616#page-135"
-
withLocation
public ResponseHeaderFields withLocation(String aLocation)
Sets the Location Response-Header-FieldHeaderField.LOCATION: "... The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI. types ..."- Parameters:
aLocation- The according location.- Returns:
- This object as of the Builder-Pattern.
- See Also:
- "https://tools.ietf.org/html/rfc2616#page-135"
-
removeLocation
public String removeLocation()
Removes the Location Response-Header-FieldHeaderField.LOCATION: "... The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI. types ..."- Returns:
- The value being removed (or null if none was set).
- See Also:
- "https://tools.ietf.org/html/rfc2616#page-135"
-
getCookieFieldName
protected String getCookieFieldName()
The Header-Field name for theCookieelements. The Header-Field name differs from the context, e.g. when setting aCookieserver-side or when retrieving aCookieclient-side.- Specified by:
getCookieFieldNamein classAbstractHeaderFields<ResponseCookie,ResponseHeaderFields>- Returns:
- The Header-Field where the
Cookieelements are stored.
-
createCookie
protected ResponseCookie createCookie(String aCookieName, String aValue)
Creates a plainCookiewith the given name and value.- Specified by:
createCookiein classAbstractHeaderFields<ResponseCookie,ResponseHeaderFields>- Parameters:
aCookieName- The name of theCookie.aValue- The value for theCookie- Returns:
- The
Cookiewith the given name and value.
-
createCookie
protected ResponseCookie createCookie(String aHttpCookie)
- Specified by:
createCookiein classAbstractHeaderFields<ResponseCookie,ResponseHeaderFields>- Parameters:
aHttpCookie- The text of the Header-Field for the cookie to be created.- Returns:
- The
Cookiewith the given cookie properties.
-
-