All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dg.libs.rest.requests.StringBodyHttpRequestImpl Maven / Gradle / Ivy

There is a newer version: 2.9.0
Show newest version
package com.dg.libs.rest.requests;

import java.io.UnsupportedEncodingException;

import org.apache.http.HttpEntity;
import org.apache.http.entity.StringEntity;

import android.content.Context;

import com.araneaapps.android.libs.logger.ALog;
import com.dg.libs.rest.callbacks.HttpCallback;
import com.dg.libs.rest.client.BaseRestClient.RequestMethod;
import com.dg.libs.rest.parsers.HttpResponseParser;

public abstract class StringBodyHttpRequestImpl extends EntityHttpRequestImpl {

  public static final String TAG = StringBodyHttpRequestImpl.class.getSimpleName();

  public StringBodyHttpRequestImpl(final Context context, RequestMethod requestMethod,
      final HttpResponseParser parser, final HttpCallback callback) {
    super(context, requestMethod, parser, callback);
  }

  public abstract String bodyContents();

  @Override
  public HttpEntity getEntity() {
    try {
      return new StringEntity(bodyContents(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
      ALog.e(e);
    }
    return null;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy