com.backendless.BLHeadersManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of backendless Show documentation
Show all versions of backendless Show documentation
Android SDK used by developers to provide Backendless API in apps.
package com.backendless;
import com.backendless.exceptions.BackendlessException;
import java.util.Hashtable;
import java.util.Map;
class BLHeadersManager implements IHeadersManager
{
private static BLHeadersManager instance = new BLHeadersManager();
static BLHeadersManager getInstance()
{
return instance;
}
private static ThreadLocal threadLocal = new InheritableThreadLocal()
{
@Override
protected AndroidHeadersManager initialValue()
{
return new AndroidHeadersManager();
}
};
BLHeadersManager()
{
}
public void cleanHeaders()
{
threadLocal.remove();
}
@Override
public void addHeader( HeadersManager.HeadersEnum headersEnum, String value )
{
threadLocal.get().addHeader( headersEnum, value );
}
@Override
public void addHeaders( Map headers )
{
threadLocal.get().addHeaders( headers );
}
@Override
public void removeHeader( HeadersManager.HeadersEnum headersEnum )
{
threadLocal.get().removeHeader( headersEnum );
}
@Override
public Hashtable getHeaders() throws BackendlessException
{
return threadLocal.get().getHeaders();
}
@Override
public void setHeaders( Map headers )
{
threadLocal.get().setHeaders( headers );
}
@Override
public String getHeader( HeadersManager.HeadersEnum headersEnum ) throws BackendlessException
{
return threadLocal.get().getHeader( headersEnum );
}
}