Example usage for org.apache.commons.lang ObjectUtils toString

List of usage examples for org.apache.commons.lang ObjectUtils toString

Introduction

In this page you can find the example usage for org.apache.commons.lang ObjectUtils toString.

Prototype

public static String toString(Object obj) 

Source Link

Document

Gets the toString of an Object returning an empty string ("") if null input.

 ObjectUtils.toString(null)         = "" ObjectUtils.toString("")           = "" ObjectUtils.toString("bat")        = "bat" ObjectUtils.toString(Boolean.TRUE) = "true" 

Usage

From source file:org.medici.bia.common.search.AdvancedSearchVolume.java

public String toString() {
    StringBuilder toString = new StringBuilder();

    appendToStringBuilder(toString, words, "Words: ");
    appendToStringBuilder(toString, datesYear, "Date Year: ");
    appendToStringBuilder(toString, datesMonth, "Date Month: ");
    appendToStringBuilder(toString, datesDay, "Date Day: ");
    appendToStringBuilder(toString, datesYearBetween, "Between Date Year: ");
    appendToStringBuilder(toString, datesMonthBetween, "Between Date Month: ");
    appendToStringBuilder(toString, datesDayBetween, "Between Date Day: ");
    appendToStringBuilder(toString, volumes, "Volumes: ");
    if (!volumesBetween.isEmpty() && !(volumesBetween.size() == 1 && volumesBetween.get(0).equals("0"))) {
        appendToStringBuilder(toString, volumesBetween, "Volumes: ");
    }/*from  w  w  w .  j a v a  2s  .c o  m*/
    appendToStringBuilder(toString, insertNums, "Inserts: ");
    if (!ObjectUtils.toString(digitized).equals("")) {
        if (toString.length() > 0) {
            toString.append("AND ");
        }
        toString.append("Digitized: ").append(digitized).append(" ");
    }
    appendToStringBuilder(toString, languages, "Languages: ");
    if (!cipher.isEmpty()) {
        if (toString.length() > 0) {
            toString.append("AND ");
        }
        toString.append("Cypher: ").append(cipher).append(" ");
    }
    if (!index.isEmpty()) {
        if (toString.length() > 0) {
            toString.append("AND ");
        }
        toString.append("Index: ").append(index).append(" ");
    }
    appendToStringBuilder(toString, fromVolume, "From Volume: ");
    appendToStringBuilder(toString, toVolume, "To Volume: ");
    appendToStringBuilder(toString, context, "Context: ");
    appendToStringBuilder(toString, inventario, "Inventario: ");
    appendToStringBuilder(toString, volumesId, "Volume ID: ");

    return toString.toString();
}

From source file:org.medici.bia.common.search.AdvancedSearchVolume.java

@Override
public Boolean empty() {
    if ((volumes.size() > 0) || (datesTypes.size() > 0) || (datesLastUpdateTypes.size() > 0)
            || (!ObjectUtils.toString(digitized).equals("")) || (languages.size() > 0) || (otherLang.size() > 0)
            || (cipher.length() > 0) || (index.length() > 0) || (fromVolume.size() > 0) || (toVolume.size() > 0)
            || (context.size() > 0) || (inventario.size() > 0) || (volumesId.size() > 0)) {
        return Boolean.FALSE;
    }//ww  w  .  j  a va  2s.c  o  m
    return Boolean.TRUE;
}

From source file:org.medici.bia.common.search.SimpleSearchTitleOrOccupation.java

/**
 * {@inheritDoc}//from  w  ww  . j  a v  a 2  s  .c  o  m
 */
@Override
public Boolean empty() {
    if (StringUtils.isEmpty(textSearch) || (!ObjectUtils.toString(roleCatId).equals(""))) {
        return Boolean.TRUE;
    }

    return Boolean.FALSE;
}

From source file:org.medici.bia.common.util.DateUtils.java

/**
 * /*from w ww .j  a  va2 s . c o  m*/
 * @param year
 * @param month
 * @param day
 * @return
 */
public static Integer getIntegerDate(Integer year, Integer month, Integer day) {
    StringBuilder stringBuilder = new StringBuilder("");

    if (year != null) {
        stringBuilder.append(year);
    } else {
        stringBuilder.append("0000");
    }

    if (!ObjectUtils.toString(month).equals("")) {
        if (month < 10) {
            stringBuilder.append('0');
        }
        stringBuilder.append(month);
    } else {
        stringBuilder.append("00");
    }

    if (day != null) {
        if (day < 10) {
            stringBuilder.append('0');
        }
        stringBuilder.append(day);
    } else {
        stringBuilder.append("00");
    }

    return NumberUtils.toInt(stringBuilder.toString());
}

From source file:org.medici.bia.common.util.DateUtils.java

/**
 * /*from w w w  . j  av  a 2 s . c  om*/
 * @param year
 * @param month
 * @param day
 * @return
 */
public static Integer getIntegerDate(Integer year, Month month, Integer day) {
    StringBuilder stringBuilder = new StringBuilder("");

    if (year != null) {
        stringBuilder.append(year);
    } else {
        stringBuilder.append("0000");
    }

    if (!ObjectUtils.toString(month).equals("")) {
        if (month.getMonthNum() < 10) {
            stringBuilder.append('0');
        }
        stringBuilder.append(month.getMonthNum());
    } else {
        stringBuilder.append("00");
    }

    if (day != null) {
        if (day < 10) {
            stringBuilder.append('0');
        }
        stringBuilder.append(day);
    } else {
        stringBuilder.append("00");
    }

    return NumberUtils.toInt(stringBuilder.toString());
}

From source file:org.medici.bia.common.util.DateUtils.java

/**
 * /*from  w  w  w.ja  va2  s .  co  m*/
 * @param year
 * @param month
 * @param day
 * @return
 */
public static Integer getLuceneDate(Integer year, Month month, Integer day) {
    StringBuilder stringBuilder = new StringBuilder("");

    if (year != null) {
        stringBuilder.append(year);
    } else {
        stringBuilder.append("0001");
    }

    if (!ObjectUtils.toString(month).equals("")) {
        if (month.getMonthNum() < 10) {
            stringBuilder.append('0');
        }
        stringBuilder.append(month.getMonthNum());
    } else {
        stringBuilder.append("01");
    }

    if (day != null) {
        if (day < 10) {
            stringBuilder.append('0');
        }
        stringBuilder.append(day);
    } else {
        stringBuilder.append("01");
    }

    return NumberUtils.toInt(stringBuilder.toString());
}

From source file:org.medici.bia.common.util.DateUtils.java

/**
 * //from   w  w w .  j  a  v  a  2 s.  c  o  m
 * @param year
 * @param month
 * @param day
 * @return
 */
public static String getStringDate(Integer year, Month month, Integer day) {
    StringBuilder returnValue = new StringBuilder("");

    if (year != null) {
        returnValue.append(year);
    }

    if (!ObjectUtils.toString(month).equals("")) {
        if (returnValue.length() > 0) {
            returnValue.append(' ');
        }
        returnValue.append(month);
    }

    if (day != null) {
        if (returnValue.length() > 0) {
            returnValue.append(' ');
        }
        returnValue.append(day);
    }

    return returnValue.toString();
}

From source file:org.medici.bia.common.util.DateUtils.java

/**
 * //  ww w.ja  v  a2s .c  om
 * @param year
 * @param month
 * @param day
 * @return
 */
public static String getStringDateHTMLForTable(Integer year, Month month, Integer day) {
    StringBuilder returnValue = new StringBuilder("");

    if (year != null) {
        returnValue.append(year);
    }

    if (!ObjectUtils.toString(month).equals("")) {
        if (returnValue.length() > 0) {
            returnValue.append("<br />");
        }
        returnValue.append(month);
    }

    if (day != null) {
        if (returnValue.length() > 0) {
            returnValue.append("<br />");
        }
        returnValue.append(day);
    }

    return returnValue.toString();
}

From source file:org.medici.bia.common.util.DateUtils.java

/**
 * //from  w  ww  . j a  va 2s .co m
 * @param year
 * @param month
 * @param day
 * @return
 */
public static String getStringForSortableDate(Integer year, Month month, Integer day) {
    StringBuilder stringBuilder = new StringBuilder("");

    if (year != null) {
        stringBuilder.append(year);
    } else {
        stringBuilder.append("0000");
    }

    if (!ObjectUtils.toString(month).equals("")) {
        if (month.getMonthNum() < 10) {
            stringBuilder.append(" 0");
            stringBuilder.append(month.getMonthNum());
        } else {
            stringBuilder.append(' ');
            stringBuilder.append(month.getMonthNum());
        }
    } else {
        stringBuilder.append(" 00");
    }

    if (day != null) {
        if (day < 10) {
            stringBuilder.append(" 0");
            stringBuilder.append(day);
        } else {
            stringBuilder.append(' ');
            stringBuilder.append(day);
        }
    } else {
        stringBuilder.append(" 00");
    }

    return stringBuilder.toString();
}

From source file:org.medici.bia.common.util.DocumentUtils.java

/**
 * This method return a string relative to the document provided with the following style: <br/>
 * <code> volNum + volLetExt / insertNum + insertLet / folioNum + folioMod + folioRectoVerso </code>
 * /*from www .  j  a  v a 2  s.c  o m*/
 * @param volNum the volume number
 * @param volLetExt the volume extension letter
 * @param insertNum the insert number
 * @param insertLet the insert extension
 * @param folioNum the folio number
 * @param folioMod the folio extension
 * @param folioRectoVerso the folio recto/verso information
 * @return formatted string
 */
public static String toMDPInsertFolioFormat(Integer volNum, String volLetExt, String insertNum,
        String insertLet, Integer folioNum, String folioMod, String folioRectoVerso) {

    StringBuilder s = new StringBuilder();
    s.append(volNum != null ? volNum : "");
    s.append(ObjectUtils.toString(volLetExt));
    if (!"".equals(ObjectUtils.toString(insertNum))) {
        s.append(" / ").append(insertNum);
        if (!"".equals(ObjectUtils.toString(insertLet)))
            s.append(" ").append(insertLet);
    } else
        s.append(" / -");
    if (folioNum != null) {
        s.append(" / ").append(folioNum);
        if (!"".equals(ObjectUtils.toString(folioMod)))
            s.append(" ").append(folioMod);
        if (folioRectoVerso != null)
            s.append(" ").append(folioRectoVerso);
    } else
        s.append(" / NNF");

    return s.toString();
}