Class DocumentResponseHelper
java.lang.Object
com.janeirodigital.shapetrees.core.helpers.DocumentResponseHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkStringAsUrl
(String urlString) Check the validity of a URL string valuegetHeader
(DocumentResponse response, HttpHeader header) Gets the string value of the http headerheader
stored in the ResourceAttributes of the providedresponse
.getHeader
(ResourceAttributes attributes, HttpHeader header) Gets the string value of the http headerheader
stored in the providedattributes
.getLinkHeaders
(DocumentResponse response) Gets a list of string values for HTTP Link headers stored in the providedresponse
getLinkRelation
(ResourceAttributes linkRelations, LinkRelation relation) Gets a single link relation value from the providedlinkRelations
map of HTTP Link Relationsstatic RelationAttributes
getLinkRelations
(DocumentResponse response) Extracts HTTP Link Relations from the HTTP Headers of the providedresponse
.static ShapeTreeResourceType
getResourceType
(DocumentResponse response) Determine a resource type by parsing Link rel=type headersstatic URL
stringToUrl
(String urlString) Convert the provided URL string value to URLstatic URL
stringToUrl
(URL context, String urlString) Convert the provided URL string value to a URL, using the provided URLcontext
-
Method Details
-
getHeader
Gets the string value of the http headerheader
stored in the ResourceAttributes of the providedresponse
.- Parameters:
response
- DocumentResponse to extract value fromheader
- HTTP Header to get the value for- Returns:
- Optional string value of the header
-
getHeader
Gets the string value of the http headerheader
stored in the providedattributes
.- Parameters:
attributes
- ResourceAttributes to extract value fromheader
- HTTP header to get the value for- Returns:
- Optional string value of the header
-
getLinkHeaders
Gets a list of string values for HTTP Link headers stored in the providedresponse
- Parameters:
response
- DocumentResponse to extract values from- Returns:
- List of string values from HTTP Link headers
-
getLinkRelations
Extracts HTTP Link Relations from the HTTP Headers of the providedresponse
. Note that the ResourceAttributes class is used to represent the resultant map of relations.- Parameters:
response
- DocumentResponse to extract values from- Returns:
- Map of link relations for HTTP Link headers
-
getLinkRelation
public static Optional<String> getLinkRelation(ResourceAttributes linkRelations, LinkRelation relation) Gets a single link relation value from the providedlinkRelations
map of HTTP Link Relations- Parameters:
linkRelations
- Map of HTTP Link Relations as ResourceAttributesrelation
- Link relation type to get- Returns:
- Optional string value of the provided LinkRelation
-
getResourceType
Determine a resource type by parsing Link rel=type headers- Parameters:
response
- DocumentResponse to parse- Returns:
- Type of resource
-
checkStringAsUrl
Check the validity of a URL string value- Parameters:
urlString
- URL string value to check- Throws:
ShapeTreeException
- thrown when the URL value is malformed
-
stringToUrl
Convert the provided URL string value to URL- Parameters:
urlString
- URL string value to convert- Returns:
- Converted URL
- Throws:
ShapeTreeException
- on Malformed URL string value
-
stringToUrl
Convert the provided URL string value to a URL, using the provided URLcontext
- Parameters:
context
- URL context URL to create fromurlString
- URL string value to convert- Returns:
- Converted URL
- Throws:
ShapeTreeException
- on Malformed URL string value
-