Example usage for org.apache.commons.lang StringUtils removeStart

List of usage examples for org.apache.commons.lang StringUtils removeStart

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils removeStart.

Prototype

public static String removeStart(String str, String remove) 

Source Link

Document

Removes a substring only if it is at the begining of a source string, otherwise returns the source string.

Usage

From source file:org.kuali.rice.krad.util.KRADUtils.java

/**
 * Attempts to generate a unique view title by combining the View's headerText with the title attribute for the
 * dataObjectClass found through the DataObjectMetaDataService.  If the title attribute cannot be found, just the
 * headerText is returned./* w  ww  .j a  v a  2s.  c o m*/
 *
 * @param form the form
 * @param view the view
 * @return the headerText with the title attribute in parenthesis or just the headerText if it title attribute
 * cannot be determined
 */
public static String generateUniqueViewTitle(UifFormBase form, View view) {
    String title = view.getHeader().getHeaderText();

    String viewLabelPropertyName = "";

    Class<?> dataObjectClass;
    if (StringUtils.isNotBlank(view.getDefaultBindingObjectPath())) {
        dataObjectClass = ObjectPropertyUtils.getPropertyType(form, view.getDefaultBindingObjectPath());
    } else {
        dataObjectClass = view.getFormClass();
    }

    if (dataObjectClass != null) {
        viewLabelPropertyName = KRADServiceLocatorWeb.getLegacyDataAdapter().getTitleAttribute(dataObjectClass);
    }

    String viewLabelPropertyPath = "";
    if (StringUtils.isNotBlank(viewLabelPropertyName)) {
        // adjust binding prefix
        if (!viewLabelPropertyName.startsWith(UifConstants.NO_BIND_ADJUST_PREFIX)) {
            if (StringUtils.isNotBlank(view.getDefaultBindingObjectPath())) {
                viewLabelPropertyPath = view.getDefaultBindingObjectPath() + "." + viewLabelPropertyName;
            }
        } else {
            viewLabelPropertyPath = StringUtils.removeStart(viewLabelPropertyName,
                    UifConstants.NO_BIND_ADJUST_PREFIX);
        }
    } else {
        // attempt to get title attribute
        if (StringUtils.isNotBlank(view.getDefaultBindingObjectPath())) {
            dataObjectClass = ViewModelUtils.getObjectClassForMetadata(view, form,
                    view.getDefaultBindingObjectPath());
        } else {
            dataObjectClass = view.getFormClass();
        }

        if (dataObjectClass != null) {
            String titleAttribute = KRADServiceLocatorWeb.getLegacyDataAdapter()
                    .getTitleAttribute(dataObjectClass);
            if (StringUtils.isNotBlank(titleAttribute)) {
                viewLabelPropertyPath = view.getDefaultBindingObjectPath() + "." + titleAttribute;
            }
        }
    }

    Object viewLabelPropertyValue = null;
    if (StringUtils.isNotBlank(viewLabelPropertyPath)
            && ObjectPropertyUtils.isReadableProperty(form, viewLabelPropertyPath)) {
        viewLabelPropertyValue = ObjectPropertyUtils.getPropertyValueAsText(form, viewLabelPropertyPath);
    }

    if (viewLabelPropertyValue != null && StringUtils.isNotBlank(viewLabelPropertyValue.toString())
            && StringUtils.isNotBlank(title)) {
        return title + " (" + viewLabelPropertyValue.toString() + ")";
    } else {
        return title;
    }
}

From source file:org.kuali.rice.krad.util.KRADUtils.java

/**
 * Get the rowCss for the line specified, by evaluating the conditionalRowCssClasses map for that row
 *
 * @param conditionalRowCssClasses the conditionalRowCssClass map, where key is the condition and value is
 * the class(es)//from w  w w. j a va  2 s.  c  o  m
 * @param lineIndex the line/row index
 * @param isOdd true if the row is considered odd
 * @param lineContext the lineContext for expressions, pass null if not applicable
 * @param expressionEvaluator the expressionEvaluator, pass null if not applicable
 * @return row csss class String for the class attribute of this row
 */
public static String generateRowCssClassString(Map<String, String> conditionalRowCssClasses, int lineIndex,
        boolean isOdd, Map<String, Object> lineContext, ExpressionEvaluator expressionEvaluator) {
    String rowCss = "";
    if (conditionalRowCssClasses == null || conditionalRowCssClasses.isEmpty()) {
        return rowCss;
    }

    for (String cssRule : conditionalRowCssClasses.keySet()) {
        if (cssRule.startsWith(UifConstants.EL_PLACEHOLDER_PREFIX) && lineContext != null
                && expressionEvaluator != null) {
            String outcome = expressionEvaluator.evaluateExpressionTemplate(lineContext, cssRule);
            if (outcome != null && Boolean.parseBoolean(outcome)) {
                rowCss = rowCss + " " + conditionalRowCssClasses.get(cssRule);
            }
        } else if (cssRule.equals(UifConstants.RowSelection.ALL)) {
            rowCss = rowCss + " " + conditionalRowCssClasses.get(cssRule);
        } else if (cssRule.equals(UifConstants.RowSelection.EVEN) && !isOdd) {
            rowCss = rowCss + " " + conditionalRowCssClasses.get(cssRule);
        } else if (cssRule.equals(UifConstants.RowSelection.ODD) && isOdd) {
            rowCss = rowCss + " " + conditionalRowCssClasses.get(cssRule);
        } else if (StringUtils.isNumeric(cssRule) && (lineIndex + 1) == Integer.parseInt(cssRule)) {
            rowCss = rowCss + " " + conditionalRowCssClasses.get(cssRule);
        }
    }

    rowCss = StringUtils.removeStart(rowCss, " ");

    return rowCss;
}

From source file:org.kuali.rice.location.framework.country.AbstractCountryValuesFinderBase.java

@Override
public List<KeyValue> getKeyValues() {
    Country defaultCountry = getDefaultCountry();
    List<Country> countries = new ArrayList<Country>(retrieveCountriesForValuesFinder());

    List<KeyValue> values = new ArrayList<KeyValue>(countries.size() + 1);
    values.add(new ConcreteKeyValue("", ""));
    if (defaultCountry != null) {
        values.add(new ConcreteKeyValue(defaultCountry.getCode(), defaultCountry.getName()));
    }//from  w  ww . j  a  v a 2s  .c  om

    Collections.sort(countries, new Comparator<Country>() {
        @Override
        public int compare(Country country1, Country country2) {
            // some institutions may prefix the country name with an asterisk if the country no longer exists
            // the country names will be compared without the asterisk
            String sortValue1 = StringUtils.trim(StringUtils.removeStart(country1.getName(), "*"));
            String sortValue2 = StringUtils.trim(StringUtils.removeStart(country2.getName(), "*"));
            return sortValue1.compareToIgnoreCase(sortValue2);
        }

    });

    // the default country may show up twice, but that's fine
    for (Country country : countries) {
        if (country.isActive()) {
            values.add(new ConcreteKeyValue(country.getCode(), country.getName()));
        }
    }
    return values;
}

From source file:org.kuali.rice.shareddata.framework.country.AbstractCountryValuesFinderBase.java

@Override
public List<KeyValue> getKeyValues() {
    List<Country> boList = new ArrayList<Country>(retrieveCountriesForValuesFinder());
    List<KeyValue> labels = new ArrayList<KeyValue>(boList.size() + 1);

    labels.add(new ConcreteKeyValue("", ""));

    Collections.sort(boList, new Comparator<Country>() {
        @Override/* w w w  .  j a  va2s  .  co  m*/
        public int compare(Country o1, Country o2) {
            // some institutions may prefix the country name with an asterisk if the country no longer exists
            // the country names will be compared without the asterisk
            String sortValue1 = StringUtils.trim(StringUtils.removeStart(o1.getName(), "*"));
            String sortValue2 = StringUtils.trim(StringUtils.removeStart(o2.getName(), "*"));
            return sortValue1.compareToIgnoreCase(sortValue2);
        }

    });

    for (Country country : boList) {
        if (country.isActive()) {
            labels.add(new ConcreteKeyValue(country.getCode(), country.getName()));
        }
    }
    return labels;
}

From source file:org.kuali.student.common.uif.widget.KSRichTable.java

/**
 * Builds column options for sorting//w  ww.  jav a2 s  .  c  om
 *
 * @param collectionGroup
 */
@Override
protected void buildTableOptions(CollectionGroup collectionGroup) {
    LayoutManager layoutManager = collectionGroup.getLayoutManager();
    final boolean isUseServerPaging = collectionGroup.isUseServerPaging();

    // if sub collection exists, don't allow the table sortable
    if (!collectionGroup.getSubCollections().isEmpty()) {
        setDisableTableSort(true);
    }

    if (!isDisableTableSort()) {
        // if rendering add line, skip that row from col sorting
        if (collectionGroup.isRenderAddLine() && !collectionGroup.isReadOnly()
                && !((layoutManager instanceof TableLayoutManager)
                        && ((TableLayoutManager) layoutManager).isSeparateAddLine())) {
            Map<String, String> oTemplateOptions = this.getTemplateOptions();

            if (oTemplateOptions == null) {
                setTemplateOptions(oTemplateOptions = new HashMap<String, String>());
            }

            oTemplateOptions.put(UifConstants.TableToolsKeys.SORT_SKIP_ROWS,
                    "[" + UifConstants.TableToolsValues.ADD_ROW_DEFAULT_INDEX + "]");
        }

        StringBuilder tableToolsColumnOptions = new StringBuilder("[");

        int columnIndex = 0;
        int actionIndex = UifConstants.TableLayoutValues.ACTIONS_COLUMN_RIGHT_INDEX;
        boolean actionFieldVisible = collectionGroup.isRenderLineActions() && !collectionGroup.isReadOnly();

        if (layoutManager instanceof TableLayoutManager) {
            actionIndex = ((TableLayoutManager) layoutManager).getActionColumnIndex();
        }

        if (actionIndex == UifConstants.TableLayoutValues.ACTIONS_COLUMN_LEFT_INDEX && actionFieldVisible) {
            String actionColOptions = constructTableColumnOptions(columnIndex, false, isUseServerPaging, null,
                    null);
            tableToolsColumnOptions.append(actionColOptions + " , ");
            columnIndex++;
        }

        if (layoutManager instanceof TableLayoutManager
                && ((TableLayoutManager) layoutManager).isRenderSequenceField()) {

            //add mData handling if using a json data source
            String mDataOption = "";
            if (collectionGroup.isUseServerPaging() || isForceLocalJsonData()) {
                mDataOption = "\"" + UifConstants.TableToolsKeys.MDATA
                        + "\" : function(row,type,newVal){ return _handleColData(row,type,'c" + columnIndex
                        + "',newVal);}, ";
            }

            tableToolsColumnOptions.append("{\"" + UifConstants.TableToolsKeys.SORTABLE + "\" : " + false
            // auto sequence column is never sortable
                    + ", \"" + UifConstants.TableToolsKeys.SORT_TYPE + "\" : \""
                    + UifConstants.TableToolsValues.NUMERIC + "\", " + mDataOption + "\""
                    + UifConstants.TableToolsKeys.TARGETS + "\": [" + columnIndex + "]}, ");
            columnIndex++;
            if (actionIndex == 2 && actionFieldVisible) {
                String actionColOptions = constructTableColumnOptions(columnIndex, false, isUseServerPaging,
                        null, null);
                tableToolsColumnOptions.append(actionColOptions + " , ");
                columnIndex++;
            }
        }

        // skip select field if enabled
        if (collectionGroup.isIncludeLineSelectionField()) {
            String colOptions = constructTableColumnOptions(columnIndex, false, isUseServerPaging, null, null);
            tableToolsColumnOptions.append(colOptions + " , ");
            columnIndex++;
        }

        // if data dictionary defines aoColumns, copy here and skip default sorting/visibility behaviour
        if (!StringUtils.isEmpty(getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMNS))) {
            // get the contents of the JS array string
            String jsArray = getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMNS);
            int startBrace = StringUtils.indexOf(jsArray, "[");
            int endBrace = StringUtils.lastIndexOf(jsArray, "]");
            tableToolsColumnOptions.append(StringUtils.substring(jsArray, startBrace + 1, endBrace) + ", ");

            if (actionFieldVisible && (actionIndex == -1 || actionIndex >= columnIndex)) {
                String actionColOptions = constructTableColumnOptions(columnIndex, false, isUseServerPaging,
                        null, null);
                tableToolsColumnOptions.append(actionColOptions);
            } else {
                tableToolsColumnOptions = new StringBuilder(
                        StringUtils.removeEnd(tableToolsColumnOptions.toString(), ", "));
            }

            tableToolsColumnOptions.append("]");
            getTemplateOptions().put(UifConstants.TableToolsKeys.AO_COLUMNS,
                    tableToolsColumnOptions.toString());
        } else if (!StringUtils.isEmpty(getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS))
                && isForceAoColumnDefsOverride()) {
            String jsArray = getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS);
            int startBrace = StringUtils.indexOf(jsArray, "[");
            int endBrace = StringUtils.lastIndexOf(jsArray, "]");
            tableToolsColumnOptions.append(StringUtils.substring(jsArray, startBrace + 1, endBrace) + ", ");

            if (actionFieldVisible && (actionIndex == -1 || actionIndex >= columnIndex)) {
                String actionColOptions = constructTableColumnOptions(columnIndex, false, isUseServerPaging,
                        null, null);
                tableToolsColumnOptions.append(actionColOptions);
            } else {
                tableToolsColumnOptions = new StringBuilder(
                        StringUtils.removeEnd(tableToolsColumnOptions.toString(), ", "));
            }

            tableToolsColumnOptions.append("]");
            getTemplateOptions().put(UifConstants.TableToolsKeys.AO_COLUMN_DEFS,
                    tableToolsColumnOptions.toString());
        } else if (layoutManager instanceof TableLayoutManager) {
            List<Field> rowFields = ((TableLayoutManager) layoutManager).getFirstRowFields();

            // build column defs from the the first row of the table
            for (Component component : rowFields) {
                if (actionFieldVisible && columnIndex + 1 == actionIndex) {
                    String actionColOptions = constructTableColumnOptions(columnIndex, false, isUseServerPaging,
                            null, null);
                    tableToolsColumnOptions.append(actionColOptions + " , ");
                    columnIndex++;
                }

                //add mData handling if using a json data source
                String mDataOption = "";
                if (collectionGroup.isUseServerPaging() || isForceLocalJsonData()) {
                    mDataOption = "\"" + UifConstants.TableToolsKeys.MDATA
                            + "\" : function(row,type,newVal){ return _handleColData(row,type,'c" + columnIndex
                            + "',newVal);}, ";
                }

                // for FieldGroup, get the first field from that group
                if (component instanceof FieldGroup) {
                    component = ((FieldGroup) component).getItems().get(0);
                }

                Map<String, String> componentDataAttributes;
                if (component instanceof DataField) {
                    DataField field = (DataField) component;

                    // if a field is marked as invisible in hiddenColumns, append options and skip sorting
                    if (getHiddenColumns() != null && getHiddenColumns().contains(field.getPropertyName())) {
                        tableToolsColumnOptions.append("{" + UifConstants.TableToolsKeys.VISIBLE + ": "
                                + UifConstants.TableToolsValues.FALSE + ", " + mDataOption + "\""
                                + UifConstants.TableToolsKeys.TARGETS + "\": [" + columnIndex + "]" + "}, ");
                        // if sortableColumns is present and a field is marked as sortable or unspecified
                    } else if (getSortableColumns() != null && !getSortableColumns().isEmpty()) {
                        if (getSortableColumns().contains(field.getPropertyName())) {
                            tableToolsColumnOptions.append(
                                    getDataFieldColumnOptions(columnIndex, collectionGroup, field) + ", ");
                        } else {
                            tableToolsColumnOptions.append("{'" + UifConstants.TableToolsKeys.SORTABLE + "': "
                                    + UifConstants.TableToolsValues.FALSE + ", " + mDataOption + "\""
                                    + UifConstants.TableToolsKeys.TARGETS + "\": [" + columnIndex + "]"
                                    + "}, ");
                        }
                    } else {// sortable columns not defined
                        String colOptions = getDataFieldColumnOptions(columnIndex, collectionGroup, field);
                        tableToolsColumnOptions.append(colOptions + " , ");
                    }
                    columnIndex++;
                } else if ((component instanceof MessageField)
                        && (componentDataAttributes = component.getDataAttributes()) != null
                        && UifConstants.RoleTypes.ROW_GROUPING
                                .equals(componentDataAttributes.get(UifConstants.DataAttributes.ROLE))) {
                    //Grouping column is never shown, so skip
                    tableToolsColumnOptions.append("{" + UifConstants.TableToolsKeys.VISIBLE + ": "
                            + UifConstants.TableToolsValues.FALSE + ", " + mDataOption + "\""
                            + UifConstants.TableToolsKeys.TARGETS + "\": [" + columnIndex + "]" + "}, ");
                    columnIndex++;
                    // start KS customization (to allow message field sorting) - KSENROLL-4999
                } else if (component instanceof MessageField) {
                    componentDataAttributes = component.getDataAttributes();
                    //For message field, sort as a regular String
                    String sortType = "";
                    if (componentDataAttributes != null) {
                        sortType = componentDataAttributes.get("sortType");
                    }
                    if (StringUtils.isBlank(sortType)) {
                        sortType = UifConstants.TableToolsValues.DOM_TEXT;
                    }
                    String colOptions = constructTableColumnOptions(columnIndex, true, isUseServerPaging,
                            String.class, sortType);
                    tableToolsColumnOptions.append(colOptions + " , ");
                    columnIndex++;
                    // end KS customization (to allow message field sorting) - KSENROLL-4999
                } else if (component instanceof LinkField) {
                    String colOptions = constructTableColumnOptions(columnIndex, true, isUseServerPaging,
                            String.class, UifConstants.TableToolsValues.DOM_TEXT);
                    tableToolsColumnOptions.append(colOptions + " , ");
                    columnIndex++;
                } else {
                    String colOptions = constructTableColumnOptions(columnIndex, false, isUseServerPaging, null,
                            null);
                    tableToolsColumnOptions.append(colOptions + " , ");
                    columnIndex++;
                }

            }

            if (actionFieldVisible && (actionIndex == -1 || actionIndex >= columnIndex)) {
                String actionColOptions = constructTableColumnOptions(columnIndex, false, isUseServerPaging,
                        null, null);
                tableToolsColumnOptions.append(actionColOptions);
            } else {
                tableToolsColumnOptions = new StringBuilder(
                        StringUtils.removeEnd(tableToolsColumnOptions.toString(), ", "));
            }
            //merge the aoColumnDefs passed in
            if (!StringUtils.isEmpty(getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS))) {
                String origAoOptions = getTemplateOptions().get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS)
                        .trim();
                origAoOptions = StringUtils.removeStart(origAoOptions, "[");
                origAoOptions = StringUtils.removeEnd(origAoOptions, "]");
                tableToolsColumnOptions.append("," + origAoOptions);
            }

            tableToolsColumnOptions.append("]");
            getTemplateOptions().put(UifConstants.TableToolsKeys.AO_COLUMN_DEFS,
                    tableToolsColumnOptions.toString());
        }
    }
}

From source file:org.kuali.student.core.krms.SimpleTableLayoutManager.java

/**
 * Assembles the field instances for the collection line. The given sequence
 * field prototype is copied for the line sequence field. Likewise a copy of
 * the actionFieldPrototype is made and the given actions are set as the
 * items for the action field. Finally the generated items are assembled
 * together into the allRowFields list with the given lineFields.
 *
 * @see CollectionLayoutManager#buildLine(org.kuali.rice.krad.uif.container.collections.LineBuilderContext)
 *///from   w w  w .  j  a  v  a  2 s  .  c o m
@Override
public void buildLine(LineBuilderContext lineBuilderContext) {
    View view = ViewLifecycle.getView();

    List<Field> lineFields = lineBuilderContext.getLineFields();
    CollectionGroup collectionGroup = lineBuilderContext.getCollectionGroup();
    int lineIndex = lineBuilderContext.getLineIndex();
    String idSuffix = lineBuilderContext.getIdSuffix();
    Object currentLine = lineBuilderContext.getCurrentLine();
    String bindingPath = lineBuilderContext.getBindingPath();

    // since expressions are not evaluated on child components yet, we need to evaluate any properties
    // we are going to read for building the table
    ExpressionEvaluator expressionEvaluator = ViewLifecycle.getExpressionEvaluator();
    for (Field lineField : lineFields) {
        lineField.pushObjectToContext(UifConstants.ContextVariableNames.PARENT, collectionGroup);
        lineField.pushAllToContext(view.getContext());
        lineField.pushObjectToContext(UifConstants.ContextVariableNames.THEME_IMAGES,
                view.getTheme().getImageDirectory());
        lineField.pushObjectToContext(UifConstants.ContextVariableNames.COMPONENT, lineField);

        expressionEvaluator.evaluatePropertyExpression(view, lineField.getContext(), lineField,
                UifPropertyPaths.ROW_SPAN, true);
        expressionEvaluator.evaluatePropertyExpression(view, lineField.getContext(), lineField,
                UifPropertyPaths.COL_SPAN, true);
        expressionEvaluator.evaluatePropertyExpression(view, lineField.getContext(), lineField,
                UifPropertyPaths.REQUIRED, true);
        expressionEvaluator.evaluatePropertyExpression(view, lineField.getContext(), lineField,
                UifPropertyPaths.READ_ONLY, true);
    }

    // if first line for table set number of data columns
    if (this.getAllRowFields().isEmpty()) {
        if (isSuppressLineWrapping()) {
            setNumberOfDataColumns(lineFields.size());
        } else {
            setNumberOfDataColumns(getNumberOfColumns());
        }
    }

    boolean isAddLine = false;

    String rowCss = "";
    boolean addLineInTable = collectionGroup.isRenderAddLine() && !collectionGroup.isReadOnly()
            && !isSeparateAddLine();

    if (collectionGroup.isHighlightNewItems()
            && ((UifFormBase) lineBuilderContext.getModel()).isAddedCollectionItem(currentLine)) {
        rowCss = collectionGroup.getNewItemsCssClass();
    } else if (isAddLine && addLineInTable) {
        rowCss = collectionGroup.getAddItemCssClass();
        this.addStyleClass(CssConstants.Classes.HAS_ADD_LINE);
    }

    rowCss = StringUtils.removeStart(rowCss, " ");
    this.getRowCssClasses().add(rowCss);

    // set label field rendered to true on line fields and adjust cell properties
    for (Field field : lineFields) {
        field.setLabelRendered(true);
        field.setFieldLabel(null);

        setCellAttributes(field);
    }

    // select field will come after sequence field (if enabled) or be first column
    if (collectionGroup.isIncludeLineSelectionField()) {
        Field selectField = ComponentUtils.copy(getSelectFieldPrototype(), idSuffix);
        CollectionLayoutUtils.prepareSelectFieldForLine(selectField, collectionGroup, bindingPath, currentLine);

        ComponentUtils.updateContextForLine(selectField, collectionGroup, currentLine, lineIndex, idSuffix);
        setCellAttributes(selectField);

        this.getAllRowFields().add(selectField);

    }

    // now add the fields in the correct position
    for (Field lineField : lineFields) {

        this.getAllRowFields().add(lineField);

        //details action
        if (lineField instanceof FieldGroup && ((FieldGroup) lineField).getItems() != null) {
            for (Component component : ((FieldGroup) lineField).getItems()) {
                if (component != null && component instanceof Action
                        && component.getDataAttributes().get("role") != null
                        && component.getDataAttributes().get("role").equals("detailsLink")
                        && StringUtils.isBlank(((Action) component).getActionScript())) {
                    ((Action) component)
                            .setActionScript("rowDetailsActionHandler(this,'" + this.getId() + "');");
                }
            }
        }
    }

    // add sub-collection fields to end of data fields
    this.getAllRowFields().addAll(lineBuilderContext.getSubCollectionFields());
}

From source file:org.kuali.student.enrollment.class2.acal.dto.TimeSetWrapper.java

protected String formatEndDateUI(Date endDate) {
    if (endDate != null) {
        if (!isAllDay()) {
            String formattedEndDate = DateFormatters.MONTH_DAY_YEAR_TIME_DATE_FORMATTER.format(endDate);
            String formattedStartDate = DateFormatters.MONTH_DAY_YEAR_TIME_DATE_FORMATTER.format(startDate);
            String strippedDate = StringUtils.removeStart(formattedEndDate,
                    StringUtils.substringBefore(formattedStartDate, " "));
            return StringUtils.removeEndIgnoreCase(strippedDate, "11:59 pm");
        } else {//from  w ww  .  j  av a 2s  . c o m
            if (isDateRange()) {
                return DateFormatters.MONTH_DAY_YEAR_DATE_FORMATTER.format(endDate);
            } else {
                return StringUtils.EMPTY;
            }
        }
    } else {
        return StringUtils.EMPTY;
    }

}

From source file:org.lexevs.dao.database.utility.DaoUtility.java

private static String removeLeadingUnderscore(String string) {
    if (StringUtils.isBlank(string)) {
        return null;
    }//from w w  w. java 2s  .  c om

    if (string.startsWith("_")) {
        string = StringUtils.removeStart(string, "_");
    }
    return string;
}

From source file:org.lilyproject.lilyservertestfw.ConfUtil.java

public static void copyFromJar(File confDir, String confResourcePath, JarURLConnection jarConnection)
        throws IOException {
    JarFile jarFile = jarConnection.getJarFile();
    Enumeration<JarEntry> entries = jarFile.entries();
    while (entries.hasMoreElements()) {
        JarEntry entry = entries.nextElement();
        if (entry.getName().startsWith(confResourcePath)) {
            String fileName = StringUtils.removeStart(entry.getName(), confResourcePath);
            if (entry.isDirectory()) {
                File subDir = new File(confDir, fileName);
                subDir.mkdirs();//from   w  ww  .  j av  a  2  s  .  c  om
            } else {
                InputStream entryInputStream = null;
                try {
                    entryInputStream = jarFile.getInputStream(entry);
                    FileUtils.copyInputStreamToFile(entryInputStream, new File(confDir, fileName));
                } finally {
                    if (entryInputStream != null) {
                        entryInputStream.close();
                    }
                }
            }
        }
    }
}

From source file:org.lisapark.octopus.util.jdbc.DaoUtils.java

/**
 * Converts the object to the string//from   w w w.  ja v  a 2s .  c  o  m
 * with some (very minimal) formating.
 */
public static String convertToSqlString(Object value) {

    if (value == null) {
        return "";
    }
    String newValue;
    if (value instanceof Date) {
        SimpleDateFormat dateFormatter = new SimpleDateFormat("YYYY-mm-dd");
        newValue = dateFormatter.format((Date) value);
    } else if (value instanceof Boolean) {
        boolean bool = ((Boolean) value).booleanValue();
        if (bool) {
            newValue = "1";
        } else {
            newValue = "0";
        }
    } else {
        newValue = value.toString();
    }
    // remove all chars that can be part of numeric value, but not
    // a unicode numeric char (minus, decimal point, and comma)
    String tmp = StringUtils.removeStart(newValue, "-");
    //        tmp = StringUtils.remove(tmp, '.');
    tmp = StringUtils.remove(tmp, ',');

    return StringUtils.isNumeric(tmp) ? (StringUtils.isBlank(newValue) ? "''" : newValue)
            : ("'" + StringEscapeUtils.escapeSql(newValue)) + "'";
}