[OLINGO-659] Replaced Collection with List

This commit is contained in:
Michael Bolz 2015-08-14 13:49:29 +02:00
parent a739034f2f
commit 1984525384
4 changed files with 24 additions and 21 deletions

View File

@ -21,6 +21,7 @@ package org.apache.olingo.commons.api.http;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
/**
@ -183,7 +184,7 @@ public class HttpHeader {
public static final String ODATA_ENTITY_ID = "OData-EntityID";
private final String name;
private final Collection<String> values;
private final List<String> values;
/**
* Create header for given name
@ -216,8 +217,8 @@ public class HttpHeader {
* Get all values for this header
* @return all header values
*/
public Collection<String> getValues() {
return Collections.unmodifiableCollection(values);
public List<String> getValues() {
return Collections.unmodifiableList(values);
}
/**

View File

@ -22,6 +22,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -104,6 +106,21 @@ public class HttpHeaders {
return Collections.unmodifiableCollection(headers.values());
}
/**
* Get all headers with the according values.
*
* @return an unmodifiable Map of header names/values
*/
public Map<String, List<String>> getHeaderToValues() {
Map<String, List<String>> result = new HashMap<String, List<String>>();
Collection<HttpHeader> allHeaders = headers.values();
for (HttpHeader header : allHeaders) {
result.put(header.getName(), header.getValues());
}
return Collections.unmodifiableMap(result);
}
/**
* Get all header names.
*

View File

@ -20,9 +20,6 @@ package org.apache.olingo.server.api;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -124,14 +121,7 @@ public class ODataRequest {
* @return an unmodifiable Map of header names/values
*/
public Map<String, List<String>> getAllHeaders() {
Collection<HttpHeader> allHeader = headers.getHeaders();
Map<String, List<String>> result = new HashMap<String, List<String>>();
for (HttpHeader httpHeader : allHeader) {
result.put(httpHeader.getName(), new ArrayList<String>(httpHeader.getValues()));
}
return Collections.unmodifiableMap(result);
return headers.getHeaderToValues();
}
@ -241,7 +231,7 @@ public class ODataRequest {
/**
* Sets the HTTP protocol used
* @param protocol
* @param 2protocol
* @see #getProtocol()
*/
public void setProtocol(String protocol) {

View File

@ -97,12 +97,7 @@ public class ODataResponse {
* @return an unmodifiable Map of header names/values
*/
public Map<String, List<String>> getAllHeaders() {
Map<String, List<String>> result = new HashMap<String, List<String>>();
Collection<HttpHeader> allHeaders = headers.getHeaders();
for (HttpHeader header : allHeaders) {
result.put(header.getName(), new ArrayList<String>(header.getValues()));
}
return Collections.unmodifiableMap(result);
return headers.getHeaderToValues();
}
/**