KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > net > HttpRetryException


1 /*
2  * @(#)HttpRetryException.java 1.2 05/11/17
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.net;
9
10 import java.io.IOException JavaDoc;
11
12 /**
13  * Thrown to indicate that a HTTP request needs to be retried
14  * but cannot be retried automatically, due to streaming mode
15  * being enabled.
16  *
17  * @author Michael McMahon
18  * @version 1.2, 11/17/05
19  * @since 1.5
20  */

21 public
22 class HttpRetryException extends IOException JavaDoc {
23
24     private int responseCode;
25     private String JavaDoc location;
26
27     /**
28      * Constructs a new <code>HttpRetryException</code> from the
29      * specified response code and exception detail message
30      *
31      * @param detail the detail message.
32      * @param code the HTTP response code from server.
33      */

34     public HttpRetryException(String JavaDoc detail, int code) {
35     super(detail);
36     responseCode = code;
37     }
38     
39     /**
40      * Constructs a new <code>HttpRetryException</code> with detail message
41      * responseCode and the contents of the Location response header field.
42      *
43      * @param detail the detail message.
44      * @param code the HTTP response code from server.
45      * @param location the URL to be redirected to
46      */

47     public HttpRetryException(String JavaDoc detail, int code, String JavaDoc location) {
48     super (detail);
49     responseCode = code;
50     this.location = location;
51     }
52
53     /**
54      * Returns the http response code
55      *
56      * @return The http response code.
57      */

58     public int responseCode() {
59         return responseCode;
60     }
61
62     /**
63      * Returns a string explaining why the http request could
64      * not be retried.
65      *
66      * @return The reason string
67      */

68     public String JavaDoc getReason() {
69         return super.getMessage();
70     }
71
72     /**
73      * Returns the value of the Location header field if the
74      * error resulted from redirection.
75      *
76      * @return The location string
77      */

78     public String JavaDoc getLocation() {
79         return location;
80     }
81 }
82
Popular Tags