Example usage for org.apache.http.util TextUtils isEmpty

List of usage examples for org.apache.http.util TextUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.http.util TextUtils isEmpty.

Prototype

public static boolean isEmpty(CharSequence charSequence) 

Source Link

Usage

From source file:heybot.heybot.java

private static Operation getOperation(Properties prop) {
    String opValue = prop.getProperty("OPERATION");
    if (TextUtils.isEmpty(opValue)) {
        System.err.println("Ooops! Parameter OPERATION not found in .hb file.");
    } else {/*from ww w  .j  a  va2 s. c o  m*/
        opValue = opValue.toLowerCase(new Locale("tr-TR"));
        switch (opValue) {
        case "upload":
            return new Upload();
        case "cleanup":
            return new Cleanup();
        case "review":
            return new Review();
        case "check-new":
            return new CheckNew();
        case "cleanup-svn":
            return new CleanupSvn();
        case "sync-issue":
            return new SyncIssue();
        case "next-version":
            return new NextVersion();
        case "release":
            return new Release();
        case "begin-issue":
            return new BeginIssue();
        case "snapshot":
            return new Snapshot();
        default:
            System.err.println("Ooops! Unsupported operation. Please check version and manual.");
        }
    }

    return null;
}

From source file:netcap.JcaptureConfiguration.java

/**
 * ??/*from  w  w w  .  j  a  v a 2 s .  co m*/
 */
private void saveConfiguration() {
    try {
        int caplen = Integer.parseInt(caplenTextField.getText());
        if (caplen < 68 || caplen > 1514) {
            ViewModules.showMessageDialog(null, "? 68  1514");
            return;
        }
        NetworkInterface netInter = devices[netJComboBox.getSelectedIndex()];
        boolean isPromisc = checkBox.isSelected();
        jpcap = JpcapCaptor.openDevice(netInter, caplen, isPromisc, 50);
        if (!TextUtils.isEmpty(proFilterField.getText()))
            jpcap.setFilter(proFilterField.getText(), true);
        if (!TextUtils.isEmpty(domainFilterField.getText()))
            domain = domainFilterField.getText().trim();
    } catch (NumberFormatException e) {
        ViewModules.showMessageDialog(null, "?");
    } catch (java.io.IOException e) {
        ViewModules.showMessageDialog(null, e.toString());
        jpcap = null;
    } finally {
        dispose();
    }
}

From source file:com.wareninja.opensource.discourse.utils.MyWebClient.java

public void addRequestHeader(final String key, final String value) {

    if (DEBUG)/*from w w  w.ja va 2s. co m*/
        System.out.println(TAG + "|" + "addRequestHeader->" + "key:" + key + "|value:" + value);
    if (TextUtils.isEmpty(key) || TextUtils.isEmpty(value))
        return;

    this.requestHeaders.add(new PlainRequestHeader(key, value));
}

From source file:nya.miku.wishmaster.ui.settings.AutohideActivity.java

@SuppressLint("InflateParams")
@Override//from  w  ww .ja v  a  2s  . c  om
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    Object item = l.getItemAtPosition(position);
    final int changeId;
    if (item instanceof AutohideRule) {
        changeId = position - 1;
    } else {
        changeId = -1; //-1 - ?  
    }

    Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
            ? new ContextThemeWrapper(this, R.style.Neutron_Medium)
            : this;
    View dialogView = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_autohide_rule, null);
    final EditText regexEditText = (EditText) dialogView.findViewById(R.id.dialog_autohide_regex);
    final Spinner chanSpinner = (Spinner) dialogView.findViewById(R.id.dialog_autohide_chan_spinner);
    final EditText boardEditText = (EditText) dialogView.findViewById(R.id.dialog_autohide_boardname);
    final EditText threadEditText = (EditText) dialogView.findViewById(R.id.dialog_autohide_threadnum);
    final CheckBox inCommentCheckBox = (CheckBox) dialogView.findViewById(R.id.dialog_autohide_in_comment);
    final CheckBox inSubjectCheckBox = (CheckBox) dialogView.findViewById(R.id.dialog_autohide_in_subject);
    final CheckBox inNameCheckBox = (CheckBox) dialogView.findViewById(R.id.dialog_autohide_in_name);

    chanSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, chans));
    if (changeId != -1) {
        AutohideRule rule = (AutohideRule) item;
        regexEditText.setText(rule.regex);
        int chanPosition = chans.indexOf(rule.chanName);
        chanSpinner.setSelection(chanPosition != -1 ? chanPosition : 0);
        boardEditText.setText(rule.boardName);
        threadEditText.setText(rule.threadNumber);
        inCommentCheckBox.setChecked(rule.inComment);
        inSubjectCheckBox.setChecked(rule.inSubject);
        inNameCheckBox.setChecked(rule.inName);
    } else {
        chanSpinner.setSelection(0);
    }

    DialogInterface.OnClickListener save = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String regex = regexEditText.getText().toString();
            if (regex.length() == 0) {
                Toast.makeText(AutohideActivity.this, R.string.autohide_error_empty_regex, Toast.LENGTH_LONG)
                        .show();
                return;
            }

            try {
                Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.DOTALL);
            } catch (Exception e) {
                CharSequence message = null;
                if (e instanceof PatternSyntaxException) {
                    String eMessage = e.getMessage();
                    if (!TextUtils.isEmpty(eMessage)) {
                        SpannableStringBuilder a = new SpannableStringBuilder(
                                getString(R.string.autohide_error_incorrect_regex));
                        a.append('\n');
                        int startlen = a.length();
                        a.append(eMessage);
                        a.setSpan(new TypefaceSpan("monospace"), startlen, a.length(),
                                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                        message = a;
                    }
                }
                if (message == null)
                    message = getString(R.string.error_unknown);
                Toast.makeText(AutohideActivity.this, message, Toast.LENGTH_LONG).show();
                return;
            }

            AutohideRule rule = new AutohideRule();
            int spinnerSelectedPosition = chanSpinner.getSelectedItemPosition();
            rule.regex = regex;
            rule.chanName = spinnerSelectedPosition > 0 ? chans.get(spinnerSelectedPosition) : ""; // 0 ? = ? 
            rule.boardName = boardEditText.getText().toString();
            rule.threadNumber = threadEditText.getText().toString();
            rule.inComment = inCommentCheckBox.isChecked();
            rule.inSubject = inSubjectCheckBox.isChecked();
            rule.inName = inNameCheckBox.isChecked();

            if (!rule.inComment && !rule.inSubject && !rule.inName) {
                Toast.makeText(AutohideActivity.this, R.string.autohide_error_no_condition, Toast.LENGTH_LONG)
                        .show();
                return;
            }

            if (changeId == -1) {
                rulesJson.put(rule.toJson());
            } else {
                rulesJson.put(changeId, rule.toJson());
            }
            rulesChanged();
        }
    };
    AlertDialog dialog = new AlertDialog.Builder(this).setView(dialogView)
            .setTitle(changeId == -1 ? R.string.autohide_add_rule_title : R.string.autohide_edit_rule_title)
            .setPositiveButton(R.string.autohide_save_button, save)
            .setNegativeButton(android.R.string.cancel, null).create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}

From source file:weavebytes.com.futureerp.activities.LoginActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {

    case R.id.btnlogin:
        username = name.getText().toString();
        password = pass.getText().toString();
        if (TextUtils.isEmpty(username)) {
            name.setError("Enter Name");
        } else if (TextUtils.isEmpty(password)) {
            pass.setError("Enter Password");
        } else {/*from  ww w  . ja va 2s  . co m*/
            SendJsonRequest();
        }
        break;
    case R.id.btnregister:
        Intent it = new Intent(LoginActivity.this, RegistrationActivity.class);
        startActivity(it);
        break;

    }
}

From source file:com.amos.tool.SelfRedirectStrategy.java

/**
 * @since 4.1/*from w w w . ja va  2s  .  co  m*/
 */
protected URI createLocationURI(final String location) throws ProtocolException {

    System.out.println("redirect_location:" + location);

    try {
        final URIBuilder b = new URIBuilder(new URI(location).normalize());
        final String host = b.getHost();
        if (host != null) {
            b.setHost(host.toLowerCase(Locale.ENGLISH));
        }
        final String path = b.getPath();
        if (TextUtils.isEmpty(path)) {
            b.setPath("/");
        }
        return b.build();
    } catch (final URISyntaxException ex) {
        throw new ProtocolException("Invalid redirect URI: " + location, ex);
    }
}

From source file:de.mprengemann.intellij.plugin.androidicons.settings.PluginSettings.java

@Override
public boolean isModified() {
    boolean isModified = false;

    if (selectionPerformed) {
        if (persistedAndroidIconsFile == null
                || !persistedAndroidIconsFile.equalsIgnoreCase(selectedAndroidIconsFile.getUrl())) {
            isModified = true;/* ww w . j ava2  s  .  c  o  m*/
        }
        if (persistedMaterialIconsFile == null
                || !persistedMaterialIconsFile.equalsIgnoreCase(selectedMaterialIconsFile.getUrl())) {
            isModified = true;
        }
    } else if (!TextUtils.isEmpty(persistedAndroidIconsFile) && selectedAndroidIconsFile == null) {
        isModified = true;
    } else if (!TextUtils.isEmpty(persistedMaterialIconsFile) && selectedMaterialIconsFile == null) {
        isModified = true;
    }

    return isModified;
}

From source file:com.portol.common.utils.Util.java

/**
 * Parses an xs:duration attribute value, returning the parsed duration in milliseconds.
 *
 * @param value The attribute value to parse.
 * @return The parsed duration in milliseconds.
 *///from w  ww . ja va2  s.  c o m
public static long parseXsDuration(String value) {
    Matcher matcher = XS_DURATION_PATTERN.matcher(value);
    if (matcher.matches()) {
        boolean negated = !TextUtils.isEmpty(matcher.group(1));
        // Durations containing years and months aren't completely defined. We assume there are
        // 30.4368 days in a month, and 365.242 days in a year.
        String years = matcher.group(3);
        double durationSeconds = (years != null) ? Double.parseDouble(years) * 31556908 : 0;
        String months = matcher.group(5);
        durationSeconds += (months != null) ? Double.parseDouble(months) * 2629739 : 0;
        String days = matcher.group(7);
        durationSeconds += (days != null) ? Double.parseDouble(days) * 86400 : 0;
        String hours = matcher.group(10);
        durationSeconds += (hours != null) ? Double.parseDouble(hours) * 3600 : 0;
        String minutes = matcher.group(12);
        durationSeconds += (minutes != null) ? Double.parseDouble(minutes) * 60 : 0;
        String seconds = matcher.group(14);
        durationSeconds += (seconds != null) ? Double.parseDouble(seconds) : 0;
        long durationMillis = (long) (durationSeconds * 1000);
        return negated ? -durationMillis : durationMillis;
    } else {
        return (long) (Double.parseDouble(value) * 3600 * 1000);
    }
}

From source file:com.portol.common.utils.Util.java

/**
 * Parses an xs:dateTime attribute value, returning the parsed timestamp in milliseconds since
 * the epoch.//from  w  ww .  j  av a 2 s.co  m
 *
 * @param value The attribute value to parse.
 * @return The parsed timestamp in milliseconds since the epoch.
 */
public static long parseXsDateTime(String value) throws ParseException {
    Matcher matcher = XS_DATE_TIME_PATTERN.matcher(value);
    if (!matcher.matches()) {
        throw new ParseException("Invalid date/time format: " + value, 0);
    }

    int timezoneShift;
    if (matcher.group(9) == null) {
        // No time zone specified.
        timezoneShift = 0;
    } else if (matcher.group(9).equalsIgnoreCase("Z")) {
        timezoneShift = 0;
    } else {
        timezoneShift = ((Integer.parseInt(matcher.group(12)) * 60 + Integer.parseInt(matcher.group(13))));
        if (matcher.group(11).equals("-")) {
            timezoneShift *= -1;
        }
    }

    Calendar dateTime = new GregorianCalendar(TimeZone.getTimeZone("GMT"));

    dateTime.clear();
    // Note: The month value is 0-based, hence the -1 on group(2)
    dateTime.set(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)) - 1,
            Integer.parseInt(matcher.group(3)), Integer.parseInt(matcher.group(4)),
            Integer.parseInt(matcher.group(5)), Integer.parseInt(matcher.group(6)));
    if (!TextUtils.isEmpty(matcher.group(8))) {
        final BigDecimal bd = new BigDecimal("0." + matcher.group(8));
        // we care only for milliseconds, so movePointRight(3)
        dateTime.set(Calendar.MILLISECOND, bd.movePointRight(3).intValue());
    }

    long time = dateTime.getTimeInMillis();
    if (timezoneShift != 0) {
        time -= timezoneShift * 60000;
    }

    return time;
}

From source file:heybot.heybot.java

private static void openOperation(String operation) {
    String editor = System.getenv("HEYBOT_EDITOR");
    String hbFile = getFileName(operation);

    if (TextUtils.isEmpty(editor)) {
        System.err.println("Ooops! Could not use external editor to open *" + hbFile
                + "* operation; consider setting the HEYBOT_EDITOR environment variable!");
    } else {//www.j a v  a 2  s.  co m
        String hbFilePath = getWorkspacePath() + "/" + hbFile;
        if (new File(hbFilePath).exists()) {
            Command editorCmd = new Command(new String[] { "which", editor });
            if (editorCmd.execute() && !TextUtils.isEmpty(editorCmd.toString())) {
                System.out.println("[*] Opening " + hbFile + " with editor ");
                System.out.println(editorCmd.toString());
                new Command(new String[] { editor, hbFilePath }).executeNoWait();
            } else {
                System.err.println("Ooops! Could not find editor *" + editor + "* in global path!");
            }
        } else {
            System.err.println("Ooops! Could not find *" + hbFile + "* in workspace!");
        }
    }
}