<commit_before>package cgeo.geocaching.connector.trackable;

import cgeo.geocaching.R;
import cgeo.geocaching.activity.TokenAuthorizationActivity;
import cgeo.geocaching.network.Network;
import cgeo.geocaching.settings.Settings;

import ch.boye.httpclientandroidlib.HttpResponse;

import android.os.Bundle;

import java.util.regex.Pattern;

public class GeokretyAuthorizationActivity extends TokenAuthorizationActivity {

    private static final Pattern PATTERN_IS_ERROR = Pattern.compile("error ([\\d]+)");
    private static final Pattern PATTERN_TOKEN = Pattern.compile("([\\w]+)");

    public static final TokenAuthParameters GEOKRETY_TOKEN_AUTH_PARAMS = new TokenAuthParameters(
            "http://geokrety.org/api-login2secid.php",
            "http://geokrety.org/adduser.php",
            "login",
            "password");

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void setToken(final String token) {
        Settings.setGeokretySecId(token);
    }

    @Override
    protected String getToken() {
        return Settings.getGeokretySecId();
    }

    @Override
    protected String getAuthTitle() {
        return res.getString(R.string.init_geokrety);
    }

    @Override
    protected Pattern getPatternIsError() {
        return PATTERN_IS_ERROR;
    }

    @Override
    protected Pattern getPatternToken() {
        return PATTERN_TOKEN;
    }

    @Override
    protected String getAuthDialogCompleted() {
        return res.getString(R.string.auth_dialog_completed_geokrety, getAuthTitle());
    }

    @Override
    protected String getExtendedErrorMsg(final HttpResponse response) {
        final String line = Network.getResponseData(response);
        return getExtendedErrorMsg(line);
    }

    @Override
    protected String getExtendedErrorMsg(final String response) {
        if (response.equals("1")) {
            return res.getString(R.string.err_auth_geokrety_bad_password);
        }

        return res.getString(R.string.err_auth_geokrety_unknown, getAuthTitle(), response);
    }

}<commit_msg>findbugs: potential null dereference<commit_after>package cgeo.geocaching.connector.trackable;

import cgeo.geocaching.R;
import cgeo.geocaching.activity.TokenAuthorizationActivity;
import cgeo.geocaching.network.Network;
import cgeo.geocaching.settings.Settings;

import ch.boye.httpclientandroidlib.HttpResponse;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.Nullable;

import android.os.Bundle;

import java.util.regex.Pattern;

public class GeokretyAuthorizationActivity extends TokenAuthorizationActivity {

    private static final Pattern PATTERN_IS_ERROR = Pattern.compile("error ([\\d]+)");
    private static final Pattern PATTERN_TOKEN = Pattern.compile("([\\w]+)");

    public static final TokenAuthParameters GEOKRETY_TOKEN_AUTH_PARAMS = new TokenAuthParameters(
            "http://geokrety.org/api-login2secid.php",
            "http://geokrety.org/adduser.php",
            "login",
            "password");

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void setToken(final String token) {
        Settings.setGeokretySecId(token);
    }

    @Override
    protected String getToken() {
        return Settings.getGeokretySecId();
    }

    @Override
    protected String getAuthTitle() {
        return res.getString(R.string.init_geokrety);
    }

    @Override
    protected Pattern getPatternIsError() {
        return PATTERN_IS_ERROR;
    }

    @Override
    protected Pattern getPatternToken() {
        return PATTERN_TOKEN;
    }

    @Override
    protected String getAuthDialogCompleted() {
        return res.getString(R.string.auth_dialog_completed_geokrety, getAuthTitle());
    }

    @Override
    protected String getExtendedErrorMsg(final HttpResponse response) {
        final String line = Network.getResponseData(response);
        return getExtendedErrorMsg(line);
    }

    @Override
    protected String getExtendedErrorMsg(final @Nullable String response) {
        if (StringUtils.equals(response, "1")) {
            return res.getString(R.string.err_auth_geokrety_bad_password);
        }

        return res.getString(R.string.err_auth_geokrety_unknown, getAuthTitle(), response);
    }

}
{'fraction_non_alphanumeric': 0.09245027124773961, 'fraction_numerical': 0.0011301989150090416, 'mean_word_length': 3.4205794205794207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5110213', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1245, 'n_words': 241}