Changeset 717

Show
Ignore:
Timestamp:
06/15/07 12:56:51 (2 years ago)
Author:
yuanying
Message:

JSONConverter has classMap;

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/ClientErrorException.java

    r713 r717  
    2525    public ClientErrorException(int statusCode, String message) { 
    2626        super(statusCode, message); 
    27         // TODO Auto-generated constructor stub 
    2827    } 
    2928 
    3029    public ClientErrorException(int statusCode) { 
    3130        super(statusCode); 
    32         // TODO Auto-generated constructor stub 
    3331    } 
    3432 
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/ConnectionException.java

    r713 r717  
    2626 
    2727    public ConnectionException(int statusCode) { 
    28         this(statusCode, null); 
     28        this(statusCode, "Statis Code: " + statusCode); 
    2929    } 
    3030     
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/HttpClientConnection.java

    r713 r717  
    118118        if (this.isFollowRedirects() && this.needRedirect(method)) { 
    119119            URI redirectUri = this.extractRedirectURI(method); 
     120            method.releaseConnection(); 
    120121            return this.get(redirectUri.toString(), new HashMap<String, String>()); 
    121122        } 
     
    130131    private URI extractRedirectURI(HttpMethod method) { 
    131132        URI redirectUri = null; 
    132         Header header = method.getRequestHeader("location"); 
     133        Header header = method.getResponseHeader("location"); 
    133134        try { 
    134135            redirectUri = new URI(header.getValue(), true); 
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/convert/JSONConverter.java

    r662 r717  
    3232    private Class<T> targetType; 
    3333     
     34    private Map<String, Class<?>> classMap; 
     35     
    3436    public JSONConverter(Class<T> clazz) { 
     37        this(clazz, null); 
     38    } 
     39     
     40    public JSONConverter(Class<T> clazz, Map<String, Class<?>> classMap) { 
    3541        this.targetType = clazz; 
     42        this.classMap = classMap; 
     43    } 
     44 
     45    public Map<String, Class<?>> getClassMap() { 
     46        return classMap; 
     47    } 
     48 
     49    public void setClassMap(Map<String, Class<?>> classMap) { 
     50        this.classMap = classMap; 
    3651    } 
    3752 
     
    4055     * @see org.jalcedo.client.rest.convert.Converter#toBean(java.lang.String) 
    4156     */ 
    42     @SuppressWarnings("unchecked") 
    4357    public T toBean(String string) { 
    44         JSONObject obj = JSONObject.fromString(string); 
    45         return (T) JSONObject.toBean(obj, this.targetType); 
     58        return this.toBean(string, this.getClassMap()); 
    4659    } 
    4760 
     
    5972     * @see org.jalcedo.client.rest.convert.Converter#toList(java.lang.String) 
    6073     */ 
    61     @SuppressWarnings("unchecked") 
    6274    public List<T> toList(String string) { 
    63         return JSONArray.toList(JSONArray.fromString(string), this.targetType); 
     75        return this.toList(string, this.getClassMap()); 
    6476    } 
    6577