From ef71254e5f8c3db0aae289a15d47e0a3c457f26f Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Sun, 12 May 2013 23:29:26 -0700 Subject: [PATCH] Re-arrange package structure. --- .../java/retrofit/{http => }/Callback.java | 4 +- .../retrofit/{http => }/CallbackRunnable.java | 2 +- .../retrofit/{http => }/ChangeableServer.java | 4 +- .../java/retrofit/{http => }/Platform.java | 37 ++++---- .../java/retrofit/{http => }/Profiler.java | 4 +- .../retrofit/{http => }/RequestBuilder.java | 25 +++--- .../retrofit/{http => }/RequestHeaders.java | 6 +- .../retrofit/{http => }/ResponseWrapper.java | 11 ++- .../java/retrofit/{http => }/RestAdapter.java | 89 +++++++++++-------- .../retrofit/{http => }/RestMethodInfo.java | 20 +++-- .../retrofit/{http => }/RetrofitError.java | 8 +- .../main/java/retrofit/{http => }/Server.java | 2 +- .../main/java/retrofit/{http => }/Types.java | 2 +- .../main/java/retrofit/{http => }/Utils.java | 23 ++--- .../android/AndroidApacheClient.java | 6 +- .../android/MainThreadExecutor.java | 2 +- .../{http => }/client/ApacheClient.java | 6 +- .../retrofit/{http => }/client/Client.java | 2 +- .../retrofit/{http => }/client/Header.java | 2 +- .../retrofit/{http => }/client/OkClient.java | 2 +- .../retrofit/{http => }/client/Request.java | 4 +- .../retrofit/{http => }/client/Response.java | 4 +- .../client/UrlConnectionClient.java | 6 +- .../ConversionException.java | 2 +- .../{http => converter}/Converter.java | 12 +-- .../{http => converter}/GsonConverter.java | 11 +-- .../main/java/retrofit/http/Parameter.java | 79 ---------------- .../src/main/java/retrofit/http/Part.java | 4 +- .../mime/FormUrlEncodedTypedOutput.java | 2 +- .../src/main/java/retrofit/mime/MimeUtil.java | 38 ++++++++ .../{http => }/mime/MultipartTypedOutput.java | 2 +- .../{http => }/mime/TypedByteArray.java | 2 +- .../retrofit/{http => }/mime/TypedFile.java | 2 +- .../retrofit/{http => }/mime/TypedInput.java | 2 +- .../retrofit/{http => }/mime/TypedOutput.java | 2 +- .../retrofit/{http => }/mime/TypedString.java | 2 +- .../{http => }/CallbackRunnableTest.java | 8 +- .../{http => }/RequestBuilderTest.java | 22 +++-- .../retrofit/{http => }/RestAdapterTest.java | 18 ++-- .../{http => }/RestMethodInfoTest.java | 29 ++++-- .../retrofit/{http => }/TestingUtils.java | 6 +- .../{http => }/client/ApacheClientTest.java | 14 +-- .../client/DummyHttpUrlConnection.java | 4 +- .../client/UrlConnectionClientTest.java | 10 +-- .../mime/FormUrlEncodingTypedOutputTest.java | 2 +- .../retrofit/{http => }/mime/MimeHelper.java | 2 +- .../UtilsTest.java => mime/MimeUtilTest.java} | 6 +- .../mime/MultipartTypedOutputTest.java | 2 +- .../{http => }/mime/TypedByteArrayTest.java | 2 +- .../{http => }/mime/TypedFileTest.java | 2 +- .../retrofit/GitHubClient.java} | 6 +- 51 files changed, 284 insertions(+), 280 deletions(-) rename retrofit/src/main/java/retrofit/{http => }/Callback.java (94%) rename retrofit/src/main/java/retrofit/{http => }/CallbackRunnable.java (98%) rename retrofit/src/main/java/retrofit/{http => }/ChangeableServer.java (96%) rename retrofit/src/main/java/retrofit/{http => }/Platform.java (86%) rename retrofit/src/main/java/retrofit/{http => }/Profiler.java (97%) rename retrofit/src/main/java/retrofit/{http => }/RequestBuilder.java (89%) rename retrofit/src/main/java/retrofit/{http => }/RequestHeaders.java (91%) rename retrofit/src/main/java/retrofit/{http => }/ResponseWrapper.java (73%) rename retrofit/src/main/java/retrofit/{http => }/RestAdapter.java (84%) rename retrofit/src/main/java/retrofit/{http => }/RestMethodInfo.java (96%) rename retrofit/src/main/java/retrofit/{http => }/RetrofitError.java (94%) rename retrofit/src/main/java/retrofit/{http => }/Server.java (98%) rename retrofit/src/main/java/retrofit/{http => }/Types.java (99%) rename retrofit/src/main/java/retrofit/{http => }/Utils.java (79%) rename retrofit/src/main/java/retrofit/{http => }/android/AndroidApacheClient.java (86%) rename retrofit/src/main/java/retrofit/{http => }/android/MainThreadExecutor.java (96%) rename retrofit/src/main/java/retrofit/{http => }/client/ApacheClient.java (97%) rename retrofit/src/main/java/retrofit/{http => }/client/Client.java (97%) rename retrofit/src/main/java/retrofit/{http => }/client/Header.java (98%) rename retrofit/src/main/java/retrofit/{http => }/client/OkClient.java (97%) rename retrofit/src/main/java/retrofit/{http => }/client/Request.java (96%) rename retrofit/src/main/java/retrofit/{http => }/client/Response.java (96%) rename retrofit/src/main/java/retrofit/{http => }/client/UrlConnectionClient.java (96%) rename retrofit/src/main/java/retrofit/{http => converter}/ConversionException.java (97%) rename retrofit/src/main/java/retrofit/{http => converter}/Converter.java (81%) rename retrofit/src/main/java/retrofit/{http => converter}/GsonConverter.java (90%) delete mode 100644 retrofit/src/main/java/retrofit/http/Parameter.java rename retrofit/src/main/java/retrofit/{http => }/mime/FormUrlEncodedTypedOutput.java (98%) create mode 100644 retrofit/src/main/java/retrofit/mime/MimeUtil.java rename retrofit/src/main/java/retrofit/{http => }/mime/MultipartTypedOutput.java (99%) rename retrofit/src/main/java/retrofit/{http => }/mime/TypedByteArray.java (98%) rename retrofit/src/main/java/retrofit/{http => }/mime/TypedFile.java (99%) rename retrofit/src/main/java/retrofit/{http => }/mime/TypedInput.java (97%) rename retrofit/src/main/java/retrofit/{http => }/mime/TypedOutput.java (97%) rename retrofit/src/main/java/retrofit/{http => }/mime/TypedString.java (97%) rename retrofit/src/test/java/retrofit/{http => }/CallbackRunnableTest.java (88%) rename retrofit/src/test/java/retrofit/{http => }/RequestBuilderTest.java (96%) rename retrofit/src/test/java/retrofit/{http => }/RestAdapterTest.java (94%) rename retrofit/src/test/java/retrofit/{http => }/RestMethodInfoTest.java (96%) rename retrofit/src/test/java/retrofit/{http => }/TestingUtils.java (90%) rename retrofit/src/test/java/retrofit/{http => }/client/ApacheClientTest.java (94%) rename retrofit/src/test/java/retrofit/{http => }/client/DummyHttpUrlConnection.java (96%) rename retrofit/src/test/java/retrofit/{http => }/client/UrlConnectionClientTest.java (97%) rename retrofit/src/test/java/retrofit/{http => }/mime/FormUrlEncodingTypedOutputTest.java (98%) rename retrofit/src/test/java/retrofit/{http => }/mime/MimeHelper.java (86%) rename retrofit/src/test/java/retrofit/{http/UtilsTest.java => mime/MimeUtilTest.java} (92%) rename retrofit/src/test/java/retrofit/{http => }/mime/MultipartTypedOutputTest.java (98%) rename retrofit/src/test/java/retrofit/{http => }/mime/TypedByteArrayTest.java (95%) rename retrofit/src/test/java/retrofit/{http => }/mime/TypedFileTest.java (98%) rename samples/github-client/src/main/java/com/{squareup/retrofit/sample/github/Client.java => example/retrofit/GitHubClient.java} (94%) diff --git a/retrofit/src/main/java/retrofit/http/Callback.java b/retrofit/src/main/java/retrofit/Callback.java similarity index 94% rename from retrofit/src/main/java/retrofit/http/Callback.java rename to retrofit/src/main/java/retrofit/Callback.java index 8cdbc9b4..45c2cf23 100644 --- a/retrofit/src/main/java/retrofit/http/Callback.java +++ b/retrofit/src/main/java/retrofit/Callback.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit; -import retrofit.http.client.Response; +import retrofit.client.Response; /** * Communicates responses to server or offline requests. Contains a callback method for each diff --git a/retrofit/src/main/java/retrofit/http/CallbackRunnable.java b/retrofit/src/main/java/retrofit/CallbackRunnable.java similarity index 98% rename from retrofit/src/main/java/retrofit/http/CallbackRunnable.java rename to retrofit/src/main/java/retrofit/CallbackRunnable.java index 4d291ea1..c1173400 100644 --- a/retrofit/src/main/java/retrofit/http/CallbackRunnable.java +++ b/retrofit/src/main/java/retrofit/CallbackRunnable.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit; import java.util.concurrent.Executor; diff --git a/retrofit/src/main/java/retrofit/http/ChangeableServer.java b/retrofit/src/main/java/retrofit/ChangeableServer.java similarity index 96% rename from retrofit/src/main/java/retrofit/http/ChangeableServer.java rename to retrofit/src/main/java/retrofit/ChangeableServer.java index b0c9ef69..e2ad65b0 100644 --- a/retrofit/src/main/java/retrofit/http/ChangeableServer.java +++ b/retrofit/src/main/java/retrofit/ChangeableServer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit; /** A {@link Server} whose URL and name can be changed at runtime. */ public class ChangeableServer extends Server { @@ -39,7 +39,7 @@ public class ChangeableServer extends Server { this.url = url; } - /** Update the URL and name returned by {@link #getUrl()} and {@link #getName()}, respetively. */ + /** Update the URL and name returned by {@link #getUrl()} and {@link #getName()}, respectively. */ public void update(String url, String name) { this.url = url; this.name = name; diff --git a/retrofit/src/main/java/retrofit/http/Platform.java b/retrofit/src/main/java/retrofit/Platform.java similarity index 86% rename from retrofit/src/main/java/retrofit/http/Platform.java rename to retrofit/src/main/java/retrofit/Platform.java index 52af0b98..8721a097 100644 --- a/retrofit/src/main/java/retrofit/http/Platform.java +++ b/retrofit/src/main/java/retrofit/Platform.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit; import android.os.Build; import android.os.Process; @@ -22,16 +22,16 @@ import com.google.gson.Gson; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; -import retrofit.http.android.AndroidApacheClient; -import retrofit.http.android.MainThreadExecutor; -import retrofit.http.client.Client; -import retrofit.http.client.OkClient; -import retrofit.http.client.UrlConnectionClient; +import retrofit.android.AndroidApacheClient; +import retrofit.android.MainThreadExecutor; +import retrofit.client.Client; +import retrofit.client.OkClient; +import retrofit.client.UrlConnectionClient; +import retrofit.converter.Converter; +import retrofit.converter.GsonConverter; import static android.os.Process.THREAD_PRIORITY_BACKGROUND; import static java.lang.Thread.MIN_PRIORITY; -import static retrofit.http.RestAdapter.IDLE_THREAD_NAME; -import static retrofit.http.Utils.SynchronousExecutor; abstract class Platform { private static final Platform PLATFORM = findPlatform(); @@ -49,10 +49,7 @@ abstract class Platform { } } - Converter defaultConverter() { - return new GsonConverter(new Gson()); - } - + abstract Converter defaultConverter(); abstract Client.Provider defaultClient(); abstract Executor defaultHttpExecutor(); abstract Executor defaultCallbackExecutor(); @@ -60,6 +57,10 @@ abstract class Platform { /** Provides sane defaults for operation on the JVM. */ private static class Base extends Platform { + @Override Converter defaultConverter() { + return new GsonConverter(new Gson()); + } + @Override Client.Provider defaultClient() { final Client client; if (hasOkHttpOnClasspath()) { @@ -82,13 +83,13 @@ abstract class Platform { Thread.currentThread().setPriority(MIN_PRIORITY); r.run(); } - }, IDLE_THREAD_NAME); + }, RestAdapter.IDLE_THREAD_NAME); } }); } @Override Executor defaultCallbackExecutor() { - return new SynchronousExecutor(); + return new Utils.SynchronousExecutor(); } @Override RestAdapter.Log defaultLog() { @@ -102,6 +103,10 @@ abstract class Platform { /** Provides sane defaults for operation on Android. */ private static class Android extends Platform { + @Override Converter defaultConverter() { + return new GsonConverter(new Gson()); + } + @Override Client.Provider defaultClient() { final Client client; if (hasOkHttpOnClasspath()) { @@ -126,7 +131,7 @@ abstract class Platform { Process.setThreadPriority(THREAD_PRIORITY_BACKGROUND); r.run(); } - }, IDLE_THREAD_NAME); + }, RestAdapter.IDLE_THREAD_NAME); } }); } @@ -156,7 +161,7 @@ abstract class Platform { /** * Indirection for OkHttp class to prevent VerifyErrors on Android 2.0 and earlier when the - * dependency is not present.. + * dependency is not present. */ private static class OkClientInstantiator { static Client instantiate() { diff --git a/retrofit/src/main/java/retrofit/http/Profiler.java b/retrofit/src/main/java/retrofit/Profiler.java similarity index 97% rename from retrofit/src/main/java/retrofit/http/Profiler.java rename to retrofit/src/main/java/retrofit/Profiler.java index f8213c94..842d4504 100644 --- a/retrofit/src/main/java/retrofit/http/Profiler.java +++ b/retrofit/src/main/java/retrofit/Profiler.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit; /** * A hook allowing clients to log HTTP method times and response status codes. @@ -26,7 +26,7 @@ public interface Profiler { * Invoked before an HTTP method call. The object returned by this method will be * passed to {@link #afterCall} when the call returns. *

- * This method gives implementors the opportunity to include information that may + * This method gives implementers the opportunity to include information that may * change during the server call in {@code afterCall} logic. */ T beforeCall(); diff --git a/retrofit/src/main/java/retrofit/http/RequestBuilder.java b/retrofit/src/main/java/retrofit/RequestBuilder.java similarity index 89% rename from retrofit/src/main/java/retrofit/http/RequestBuilder.java rename to retrofit/src/main/java/retrofit/RequestBuilder.java index 7e6dd73f..310b51ba 100644 --- a/retrofit/src/main/java/retrofit/http/RequestBuilder.java +++ b/retrofit/src/main/java/retrofit/RequestBuilder.java @@ -13,19 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; -import retrofit.http.client.Header; -import retrofit.http.client.Request; -import retrofit.http.mime.FormUrlEncodedTypedOutput; -import retrofit.http.mime.MultipartTypedOutput; -import retrofit.http.mime.TypedOutput; - -import static retrofit.http.RestMethodInfo.NO_BODY; +import retrofit.client.Header; +import retrofit.client.Request; +import retrofit.converter.Converter; +import retrofit.mime.FormUrlEncodedTypedOutput; +import retrofit.mime.MultipartTypedOutput; +import retrofit.mime.TypedOutput; /** Builds HTTP requests from Java method invocations. */ final class RequestBuilder { @@ -34,7 +33,7 @@ final class RequestBuilder { private RestMethodInfo methodInfo; private Object[] args; private String apiUrl; - private List headers; + private List headers; RequestBuilder(Converter converter) { this.converter = converter; @@ -59,7 +58,7 @@ final class RequestBuilder { } /** A list of custom headers. */ - RequestBuilder headers(List headers) { + RequestBuilder headers(List headers) { this.headers = headers; return this; } @@ -100,7 +99,7 @@ final class RequestBuilder { } } - List headers = new ArrayList(); + List headers = new ArrayList(); if (this.headers != null) { headers.addAll(this.headers); } @@ -116,7 +115,7 @@ final class RequestBuilder { if (name == null) continue; Object arg = args[i]; if (arg != null) { - headers.add(new retrofit.http.client.Header(name, String.valueOf(arg))); + headers.add(new retrofit.client.Header(name, String.valueOf(arg))); } } } @@ -143,7 +142,7 @@ final class RequestBuilder { switch (methodInfo.requestType) { case SIMPLE: { int bodyIndex = methodInfo.bodyIndex; - if (bodyIndex == NO_BODY) { + if (bodyIndex == RestMethodInfo.NO_BODY) { return null; } Object body = args[bodyIndex]; diff --git a/retrofit/src/main/java/retrofit/http/RequestHeaders.java b/retrofit/src/main/java/retrofit/RequestHeaders.java similarity index 91% rename from retrofit/src/main/java/retrofit/http/RequestHeaders.java rename to retrofit/src/main/java/retrofit/RequestHeaders.java index b8b26a1f..c1bef05d 100644 --- a/retrofit/src/main/java/retrofit/http/RequestHeaders.java +++ b/retrofit/src/main/java/retrofit/RequestHeaders.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit; import java.util.Collections; import java.util.List; -import retrofit.http.client.Header; +import retrofit.client.Header; /** Manages headers for each request. */ public interface RequestHeaders { @@ -25,7 +25,7 @@ public interface RequestHeaders { * Get a list of headers for a request. This method will be called once for each request allowing * you to change the list as the state of your application changes. */ - List get(); + List

get(); /** Empty header list. */ RequestHeaders NONE = new RequestHeaders() { diff --git a/retrofit/src/main/java/retrofit/http/ResponseWrapper.java b/retrofit/src/main/java/retrofit/ResponseWrapper.java similarity index 73% rename from retrofit/src/main/java/retrofit/http/ResponseWrapper.java rename to retrofit/src/main/java/retrofit/ResponseWrapper.java index 8fe9d7ff..65b88136 100644 --- a/retrofit/src/main/java/retrofit/http/ResponseWrapper.java +++ b/retrofit/src/main/java/retrofit/ResponseWrapper.java @@ -13,22 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit; -import retrofit.http.client.Response; +import retrofit.client.Response; /** - * A wrapper that holds the {@link Response} and {@link Converter} response to be used by the - * {@link CallbackRunnable} for success method calls on {@link Callback}. + * A wrapper that holds the {@link Response} and {@link retrofit.converter.Converter} response to + * be used by the {@link CallbackRunnable} for success method calls on {@link Callback}. * * @author JJ Ford (jj.n.ford@gmail.com) */ final class ResponseWrapper { - final Response response; final Object responseBody; - public ResponseWrapper(Response response, Object responseBody) { + ResponseWrapper(Response response, Object responseBody) { this.response = response; this.responseBody = responseBody; } diff --git a/retrofit/src/main/java/retrofit/http/RestAdapter.java b/retrofit/src/main/java/retrofit/RestAdapter.java similarity index 84% rename from retrofit/src/main/java/retrofit/http/RestAdapter.java rename to retrofit/src/main/java/retrofit/RestAdapter.java index 9a1fbb4d..cea6f16b 100644 --- a/retrofit/src/main/java/retrofit/http/RestAdapter.java +++ b/retrofit/src/main/java/retrofit/RestAdapter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -26,16 +26,17 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; -import retrofit.http.Profiler.RequestInformation; -import retrofit.http.client.Client; -import retrofit.http.client.Header; -import retrofit.http.client.Request; -import retrofit.http.client.Response; -import retrofit.http.mime.TypedByteArray; -import retrofit.http.mime.TypedInput; -import retrofit.http.mime.TypedOutput; - -import static retrofit.http.Utils.SynchronousExecutor; +import retrofit.Profiler.RequestInformation; +import retrofit.client.Client; +import retrofit.client.Header; +import retrofit.client.Request; +import retrofit.client.Response; +import retrofit.converter.ConversionException; +import retrofit.converter.Converter; +import retrofit.mime.MimeUtil; +import retrofit.mime.TypedByteArray; +import retrofit.mime.TypedInput; +import retrofit.mime.TypedOutput; /** * Adapts a Java interface to a REST API. @@ -44,42 +45,47 @@ import static retrofit.http.Utils.SynchronousExecutor; * the form in which the HTTP call should be made. *

* The relative path for a given method is obtained from an annotation on the method describing - * the request type. The built-in methods are {@link GET}, {@link PUT}, {@link POST}, {@link HEAD}, - * and {@link DELETE}. You can define your own HTTP method by creating an annotation that takes a - * {code String} value and itself is annotated with {@link RestMethod @RestMethod}. + * the request type. The built-in methods are {@link retrofit.http.GET GET}, + * {@link retrofit.http.PUT PUT}, {@link retrofit.http.POST POST}, {@link retrofit.http.HEAD HEAD}, + * and {@link retrofit.http.DELETE DELETE}. You can define your own HTTP method by creating an + * annotation that takes a {code String} value and itself is annotated with + * {@link retrofit.http.RestMethod @RestMethod}. *

* Method parameters can be used to replace parts of the URL by annotating them with - * {@link Path @Path}. Replacement sections are denoted by an identifier surrounded by curly braces - * (e.g., "{foo}"). To add items to the query string of a URL use {@link Query @Query}. + * {@link retrofit.http.Path @Path}. Replacement sections are denoted by an identifier surrounded + * by curly braces (e.g., "{foo}"). To add items to the query string of a URL use + * {@link retrofit.http.Query @Query}. *

* HTTP requests happen in one of two ways: *

    *
  • On the provided HTTP {@link Executor} with callbacks marshaled to the callback * {@link Executor}. The last method parameter should be of type {@link Callback}. The HTTP * response will be converted to the callback's parameter type using the specified - * {@link Converter}. If the callback parameter type uses a wildcard, the lower bound will be - * used as the conversion type. + * {@link retrofit.converter.Converter Converter}. If the callback parameter type uses a wildcard, + * the lower bound will be used as the conversion type. *
  • On the current thread returning the response or throwing a {@link RetrofitError}. The HTTP - * response will be converted to the method's return type using the specified {@link Converter}. + * response will be converted to the method's return type using the specified + * {@link retrofit.converter.Converter Converter}. *
*

- * The body of a request is denoted by the {@link Body @Body} annotation. The object will be - * converted to request representation by a call to {@link Converter#toBody(Object) toBody} on the - * supplied {@link Converter} for this instance. The body can also be a {@link TypedOutput} where - * it will be used directly. + * The body of a request is denoted by the {@link retrofit.http.Body @Body} annotation. The object + * will be converted to request representation by a call to + * {@link retrofit.converter.Converter#toBody(Object) toBody} on the supplied + * {@link retrofit.converter.Converter Converter} for this instance. The body can also be a + * {@link TypedOutput} where it will be used directly. *

* Alternative request body formats are supported by method annotations and corresponding parameter * annotations: *

    - *
  • {@link FormUrlEncoded @FormUrlEncoded} - Form-encoded data with pairs specified by the - * {@link Field @Field} parameter annotation. - *
  • {@link Multipart @Multipart} - RFC 2387-compliant multi-part data with parts specified by - * the {@link Part @Part} parameter annotation. + *
  • {@link retrofit.http.FormUrlEncoded @FormUrlEncoded} - Form-encoded data with pairs + * specified by the {@link retrofit.http.Field @Field} parameter annotation. + *
  • {@link retrofit.http.Multipart @Multipart} - RFC 2387-compliant multi-part data with parts + * specified by the {@link retrofit.http.Part @Part} parameter annotation. *
*

- * Additional static headers can be added for an endpoint using the {@link Headers @Headers} method - * annotation. For per-request control over a header annotate a parameter with - * {@link Header @Header}. + * Additional static headers can be added for an endpoint using the + * {@link retrofit.http.Headers @Headers} method annotation. For per-request control over a header + * annotate a parameter with {@link Header @Header}. *

* For example: *

@@ -132,7 +138,7 @@ public class RestAdapter {
     this.debug = debug;
   }
 
-  /** Toggle debug logging on and off. */
+  /** Toggle debug logging on or off. */
   public void setDebug(boolean debug) {
     this.debug = debug;
   }
@@ -189,8 +195,8 @@ public class RestAdapter {
     /**
      * Execute an HTTP request.
      *
-     * @return HTTP response object of specified {@code type}.
-     * @throws RetrofitError Thrown if any error occurs during the HTTP request.
+     * @return HTTP response object of specified {@code type} or {@code null}.
+     * @throws RetrofitError if any error occurs during the HTTP request.
      */
     private Object invokeRequest(RestMethodInfo methodDetails, Object[] args) {
       methodDetails.init(); // Ensure all relevant method information has been loaded.
@@ -227,6 +233,7 @@ public class RestAdapter {
         int statusCode = response.getStatus();
         if (profiler != null) {
           RequestInformation requestInfo = getRequestInfo(serverUrl, methodDetails, request);
+          //noinspection unchecked
           profiler.afterCall(requestInfo, elapsedTime, statusCode, profilerObject);
         }
 
@@ -302,7 +309,7 @@ public class RestAdapter {
       byte[] bodyBytes = baos.toByteArray();
       bodySize = bodyBytes.length;
       String bodyMime = body.mimeType();
-      String bodyString = new String(bodyBytes, Utils.parseCharset(bodyMime));
+      String bodyString = new String(bodyBytes, MimeUtil.parseCharset(bodyMime));
       for (int i = 0, len = bodyString.length(); i < len; i += LOG_CHUNK_SIZE) {
         int end = Math.min(len, i + LOG_CHUNK_SIZE);
         log.log(bodyString.substring(i, end));
@@ -342,7 +349,7 @@ public class RestAdapter {
       byte[] bodyBytes = ((TypedByteArray) body).getBytes();
       bodySize = bodyBytes.length;
       String bodyMime = body.mimeType();
-      String bodyCharset = Utils.parseCharset(bodyMime);
+      String bodyCharset = MimeUtil.parseCharset(bodyMime);
       String bodyString = new String(bodyBytes, bodyCharset);
       for (int i = 0, len = bodyString.length(); i < len; i += LOG_CHUNK_SIZE) {
         int end = Math.min(len, i + LOG_CHUNK_SIZE);
@@ -397,17 +404,20 @@ public class RestAdapter {
     private Log log;
     private boolean debug;
 
+    /** API server base URL. */
     public Builder setServer(String endpoint) {
       if (endpoint == null) throw new NullPointerException("endpoint");
       return setServer(new Server(endpoint));
     }
 
+    /** API server. */
     public Builder setServer(Server server) {
       if (server == null) throw new NullPointerException("server");
       this.server = server;
       return this;
     }
 
+    /** The HTTP client used for requests. */
     public Builder setClient(final Client client) {
       if (client == null) throw new NullPointerException("client");
       return setClient(new Client.Provider() {
@@ -417,6 +427,7 @@ public class RestAdapter {
       });
     }
 
+    /** The HTTP client used for requests. */
     public Builder setClient(Client.Provider clientProvider) {
       if (clientProvider == null) throw new NullPointerException("clientProvider");
       this.clientProvider = clientProvider;
@@ -433,41 +444,47 @@ public class RestAdapter {
      */
     public Builder setExecutors(Executor httpExecutor, Executor callbackExecutor) {
       if (httpExecutor == null) throw new NullPointerException("httpExecutor");
-      if (callbackExecutor == null) callbackExecutor = new SynchronousExecutor();
+      if (callbackExecutor == null) callbackExecutor = new Utils.SynchronousExecutor();
       this.httpExecutor = httpExecutor;
       this.callbackExecutor = callbackExecutor;
       return this;
     }
 
+    /**  */
     public Builder setRequestHeaders(RequestHeaders requestHeaders) {
       if (requestHeaders == null) throw new NullPointerException("requestHeaders");
       this.requestHeaders = requestHeaders;
       return this;
     }
 
+    /** The converter used for serialization and deserialization of objects. */
     public Builder setConverter(Converter converter) {
       if (converter == null) throw new NullPointerException("converter");
       this.converter = converter;
       return this;
     }
 
+    /** Set the profiler used to measure requests. */
     public Builder setProfiler(Profiler profiler) {
       if (profiler == null) throw new NullPointerException("profiler");
       this.profiler = profiler;
       return this;
     }
 
+    /** Configure debug logging mechanism. */
     public Builder setLog(Log log) {
       if (log == null) throw new NullPointerException("log");
       this.log = log;
       return this;
     }
 
+    /** Enable debug logging. */
     public Builder setDebug(boolean debug) {
       this.debug = debug;
       return this;
     }
 
+    /** Create the {@link RestAdapter} instances. */
     public RestAdapter build() {
       if (server == null) {
         throw new IllegalArgumentException("Server may not be null.");
diff --git a/retrofit/src/main/java/retrofit/http/RestMethodInfo.java b/retrofit/src/main/java/retrofit/RestMethodInfo.java
similarity index 96%
rename from retrofit/src/main/java/retrofit/http/RestMethodInfo.java
rename to retrofit/src/main/java/retrofit/RestMethodInfo.java
index 63bcf350..2a9a6034 100644
--- a/retrofit/src/main/java/retrofit/http/RestMethodInfo.java
+++ b/retrofit/src/main/java/retrofit/RestMethodInfo.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http;
+package retrofit;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
@@ -26,6 +26,16 @@ import java.util.List;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import retrofit.http.Body;
+import retrofit.http.Field;
+import retrofit.http.FormUrlEncoded;
+import retrofit.http.Header;
+import retrofit.http.Headers;
+import retrofit.http.Multipart;
+import retrofit.http.Part;
+import retrofit.http.Path;
+import retrofit.http.Query;
+import retrofit.http.RestMethod;
 
 /** Request metadata about a service interface declaration. */
 final class RestMethodInfo {
@@ -57,7 +67,7 @@ final class RestMethodInfo {
   String requestUrl;
   Set requestUrlParamNames;
   String requestQuery;
-  List headers;
+  List headers;
 
   // Parameter-level details
   String[] requestUrlParam;
@@ -198,14 +208,14 @@ final class RestMethodInfo {
     requestQuery = query;
   }
 
-  private List parseHeaders(String[] headers) {
-    List headerList = new ArrayList();
+  private List parseHeaders(String[] headers) {
+    List headerList = new ArrayList();
     for (String header : headers) {
       int colon = header.indexOf(':');
       if (colon == -1 || colon == 0 || colon == headers.length - 1) {
         throw new IllegalStateException("Header must be in the form 'Name: Value': " + header);
       }
-      headerList.add(new retrofit.http.client.Header(header.substring(0, colon),
+      headerList.add(new retrofit.client.Header(header.substring(0, colon),
           header.substring(colon + 1).trim()));
     }
     return headerList;
diff --git a/retrofit/src/main/java/retrofit/http/RetrofitError.java b/retrofit/src/main/java/retrofit/RetrofitError.java
similarity index 94%
rename from retrofit/src/main/java/retrofit/http/RetrofitError.java
rename to retrofit/src/main/java/retrofit/RetrofitError.java
index e2a46004..4a8b2cff 100644
--- a/retrofit/src/main/java/retrofit/http/RetrofitError.java
+++ b/retrofit/src/main/java/retrofit/RetrofitError.java
@@ -13,12 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http;
+package retrofit;
 
 import java.io.IOException;
 import java.lang.reflect.Type;
-import retrofit.http.client.Response;
-import retrofit.http.mime.TypedInput;
+import retrofit.client.Response;
+import retrofit.converter.ConversionException;
+import retrofit.converter.Converter;
+import retrofit.mime.TypedInput;
 
 public class RetrofitError extends RuntimeException {
   public static RetrofitError networkError(String url, IOException exception) {
diff --git a/retrofit/src/main/java/retrofit/http/Server.java b/retrofit/src/main/java/retrofit/Server.java
similarity index 98%
rename from retrofit/src/main/java/retrofit/http/Server.java
rename to retrofit/src/main/java/retrofit/Server.java
index ec934774..4237dbd0 100644
--- a/retrofit/src/main/java/retrofit/http/Server.java
+++ b/retrofit/src/main/java/retrofit/Server.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http;
+package retrofit;
 
 /**
  * Represents an API endpoint URL and associated name. Callers should always consult the instance
diff --git a/retrofit/src/main/java/retrofit/http/Types.java b/retrofit/src/main/java/retrofit/Types.java
similarity index 99%
rename from retrofit/src/main/java/retrofit/http/Types.java
rename to retrofit/src/main/java/retrofit/Types.java
index 83a1c69e..0ad4e551 100644
--- a/retrofit/src/main/java/retrofit/http/Types.java
+++ b/retrofit/src/main/java/retrofit/Types.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http;
+package retrofit;
 
 import java.lang.reflect.Array;
 import java.lang.reflect.GenericArrayType;
diff --git a/retrofit/src/main/java/retrofit/http/Utils.java b/retrofit/src/main/java/retrofit/Utils.java
similarity index 79%
rename from retrofit/src/main/java/retrofit/http/Utils.java
rename to retrofit/src/main/java/retrofit/Utils.java
index 6781409f..9d4bab2c 100644
--- a/retrofit/src/main/java/retrofit/http/Utils.java
+++ b/retrofit/src/main/java/retrofit/Utils.java
@@ -14,22 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http;
+package retrofit;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.concurrent.Executor;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import retrofit.http.client.Response;
-import retrofit.http.mime.TypedByteArray;
-import retrofit.http.mime.TypedInput;
+import retrofit.client.Response;
+import retrofit.mime.TypedByteArray;
+import retrofit.mime.TypedInput;
 
-import static java.util.regex.Pattern.CASE_INSENSITIVE;
-
-public final class Utils {
-  private static final Pattern CHARSET = Pattern.compile("\\Wcharset=([^\\s;]+)", CASE_INSENSITIVE);
+final class Utils {
   private static final int BUFFER_SIZE = 0x1000;
 
   /**
@@ -71,14 +66,6 @@ public final class Utils {
     return new Response(response.getStatus(), response.getReason(), response.getHeaders(), body);
   }
 
-  public static String parseCharset(String mimeType) {
-    Matcher match = CHARSET.matcher(mimeType);
-    if (match.find()) {
-      return match.group(1).replaceAll("[\"\\\\]", "");
-    }
-    return "UTF-8";
-  }
-
   static class SynchronousExecutor implements Executor {
     @Override public void execute(Runnable runnable) {
       runnable.run();
diff --git a/retrofit/src/main/java/retrofit/http/android/AndroidApacheClient.java b/retrofit/src/main/java/retrofit/android/AndroidApacheClient.java
similarity index 86%
rename from retrofit/src/main/java/retrofit/http/android/AndroidApacheClient.java
rename to retrofit/src/main/java/retrofit/android/AndroidApacheClient.java
index af615a20..d5ae3dc8 100644
--- a/retrofit/src/main/java/retrofit/http/android/AndroidApacheClient.java
+++ b/retrofit/src/main/java/retrofit/android/AndroidApacheClient.java
@@ -13,13 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http.android;
+package retrofit.android;
 
 import android.net.http.AndroidHttpClient;
-import retrofit.http.client.ApacheClient;
+import retrofit.client.ApacheClient;
 
 /**
- * Provides a {@link retrofit.http.client.Client} which uses the Android-specific version of
+ * Provides a {@link retrofit.client.Client} which uses the Android-specific version of
  * {@link org.apache.http.client.HttpClient}, {@link AndroidHttpClient}.
  * 

* If you need to provide a customized version of the {@link AndroidHttpClient} or a different diff --git a/retrofit/src/main/java/retrofit/http/android/MainThreadExecutor.java b/retrofit/src/main/java/retrofit/android/MainThreadExecutor.java similarity index 96% rename from retrofit/src/main/java/retrofit/http/android/MainThreadExecutor.java rename to retrofit/src/main/java/retrofit/android/MainThreadExecutor.java index fb003f47..81440d04 100644 --- a/retrofit/src/main/java/retrofit/http/android/MainThreadExecutor.java +++ b/retrofit/src/main/java/retrofit/android/MainThreadExecutor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http.android; +package retrofit.android; import android.os.Handler; import android.os.Looper; diff --git a/retrofit/src/main/java/retrofit/http/client/ApacheClient.java b/retrofit/src/main/java/retrofit/client/ApacheClient.java similarity index 97% rename from retrofit/src/main/java/retrofit/http/client/ApacheClient.java rename to retrofit/src/main/java/retrofit/client/ApacheClient.java index d31081dd..1b75da3d 100644 --- a/retrofit/src/main/java/retrofit/http/client/ApacheClient.java +++ b/retrofit/src/main/java/retrofit/client/ApacheClient.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http.client; +package retrofit.client; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -33,8 +33,8 @@ import org.apache.http.entity.AbstractHttpEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicHeader; import org.apache.http.util.EntityUtils; -import retrofit.http.mime.TypedByteArray; -import retrofit.http.mime.TypedOutput; +import retrofit.mime.TypedByteArray; +import retrofit.mime.TypedOutput; /** A {@link Client} which uses an implementation of Apache's {@link HttpClient}. */ public class ApacheClient implements Client { diff --git a/retrofit/src/main/java/retrofit/http/client/Client.java b/retrofit/src/main/java/retrofit/client/Client.java similarity index 97% rename from retrofit/src/main/java/retrofit/http/client/Client.java rename to retrofit/src/main/java/retrofit/client/Client.java index 27f7949d..5608b535 100644 --- a/retrofit/src/main/java/retrofit/http/client/Client.java +++ b/retrofit/src/main/java/retrofit/client/Client.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http.client; +package retrofit.client; import java.io.IOException; diff --git a/retrofit/src/main/java/retrofit/http/client/Header.java b/retrofit/src/main/java/retrofit/client/Header.java similarity index 98% rename from retrofit/src/main/java/retrofit/http/client/Header.java rename to retrofit/src/main/java/retrofit/client/Header.java index a1d184d6..41daf5b2 100644 --- a/retrofit/src/main/java/retrofit/http/client/Header.java +++ b/retrofit/src/main/java/retrofit/client/Header.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http.client; +package retrofit.client; /** Represents an HTTP header name/value pair. */ public final class Header { diff --git a/retrofit/src/main/java/retrofit/http/client/OkClient.java b/retrofit/src/main/java/retrofit/client/OkClient.java similarity index 97% rename from retrofit/src/main/java/retrofit/http/client/OkClient.java rename to retrofit/src/main/java/retrofit/client/OkClient.java index 9be66ec5..122fb55e 100644 --- a/retrofit/src/main/java/retrofit/http/client/OkClient.java +++ b/retrofit/src/main/java/retrofit/client/OkClient.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http.client; +package retrofit.client; import com.squareup.okhttp.OkHttpClient; import java.io.IOException; diff --git a/retrofit/src/main/java/retrofit/http/client/Request.java b/retrofit/src/main/java/retrofit/client/Request.java similarity index 96% rename from retrofit/src/main/java/retrofit/http/client/Request.java rename to retrofit/src/main/java/retrofit/client/Request.java index 3e32ce58..8d2199de 100644 --- a/retrofit/src/main/java/retrofit/http/client/Request.java +++ b/retrofit/src/main/java/retrofit/client/Request.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http.client; +package retrofit.client; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import retrofit.http.mime.TypedOutput; +import retrofit.mime.TypedOutput; /** Encapsulates all of the information necessary to make an HTTP request. */ public final class Request { diff --git a/retrofit/src/main/java/retrofit/http/client/Response.java b/retrofit/src/main/java/retrofit/client/Response.java similarity index 96% rename from retrofit/src/main/java/retrofit/http/client/Response.java rename to retrofit/src/main/java/retrofit/client/Response.java index bc14ab29..44c1406b 100644 --- a/retrofit/src/main/java/retrofit/http/client/Response.java +++ b/retrofit/src/main/java/retrofit/client/Response.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http.client; +package retrofit.client; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import retrofit.http.mime.TypedInput; +import retrofit.mime.TypedInput; /** An HTTP response. */ public final class Response { diff --git a/retrofit/src/main/java/retrofit/http/client/UrlConnectionClient.java b/retrofit/src/main/java/retrofit/client/UrlConnectionClient.java similarity index 96% rename from retrofit/src/main/java/retrofit/http/client/UrlConnectionClient.java rename to retrofit/src/main/java/retrofit/client/UrlConnectionClient.java index 84ad6571..fcca8c48 100644 --- a/retrofit/src/main/java/retrofit/http/client/UrlConnectionClient.java +++ b/retrofit/src/main/java/retrofit/client/UrlConnectionClient.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http.client; +package retrofit.client; import java.io.IOException; import java.io.InputStream; @@ -22,8 +22,8 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; -import retrofit.http.mime.TypedInput; -import retrofit.http.mime.TypedOutput; +import retrofit.mime.TypedInput; +import retrofit.mime.TypedOutput; /** Retrofit client that uses {@link HttpURLConnection} for communication. */ public class UrlConnectionClient implements Client { diff --git a/retrofit/src/main/java/retrofit/http/ConversionException.java b/retrofit/src/main/java/retrofit/converter/ConversionException.java similarity index 97% rename from retrofit/src/main/java/retrofit/http/ConversionException.java rename to retrofit/src/main/java/retrofit/converter/ConversionException.java index 5619f54e..6673efc0 100644 --- a/retrofit/src/main/java/retrofit/http/ConversionException.java +++ b/retrofit/src/main/java/retrofit/converter/ConversionException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit.converter; /** Indicate that conversion was unable to complete successfully. */ @SuppressWarnings("UnusedDeclaration") diff --git a/retrofit/src/main/java/retrofit/http/Converter.java b/retrofit/src/main/java/retrofit/converter/Converter.java similarity index 81% rename from retrofit/src/main/java/retrofit/http/Converter.java rename to retrofit/src/main/java/retrofit/converter/Converter.java index 73289cff..6ac5b6fa 100644 --- a/retrofit/src/main/java/retrofit/http/Converter.java +++ b/retrofit/src/main/java/retrofit/converter/Converter.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit.converter; import java.lang.reflect.Type; -import retrofit.http.mime.TypedInput; -import retrofit.http.mime.TypedOutput; +import retrofit.mime.TypedInput; +import retrofit.mime.TypedOutput; /** * Arbiter for converting objects to and from their representation in HTTP. @@ -32,9 +32,9 @@ public interface Converter { * @param type Target object type. * @return Instance of {@code type} which will be cast by the caller. * @throws ConversionException if conversion was unable to complete. This will trigger a call to - * {@link Callback#failure(RetrofitError)} or throw a {@link retrofit.http.RetrofitError}. The - * exception message should report all necessary information about its cause as the response body - * will be set to {@code null}. + * {@link retrofit.Callback#failure(retrofit.RetrofitError)} or throw a + * {@link retrofit.RetrofitError}. The exception message should report all necessary information + * about its cause as the response body will be set to {@code null}. */ Object fromBody(TypedInput body, Type type) throws ConversionException; diff --git a/retrofit/src/main/java/retrofit/http/GsonConverter.java b/retrofit/src/main/java/retrofit/converter/GsonConverter.java similarity index 90% rename from retrofit/src/main/java/retrofit/http/GsonConverter.java rename to retrofit/src/main/java/retrofit/converter/GsonConverter.java index a8cb8499..9e5df33c 100644 --- a/retrofit/src/main/java/retrofit/http/GsonConverter.java +++ b/retrofit/src/main/java/retrofit/converter/GsonConverter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package retrofit.http; +package retrofit.converter; import com.google.gson.Gson; import com.google.gson.JsonParseException; @@ -22,8 +22,9 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; -import retrofit.http.mime.TypedInput; -import retrofit.http.mime.TypedOutput; +import retrofit.mime.MimeUtil; +import retrofit.mime.TypedInput; +import retrofit.mime.TypedOutput; /** * A {@link Converter} which uses GSON for serialization and deserialization of entities. @@ -38,7 +39,7 @@ public class GsonConverter implements Converter { } @Override public Object fromBody(TypedInput body, Type type) throws ConversionException { - String charset = Utils.parseCharset(body.mimeType()); + String charset = MimeUtil.parseCharset(body.mimeType()); InputStreamReader isr = null; try { isr = new InputStreamReader(body.in(), charset); @@ -65,7 +66,7 @@ public class GsonConverter implements Converter { } } - static class JsonTypedOutput implements TypedOutput { + private static class JsonTypedOutput implements TypedOutput { private final byte[] jsonBytes; JsonTypedOutput(byte[] jsonBytes) { diff --git a/retrofit/src/main/java/retrofit/http/Parameter.java b/retrofit/src/main/java/retrofit/http/Parameter.java deleted file mode 100644 index daf402a0..00000000 --- a/retrofit/src/main/java/retrofit/http/Parameter.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2013 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package retrofit.http; - -import java.lang.reflect.Type; - -/** - * Represents a named parameter and its value. - *

- * This is used in one of three places in a request: - *

    - *
  • Named replacement in the relative URL path. - *
  • As a URL query parameter. - *
  • As a POST/PUT body. - *
- */ -public final class Parameter { - private final String name; - private final Type type; - private final Object value; - - public Parameter(String name, Object value, Type valueType) { - if (name == null) { - throw new NullPointerException("name == null"); - } - - this.name = name; - this.type = valueType; - this.value = value; - } - - public String getName() { - return name; - } - - public Object getValue() { - return value; - } - - /** The instance type of {@link #getValue()}. */ - public Type getValueType() { - return type; - } - - @Override public String toString() { - return name + "=" + value; - } - - @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Parameter parameter = (Parameter) o; - - if (!name.equals(parameter.name)) return false; - if (value != null ? !value.equals(parameter.value) : parameter.value != null) return false; - - return true; - } - - @Override public int hashCode() { - int result = name.hashCode(); - result = 31 * result + (value != null ? value.hashCode() : 0); - return result; - } -} diff --git a/retrofit/src/main/java/retrofit/http/Part.java b/retrofit/src/main/java/retrofit/http/Part.java index 33731a1f..be78a14e 100644 --- a/retrofit/src/main/java/retrofit/http/Part.java +++ b/retrofit/src/main/java/retrofit/http/Part.java @@ -26,10 +26,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; *

* The parameter type on which this annotation exists will be processed in one of two ways: *

    - *
  • If the type implements {@link retrofit.http.mime.TypedOutput TypedOutput} the headers and + *
  • If the type implements {@link retrofit.mime.TypedOutput TypedOutput} the headers and * body will be used directly.
  • *
  • Other object types will be converted to an appropriate representation by calling {@link - * Converter#toBody(Object)}.
  • + * retrofit.converter.Converter#toBody(Object)}. *
*

*

diff --git a/retrofit/src/main/java/retrofit/http/mime/FormUrlEncodedTypedOutput.java b/retrofit/src/main/java/retrofit/mime/FormUrlEncodedTypedOutput.java
similarity index 98%
rename from retrofit/src/main/java/retrofit/http/mime/FormUrlEncodedTypedOutput.java
rename to retrofit/src/main/java/retrofit/mime/FormUrlEncodedTypedOutput.java
index f748762d..2cfa3608 100644
--- a/retrofit/src/main/java/retrofit/http/mime/FormUrlEncodedTypedOutput.java
+++ b/retrofit/src/main/java/retrofit/mime/FormUrlEncodedTypedOutput.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http.mime;
+package retrofit.mime;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
diff --git a/retrofit/src/main/java/retrofit/mime/MimeUtil.java b/retrofit/src/main/java/retrofit/mime/MimeUtil.java
new file mode 100644
index 00000000..7307703d
--- /dev/null
+++ b/retrofit/src/main/java/retrofit/mime/MimeUtil.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 Square, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package retrofit.mime;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static java.util.regex.Pattern.CASE_INSENSITIVE;
+
+public final class MimeUtil {
+  private static final Pattern CHARSET = Pattern.compile("\\Wcharset=([^\\s;]+)", CASE_INSENSITIVE);
+
+  /** Parse the MIME type from a {@code Content-Type} header value. */
+  public static String parseCharset(String mimeType) {
+    Matcher match = CHARSET.matcher(mimeType);
+    if (match.find()) {
+      return match.group(1).replaceAll("[\"\\\\]", "");
+    }
+    return "UTF-8";
+  }
+
+  private MimeUtil() {
+    // No instances.
+  }
+}
diff --git a/retrofit/src/main/java/retrofit/http/mime/MultipartTypedOutput.java b/retrofit/src/main/java/retrofit/mime/MultipartTypedOutput.java
similarity index 99%
rename from retrofit/src/main/java/retrofit/http/mime/MultipartTypedOutput.java
rename to retrofit/src/main/java/retrofit/mime/MultipartTypedOutput.java
index 8e740f1a..62fd0abd 100644
--- a/retrofit/src/main/java/retrofit/http/mime/MultipartTypedOutput.java
+++ b/retrofit/src/main/java/retrofit/mime/MultipartTypedOutput.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http.mime;
+package retrofit.mime;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
diff --git a/retrofit/src/main/java/retrofit/http/mime/TypedByteArray.java b/retrofit/src/main/java/retrofit/mime/TypedByteArray.java
similarity index 98%
rename from retrofit/src/main/java/retrofit/http/mime/TypedByteArray.java
rename to retrofit/src/main/java/retrofit/mime/TypedByteArray.java
index 66b8446b..5f05def0 100644
--- a/retrofit/src/main/java/retrofit/http/mime/TypedByteArray.java
+++ b/retrofit/src/main/java/retrofit/mime/TypedByteArray.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http.mime;
+package retrofit.mime;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
diff --git a/retrofit/src/main/java/retrofit/http/mime/TypedFile.java b/retrofit/src/main/java/retrofit/mime/TypedFile.java
similarity index 99%
rename from retrofit/src/main/java/retrofit/http/mime/TypedFile.java
rename to retrofit/src/main/java/retrofit/mime/TypedFile.java
index a13d7c34..43fcd3a0 100644
--- a/retrofit/src/main/java/retrofit/http/mime/TypedFile.java
+++ b/retrofit/src/main/java/retrofit/mime/TypedFile.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http.mime;
+package retrofit.mime;
 
 import java.io.File;
 import java.io.FileInputStream;
diff --git a/retrofit/src/main/java/retrofit/http/mime/TypedInput.java b/retrofit/src/main/java/retrofit/mime/TypedInput.java
similarity index 97%
rename from retrofit/src/main/java/retrofit/http/mime/TypedInput.java
rename to retrofit/src/main/java/retrofit/mime/TypedInput.java
index b2d48b79..f05afb84 100644
--- a/retrofit/src/main/java/retrofit/http/mime/TypedInput.java
+++ b/retrofit/src/main/java/retrofit/mime/TypedInput.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http.mime;
+package retrofit.mime;
 
 import java.io.IOException;
 import java.io.InputStream;
diff --git a/retrofit/src/main/java/retrofit/http/mime/TypedOutput.java b/retrofit/src/main/java/retrofit/mime/TypedOutput.java
similarity index 97%
rename from retrofit/src/main/java/retrofit/http/mime/TypedOutput.java
rename to retrofit/src/main/java/retrofit/mime/TypedOutput.java
index 9a8bf8ae..f15055f8 100644
--- a/retrofit/src/main/java/retrofit/http/mime/TypedOutput.java
+++ b/retrofit/src/main/java/retrofit/mime/TypedOutput.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http.mime;
+package retrofit.mime;
 
 import java.io.IOException;
 import java.io.OutputStream;
diff --git a/retrofit/src/main/java/retrofit/http/mime/TypedString.java b/retrofit/src/main/java/retrofit/mime/TypedString.java
similarity index 97%
rename from retrofit/src/main/java/retrofit/http/mime/TypedString.java
rename to retrofit/src/main/java/retrofit/mime/TypedString.java
index 0b0922f4..9c83230f 100644
--- a/retrofit/src/main/java/retrofit/http/mime/TypedString.java
+++ b/retrofit/src/main/java/retrofit/mime/TypedString.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package retrofit.http.mime;
+package retrofit.mime;
 
 import java.io.UnsupportedEncodingException;
 
diff --git a/retrofit/src/test/java/retrofit/http/CallbackRunnableTest.java b/retrofit/src/test/java/retrofit/CallbackRunnableTest.java
similarity index 88%
rename from retrofit/src/test/java/retrofit/http/CallbackRunnableTest.java
rename to retrofit/src/test/java/retrofit/CallbackRunnableTest.java
index 225fed34..6d6617d2 100644
--- a/retrofit/src/test/java/retrofit/http/CallbackRunnableTest.java
+++ b/retrofit/src/test/java/retrofit/CallbackRunnableTest.java
@@ -1,9 +1,13 @@
 // Copyright 2013 Square, Inc.
-package retrofit.http;
+package retrofit;
 
 import java.util.concurrent.Executor;
 import org.junit.Before;
 import org.junit.Test;
+import retrofit.Callback;
+import retrofit.CallbackRunnable;
+import retrofit.ResponseWrapper;
+import retrofit.RetrofitError;
 
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.same;
@@ -11,7 +15,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static retrofit.http.Utils.SynchronousExecutor;
+import static retrofit.Utils.SynchronousExecutor;
 
 public class CallbackRunnableTest {
   private Executor executor = spy(new SynchronousExecutor());
diff --git a/retrofit/src/test/java/retrofit/http/RequestBuilderTest.java b/retrofit/src/test/java/retrofit/RequestBuilderTest.java
similarity index 96%
rename from retrofit/src/test/java/retrofit/http/RequestBuilderTest.java
rename to retrofit/src/test/java/retrofit/RequestBuilderTest.java
index 987f92b3..d74739d5 100644
--- a/retrofit/src/test/java/retrofit/http/RequestBuilderTest.java
+++ b/retrofit/src/test/java/retrofit/RequestBuilderTest.java
@@ -1,5 +1,5 @@
 // Copyright 2013 Square, Inc.
-package retrofit.http;
+package retrofit;
 
 import com.google.gson.Gson;
 import java.io.ByteArrayOutputStream;
@@ -10,16 +10,20 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import org.junit.Test;
-import retrofit.http.client.Header;
-import retrofit.http.client.Request;
-import retrofit.http.mime.MimeHelper;
-import retrofit.http.mime.MultipartTypedOutput;
-import retrofit.http.mime.TypedOutput;
-import retrofit.http.mime.TypedString;
+import retrofit.converter.Converter;
+import retrofit.converter.GsonConverter;
+import retrofit.RequestBuilder;
+import retrofit.RestMethodInfo;
+import retrofit.client.Header;
+import retrofit.client.Request;
+import retrofit.mime.MimeHelper;
+import retrofit.mime.MultipartTypedOutput;
+import retrofit.mime.TypedOutput;
+import retrofit.mime.TypedString;
 
 import static org.fest.assertions.api.Assertions.assertThat;
-import static retrofit.http.RestMethodInfo.NO_BODY;
-import static retrofit.http.RestMethodInfo.RequestType;
+import static retrofit.RestMethodInfo.NO_BODY;
+import static retrofit.RestMethodInfo.RequestType;
 
 public class RequestBuilderTest {
   @Test public void normalGet() throws Exception {
diff --git a/retrofit/src/test/java/retrofit/http/RestAdapterTest.java b/retrofit/src/test/java/retrofit/RestAdapterTest.java
similarity index 94%
rename from retrofit/src/test/java/retrofit/http/RestAdapterTest.java
rename to retrofit/src/test/java/retrofit/RestAdapterTest.java
index 725296ad..282fff5e 100644
--- a/retrofit/src/test/java/retrofit/http/RestAdapterTest.java
+++ b/retrofit/src/test/java/retrofit/RestAdapterTest.java
@@ -1,5 +1,5 @@
 // Copyright 2013 Square, Inc.
-package retrofit.http;
+package retrofit;
 
 import java.io.IOException;
 import java.util.Collections;
@@ -7,11 +7,13 @@ import java.util.List;
 import java.util.concurrent.Executor;
 import org.junit.Before;
 import org.junit.Test;
-import retrofit.http.client.Client;
-import retrofit.http.client.Header;
-import retrofit.http.client.Request;
-import retrofit.http.client.Response;
-import retrofit.http.mime.TypedString;
+import retrofit.converter.ConversionException;
+import retrofit.http.GET;
+import retrofit.client.Client;
+import retrofit.client.Header;
+import retrofit.client.Request;
+import retrofit.client.Response;
+import retrofit.mime.TypedString;
 
 import static org.fest.assertions.api.Assertions.assertThat;
 import static org.fest.assertions.api.Assertions.fail;
@@ -25,8 +27,8 @@ import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
-import static retrofit.http.Profiler.RequestInformation;
-import static retrofit.http.Utils.SynchronousExecutor;
+import static retrofit.Profiler.RequestInformation;
+import static retrofit.Utils.SynchronousExecutor;
 
 public class RestAdapterTest {
   private static List
NO_HEADERS = Collections.emptyList(); diff --git a/retrofit/src/test/java/retrofit/http/RestMethodInfoTest.java b/retrofit/src/test/java/retrofit/RestMethodInfoTest.java similarity index 96% rename from retrofit/src/test/java/retrofit/http/RestMethodInfoTest.java rename to retrofit/src/test/java/retrofit/RestMethodInfoTest.java index 9c48b046..574040c1 100644 --- a/retrofit/src/test/java/retrofit/http/RestMethodInfoTest.java +++ b/retrofit/src/test/java/retrofit/RestMethodInfoTest.java @@ -1,5 +1,5 @@ // Copyright 2013 Square, Inc. -package retrofit.http; +package retrofit; import com.google.gson.reflect.TypeToken; import java.lang.annotation.Retention; @@ -11,14 +11,29 @@ import java.util.List; import java.util.Map; import java.util.Set; import org.junit.Test; -import retrofit.http.mime.TypedOutput; +import retrofit.http.Body; +import retrofit.http.DELETE; +import retrofit.http.Field; +import retrofit.http.FormUrlEncoded; +import retrofit.http.GET; +import retrofit.http.HEAD; +import retrofit.http.Header; +import retrofit.http.Headers; +import retrofit.http.Multipart; +import retrofit.http.POST; +import retrofit.http.PUT; +import retrofit.http.Part; +import retrofit.http.Path; +import retrofit.http.Query; +import retrofit.http.RestMethod; +import retrofit.mime.TypedOutput; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; import static org.fest.assertions.api.Assertions.assertThat; -import static retrofit.http.RestMethodInfo.NO_BODY; -import static retrofit.http.RestMethodInfo.RequestType.MULTIPART; -import static retrofit.http.RestMethodInfo.RequestType.SIMPLE; +import static retrofit.RestMethodInfo.NO_BODY; +import static retrofit.RestMethodInfo.RequestType.MULTIPART; +import static retrofit.RestMethodInfo.RequestType.SIMPLE; public class RestMethodInfoTest { @Test public void pathParameterParsing() throws Exception { @@ -678,8 +693,8 @@ public class RestMethodInfoTest { methodInfo.init(); assertThat(methodInfo.headers).isEqualTo( - Arrays.asList(new retrofit.http.client.Header("X-Foo", "Bar"), - new retrofit.http.client.Header("X-Ping", "Pong"))); + Arrays.asList(new retrofit.client.Header("X-Foo", "Bar"), + new retrofit.client.Header("X-Ping", "Pong"))); } @Test public void twoHeaderParams() { diff --git a/retrofit/src/test/java/retrofit/http/TestingUtils.java b/retrofit/src/test/java/retrofit/TestingUtils.java similarity index 90% rename from retrofit/src/test/java/retrofit/http/TestingUtils.java rename to retrofit/src/test/java/retrofit/TestingUtils.java index 08b3a88a..709b1bcb 100644 --- a/retrofit/src/test/java/retrofit/http/TestingUtils.java +++ b/retrofit/src/test/java/retrofit/TestingUtils.java @@ -1,10 +1,10 @@ // Copyright 2013 Square, Inc. -package retrofit.http; +package retrofit; import java.lang.reflect.Method; import java.util.Map; -import retrofit.http.mime.MultipartTypedOutput; -import retrofit.http.mime.TypedOutput; +import retrofit.mime.MultipartTypedOutput; +import retrofit.mime.TypedOutput; import static org.fest.assertions.api.Assertions.assertThat; diff --git a/retrofit/src/test/java/retrofit/http/client/ApacheClientTest.java b/retrofit/src/test/java/retrofit/client/ApacheClientTest.java similarity index 94% rename from retrofit/src/test/java/retrofit/http/client/ApacheClientTest.java rename to retrofit/src/test/java/retrofit/client/ApacheClientTest.java index cc65b7e4..82e51fb9 100644 --- a/retrofit/src/test/java/retrofit/http/client/ApacheClientTest.java +++ b/retrofit/src/test/java/retrofit/client/ApacheClientTest.java @@ -1,5 +1,5 @@ // Copyright 2013 Square, Inc. -package retrofit.http.client; +package retrofit.client; import com.google.common.io.ByteStreams; import java.util.ArrayList; @@ -15,14 +15,14 @@ import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.message.BasicHttpResponse; import org.apache.http.message.BasicStatusLine; import org.junit.Test; -import retrofit.http.TestingUtils; -import retrofit.http.mime.TypedOutput; -import retrofit.http.mime.TypedString; +import retrofit.TestingUtils; +import retrofit.mime.TypedOutput; +import retrofit.mime.TypedString; import static org.fest.assertions.api.Assertions.assertThat; -import static retrofit.http.TestingUtils.assertBytes; -import static retrofit.http.TestingUtils.assertMultipart; -import static retrofit.http.client.ApacheClient.TypedOutputEntity; +import static retrofit.TestingUtils.assertBytes; +import static retrofit.TestingUtils.assertMultipart; +import static retrofit.client.ApacheClient.TypedOutputEntity; public class ApacheClientTest { private static final String HOST = "http://example.com"; diff --git a/retrofit/src/test/java/retrofit/http/client/DummyHttpUrlConnection.java b/retrofit/src/test/java/retrofit/client/DummyHttpUrlConnection.java similarity index 96% rename from retrofit/src/test/java/retrofit/http/client/DummyHttpUrlConnection.java rename to retrofit/src/test/java/retrofit/client/DummyHttpUrlConnection.java index f2f94e26..926e4b04 100644 --- a/retrofit/src/test/java/retrofit/http/client/DummyHttpUrlConnection.java +++ b/retrofit/src/test/java/retrofit/client/DummyHttpUrlConnection.java @@ -1,5 +1,5 @@ // Copyright 2013 Square, Inc. -package retrofit.http.client; +package retrofit.client; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -13,7 +13,7 @@ import java.util.List; import java.util.Map; /** - * Provides POJO behavior for all of the APIs {@link retrofit.http.client.UrlConnectionClient} + * Provides POJO behavior for all of the APIs {@link retrofit.client.UrlConnectionClient} * interacts with. */ public class DummyHttpUrlConnection extends HttpURLConnection { diff --git a/retrofit/src/test/java/retrofit/http/client/UrlConnectionClientTest.java b/retrofit/src/test/java/retrofit/client/UrlConnectionClientTest.java similarity index 97% rename from retrofit/src/test/java/retrofit/http/client/UrlConnectionClientTest.java rename to retrofit/src/test/java/retrofit/client/UrlConnectionClientTest.java index bd00d7f5..68fef779 100644 --- a/retrofit/src/test/java/retrofit/http/client/UrlConnectionClientTest.java +++ b/retrofit/src/test/java/retrofit/client/UrlConnectionClientTest.java @@ -1,5 +1,5 @@ // Copyright 2013 Square, Inc. -package retrofit.http.client; +package retrofit.client; import com.google.common.io.ByteStreams; import java.io.ByteArrayInputStream; @@ -10,12 +10,12 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.junit.Test; -import retrofit.http.TestingUtils; -import retrofit.http.mime.TypedOutput; -import retrofit.http.mime.TypedString; +import retrofit.TestingUtils; +import retrofit.mime.TypedOutput; +import retrofit.mime.TypedString; import static org.fest.assertions.api.Assertions.assertThat; -import static retrofit.http.TestingUtils.assertBytes; +import static retrofit.TestingUtils.assertBytes; public class UrlConnectionClientTest { private static final String HOST = "http://example.com"; diff --git a/retrofit/src/test/java/retrofit/http/mime/FormUrlEncodingTypedOutputTest.java b/retrofit/src/test/java/retrofit/mime/FormUrlEncodingTypedOutputTest.java similarity index 98% rename from retrofit/src/test/java/retrofit/http/mime/FormUrlEncodingTypedOutputTest.java rename to retrofit/src/test/java/retrofit/mime/FormUrlEncodingTypedOutputTest.java index 4d83794c..0683af8a 100644 --- a/retrofit/src/test/java/retrofit/http/mime/FormUrlEncodingTypedOutputTest.java +++ b/retrofit/src/test/java/retrofit/mime/FormUrlEncodingTypedOutputTest.java @@ -1,5 +1,5 @@ // Copyright 2013 Square, Inc. -package retrofit.http.mime; +package retrofit.mime; import java.io.ByteArrayOutputStream; import org.junit.Test; diff --git a/retrofit/src/test/java/retrofit/http/mime/MimeHelper.java b/retrofit/src/test/java/retrofit/mime/MimeHelper.java similarity index 86% rename from retrofit/src/test/java/retrofit/http/mime/MimeHelper.java rename to retrofit/src/test/java/retrofit/mime/MimeHelper.java index 5840f1c0..6b75aff5 100644 --- a/retrofit/src/test/java/retrofit/http/mime/MimeHelper.java +++ b/retrofit/src/test/java/retrofit/mime/MimeHelper.java @@ -1,5 +1,5 @@ // Copyright 2013 Square, Inc. -package retrofit.http.mime; +package retrofit.mime; import java.util.List; diff --git a/retrofit/src/test/java/retrofit/http/UtilsTest.java b/retrofit/src/test/java/retrofit/mime/MimeUtilTest.java similarity index 92% rename from retrofit/src/test/java/retrofit/http/UtilsTest.java rename to retrofit/src/test/java/retrofit/mime/MimeUtilTest.java index 5176f023..03bce7fc 100644 --- a/retrofit/src/test/java/retrofit/http/UtilsTest.java +++ b/retrofit/src/test/java/retrofit/mime/MimeUtilTest.java @@ -1,12 +1,12 @@ // Copyright 2012 Square, Inc. -package retrofit.http; +package retrofit.mime; import org.junit.Test; import static org.fest.assertions.api.Assertions.assertThat; -import static retrofit.http.Utils.parseCharset; +import static retrofit.mime.MimeUtil.parseCharset; -public class UtilsTest { +public class MimeUtilTest { @Test public void charsetParsing() { assertThat(parseCharset("text/plain;charset=utf-8")).isEqualToIgnoringCase("UTF-8"); assertThat(parseCharset("text/plain; charset=utf-8")).isEqualToIgnoringCase("UTF-8"); diff --git a/retrofit/src/test/java/retrofit/http/mime/MultipartTypedOutputTest.java b/retrofit/src/test/java/retrofit/mime/MultipartTypedOutputTest.java similarity index 98% rename from retrofit/src/test/java/retrofit/http/mime/MultipartTypedOutputTest.java rename to retrofit/src/test/java/retrofit/mime/MultipartTypedOutputTest.java index 67b03a6b..11820ec4 100644 --- a/retrofit/src/test/java/retrofit/http/mime/MultipartTypedOutputTest.java +++ b/retrofit/src/test/java/retrofit/mime/MultipartTypedOutputTest.java @@ -1,5 +1,5 @@ // Copyright 2013 Square, Inc. -package retrofit.http.mime; +package retrofit.mime; import java.io.ByteArrayOutputStream; import org.junit.Test; diff --git a/retrofit/src/test/java/retrofit/http/mime/TypedByteArrayTest.java b/retrofit/src/test/java/retrofit/mime/TypedByteArrayTest.java similarity index 95% rename from retrofit/src/test/java/retrofit/http/mime/TypedByteArrayTest.java rename to retrofit/src/test/java/retrofit/mime/TypedByteArrayTest.java index ab095261..c6145e6b 100644 --- a/retrofit/src/test/java/retrofit/http/mime/TypedByteArrayTest.java +++ b/retrofit/src/test/java/retrofit/mime/TypedByteArrayTest.java @@ -1,5 +1,5 @@ // Copyright 2010 Square, Inc. -package retrofit.http.mime; +package retrofit.mime; import org.junit.Test; diff --git a/retrofit/src/test/java/retrofit/http/mime/TypedFileTest.java b/retrofit/src/test/java/retrofit/mime/TypedFileTest.java similarity index 98% rename from retrofit/src/test/java/retrofit/http/mime/TypedFileTest.java rename to retrofit/src/test/java/retrofit/mime/TypedFileTest.java index cf0d9f66..d9d11431 100644 --- a/retrofit/src/test/java/retrofit/http/mime/TypedFileTest.java +++ b/retrofit/src/test/java/retrofit/mime/TypedFileTest.java @@ -1,5 +1,5 @@ // Copyright 2010 Square, Inc. -package retrofit.http.mime; +package retrofit.mime; import java.io.File; import java.io.FileOutputStream; diff --git a/samples/github-client/src/main/java/com/squareup/retrofit/sample/github/Client.java b/samples/github-client/src/main/java/com/example/retrofit/GitHubClient.java similarity index 94% rename from samples/github-client/src/main/java/com/squareup/retrofit/sample/github/Client.java rename to samples/github-client/src/main/java/com/example/retrofit/GitHubClient.java index 56b15575..7a5cf2e7 100644 --- a/samples/github-client/src/main/java/com/squareup/retrofit/sample/github/Client.java +++ b/samples/github-client/src/main/java/com/example/retrofit/GitHubClient.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.squareup.retrofit.sample.github; +package com.example.retrofit; import java.util.List; import retrofit.http.GET; import retrofit.http.Path; -import retrofit.http.RestAdapter; +import retrofit.RestAdapter; -public class Client { +public class GitHubClient { private static final String API_URL = "https://api.github.com"; class Contributor { -- GitLab