Example usage for java.lang CharSequence equals

List of usage examples for java.lang CharSequence equals

Introduction

In this page you can find the example usage for java.lang CharSequence equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

public void updateTitle(CharSequence cs) {
    TextView title = (TextView) findViewById(R.id.title_path);
    if ((title == null || !title.isShown()) && !BEFORE_HONEYCOMB && getActionBar() != null
            && getActionBar().getCustomView() != null)
        title = (TextView) getActionBar().getCustomView().findViewById(R.id.title_path);
    //if(BEFORE_HONEYCOMB || !USE_ACTION_BAR || getActionBar() == null)
    if (title != null && title.getVisibility() != View.GONE)
        title.setText(cs, BufferType.SPANNABLE);
    if (!BEFORE_HONEYCOMB && USE_ACTION_BAR && getActionBar() != null && (title == null || !title.isShown()))
        getActionBar().setSubtitle(cs);/* w w  w  . j  a  v  a  2s  .c o  m*/
    //else
    {
        SpannableStringBuilder sb = new SpannableStringBuilder(getResources().getString(R.string.app_title));
        sb.append(cs.equals("") ? "" : " - ");
        sb.append(cs);
        setTitle(cs);
    }
}

From source file:org.apache.commons.lang3.StringUtils.java

/**
 * <p>Compares two CharSequences, returning {@code true} if they are equal.</p>
 *
 * <p>{@code null}s are handled without exceptions. Two {@code null}
 * references are considered to be equal. The comparison is case sensitive.</p>
 *
 * <pre>// w  ww  .  j  av  a 2s . c  o  m
 * StringUtils.equals(null, null)   = true
 * StringUtils.equals(null, "abc")  = false
 * StringUtils.equals("abc", null)  = false
 * StringUtils.equals("abc", "abc") = true
 * StringUtils.equals("abc", "ABC") = false
 * </pre>
 *
 * @see java.lang.String#equals(Object)
 * @param cs1  the first CharSequence, may be null
 * @param cs2  the second CharSequence, may be null
 * @return {@code true} if the CharSequences are equal, case sensitive, or
 *  both {@code null}
 * @since 3.0 Changed signature from equals(String, String) to equals(CharSequence, CharSequence)
 */
public static boolean equals(CharSequence cs1, CharSequence cs2) {
    return cs1 == null ? cs2 == null : cs1.equals(cs2);
}

From source file:com.rdm.common.util.StringUtils.java

/**
 * <p>Compares two CharSequences, returning {@code true} if they represent
 * equal sequences of characters.</p>
 *
 * <p>{@code null}s are handled without exceptions. Two {@code null}
 * references are considered to be equal. The comparison is case sensitive.</p>
 *
 * <pre>//from   w w w  .  j  a v a2  s.  com
 * StringUtils.equals(null, null)   = true
 * StringUtils.equals(null, "abc")  = false
 * StringUtils.equals("abc", null)  = false
 * StringUtils.equals("abc", "abc") = true
 * StringUtils.equals("abc", "ABC") = false
 * </pre>
 *
 * @see Object#equals(Object)
 * @param cs1  the first CharSequence, may be {@code null}
 * @param cs2  the second CharSequence, may be {@code null}
 * @return {@code true} if the CharSequences are equal (case-sensitive), or both {@code null}
 * @since 3.0 Changed signature from equals(String, String) to equals(CharSequence, CharSequence)
 */
public static boolean equals(final CharSequence cs1, final CharSequence cs2) {
    if (cs1 == cs2) {
        return true;
    }
    if (cs1 == null || cs2 == null) {
        return false;
    }
    if (cs1 instanceof String && cs2 instanceof String) {
        return cs1.equals(cs2);
    }
    return CharSequenceUtils.regionMatches(cs1, false, 0, cs2, 0, Math.max(cs1.length(), cs2.length()));
}

From source file:bfile.util.StringUtils.java

/**
 * <p>Compares two CharSequences, returning {@code true} if they represent
 * equal sequences of characters.</p>
 *
 * <p>{@code null}s are handled without exceptions. Two {@code null}
 * references are considered to be equal. The comparison is case sensitive.</p>
 *
 * <pre>/*from www . ja  v  a2s  .  c o  m*/
 * StringUtils.equals(null, null)   = true
 * StringUtils.equals(null, "abc")  = false
 * StringUtils.equals("abc", null)  = false
 * StringUtils.equals("abc", "abc") = true
 * StringUtils.equals("abc", "ABC") = false
 * </pre>
 *
 * @see Object#equals(Object)
 * @param cs1  the first CharSequence, may be {@code null}
 * @param cs2  the second CharSequence, may be {@code null}
 * @return {@code true} if the CharSequences are equal (case-sensitive), or both {@code null}
 * @since 3.0 Changed signature from equals(String, String) to equals(CharSequence, CharSequence)
 */
public static boolean equals(final CharSequence cs1, final CharSequence cs2) {
    if (cs1 == cs2) {
        return true;
    }
    if (cs1 == null || cs2 == null) {
        return false;
    }
    if (cs1.length() != cs2.length()) {
        return false;
    }
    if (cs1 instanceof String && cs2 instanceof String) {
        return cs1.equals(cs2);
    }
    return CharSequenceUtils.regionMatches(cs1, false, 0, cs2, 0, cs1.length());
}