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

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

Introduction

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

Prototype

public static String substring(String str, int start, int end) 

Source Link

Document

Gets a substring from the specified String avoiding exceptions.

Usage

From source file:org.kuali.rice.krad.labs.transactional.LabsLookupSecurityTravelAuthorizationDocumentBase.java

/**
 * Tests the case in which the a new conversion field is added so that a field that is not referenced in either the
 * data dictionary or the Uif (the traveler type code) appears in the email address field, which is not secured.
 *
 * @throws Exception// w  w w.j  av  a  2  s  . c  o m
 */
protected void testTransactionalLookupSecurityAddHiddenConversionField() throws Exception {
    waitAndClick(By.id("travelerQuickfinder_quickfinder_act"));
    waitForPageToLoad();

    int splitPosition = StringUtils.indexOf(driver.getCurrentUrl(), CONVERSION_FIELDS)
            + CONVERSION_FIELDS.length();
    String before = StringUtils.substring(driver.getCurrentUrl(), 0, splitPosition);
    String after = StringUtils.substring(driver.getCurrentUrl(), splitPosition);
    String newUrl = before + ERRANT_CONVERSION_FIELD + after;
    open(newUrl);
    waitForPageToLoad();

    waitAndClickSearch3();
    waitAndClickReturnValue();

    assertElementPresentByName(EMAIL_ADDRESS_NAME);
    WebElement element = findElement(By.name(EMAIL_ADDRESS_NAME));
    String emailAddress = element.getAttribute("value");

    assertTrue("Non-secure field emailAddress was not empty", StringUtils.isBlank(emailAddress));
}

From source file:org.kuali.rice.krad.service.impl.KRADLegacyDataAdapterImpl.java

@Override
public org.kuali.rice.krad.bo.DataObjectRelationship getDataObjectRelationship(Object dataObject,
        Class<?> dataObjectClass, String attributeName, String attributePrefix, boolean keysOnly,
        boolean supportsLookup, boolean supportsInquiry) {
    RelationshipDefinition ddReference = getDictionaryRelationship(dataObjectClass, attributeName);

    org.kuali.rice.krad.bo.DataObjectRelationship relationship = null;
    DataObjectAttributeRelationship rel = null;
    if (PropertyAccessorUtils.isNestedOrIndexedProperty(attributeName)) {
        if (ddReference != null) {
            if (classHasSupportedFeatures(ddReference.getTargetClass(), supportsLookup, supportsInquiry)) {
                relationship = populateRelationshipFromDictionaryReference(dataObjectClass, ddReference,
                        attributePrefix, keysOnly);

                return relationship;
            }//from   ww  w . ja  v a 2  s .c om
        }

        if (dataObject == null) {
            try {
                dataObject = KRADUtils.createNewObjectFromClass(dataObjectClass);
            } catch (RuntimeException e) {
                // found interface or abstract class, just swallow exception and return a null relationship
                return null;
            }
        }

        // recurse down to the next object to find the relationship
        int nextObjectIndex = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(attributeName);
        if (nextObjectIndex == StringUtils.INDEX_NOT_FOUND) {
            nextObjectIndex = attributeName.length();
        }
        String localPrefix = StringUtils.substring(attributeName, 0, nextObjectIndex);
        String localAttributeName = StringUtils.substring(attributeName, nextObjectIndex + 1);
        Object nestedObject = ObjectPropertyUtils.getPropertyValue(dataObject, localPrefix);
        Class<?> nestedClass = null;
        if (nestedObject == null) {
            nestedClass = ObjectPropertyUtils.getPropertyType(dataObject, localPrefix);
        } else {
            nestedClass = nestedObject.getClass();
        }

        String fullPrefix = localPrefix;
        if (StringUtils.isNotBlank(attributePrefix)) {
            fullPrefix = attributePrefix + "." + localPrefix;
        }

        relationship = getDataObjectRelationship(nestedObject, nestedClass, localAttributeName, fullPrefix,
                keysOnly, supportsLookup, supportsInquiry);

        return relationship;
    }

    // non-nested reference, get persistence relationships first
    int maxSize = Integer.MAX_VALUE;

    if (isPersistable(dataObjectClass)) {
        DataObjectMetadata metadata = dataObjectService.getMetadataRepository().getMetadata(dataObjectClass);
        DataObjectRelationship dataObjectRelationship = metadata.getRelationship(attributeName);

        if (dataObjectRelationship != null) {
            List<DataObjectAttributeRelationship> attributeRelationships = dataObjectRelationship
                    .getAttributeRelationships();
            for (DataObjectAttributeRelationship dataObjectAttributeRelationship : attributeRelationships) {
                if (classHasSupportedFeatures(dataObjectRelationship.getRelatedType(), supportsLookup,
                        supportsInquiry)) {
                    maxSize = attributeRelationships.size();
                    relationship = transformToDeprecatedDataObjectRelationship(dataObjectClass, attributeName,
                            attributePrefix, dataObjectRelationship.getRelatedType(),
                            dataObjectAttributeRelationship);

                    break;
                }
            }
        }

    } else {
        ModuleService moduleService = kualiModuleService.getResponsibleModuleService(dataObjectClass);
        if (moduleService != null && moduleService.isExternalizable(dataObjectClass)) {
            relationship = getRelationshipMetadata(dataObjectClass, attributeName, attributePrefix);
            if ((relationship != null) && classHasSupportedFeatures(relationship.getRelatedClass(),
                    supportsLookup, supportsInquiry)) {
                return relationship;
            } else {
                return null;
            }
        }
    }

    if (ddReference != null && ddReference.getPrimitiveAttributes().size() < maxSize) {
        if (classHasSupportedFeatures(ddReference.getTargetClass(), supportsLookup, supportsInquiry)) {
            relationship = populateRelationshipFromDictionaryReference(dataObjectClass, ddReference, null,
                    keysOnly);
        }
    }
    return relationship;
}

From source file:org.kuali.rice.krad.uif.widget.RichTable.java

/**
 * Builds column options for sorting// ww w  . java  2  s .c  om
 *
 * @param collectionGroup
 */
protected void buildTableOptions(CollectionGroup collectionGroup) {
    checkMutable(false);

    LayoutManager layoutManager = collectionGroup.getLayoutManager();
    final boolean useServerPaging = collectionGroup.isUseServerPaging();

    if (templateOptions.isEmpty()) {
        setTemplateOptions(new HashMap<String, String>());
    }

    // 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() && !Boolean.TRUE.equals(collectionGroup.getReadOnly())
                && !((layoutManager instanceof TableLayoutManager)
                        && ((TableLayoutManager) layoutManager).isSeparateAddLine())) {

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

        StringBuilder tableColumnOptions = new StringBuilder("[");

        int colIndex = 0;
        int actionIndex = UifConstants.TableLayoutValues.ACTIONS_COLUMN_RIGHT_INDEX;
        boolean actionFieldVisible = collectionGroup.isRenderLineActions()
                && !Boolean.TRUE.equals(collectionGroup.getReadOnly());

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

        if (actionIndex == UifConstants.TableLayoutValues.ACTIONS_COLUMN_LEFT_INDEX && actionFieldVisible) {
            String options = constructTableColumnOptions(colIndex, false, useServerPaging, null, null);
            tableColumnOptions.append(options + ",");
            colIndex++;
        }

        // handle sequence field
        if (layoutManager instanceof TableLayoutManager
                && ((TableLayoutManager) layoutManager).isRenderSequenceField()) {
            Class<?> dataTypeClass = Number.class;

            if (((TableLayoutManager) layoutManager).getSequenceFieldPrototype() instanceof DataField) {
                DataField dataField = (DataField) ((TableLayoutManager) layoutManager)
                        .getSequenceFieldPrototype();
                dataTypeClass = ObjectPropertyUtils.getPropertyType(collectionGroup.getCollectionObjectClass(),
                        dataField.getPropertyName());
                // check to see if field has custom sort type
                if (dataField.getSortAs() != null && dataField.getSortAs().length() > 0) {
                    if (dataField.getSortAs().equals(UifConstants.TableToolsValues.DATE)) {
                        dataTypeClass = java.sql.Date.class;
                    } else if (dataField.getSortAs().equals(UifConstants.TableToolsValues.NUMERIC)) {
                        dataTypeClass = Number.class;
                    } else if (dataField.getSortAs().equals(UifConstants.TableToolsValues.STRING)) {
                        dataTypeClass = String.class;
                    }
                }
            }

            // don't allow sorting of sequence field - why?
            // auto sequence column is never sortable
            tableColumnOptions.append("{" + sortable(false) + "," + sortType(getSortType(dataTypeClass)) + ","
                    + sortDataType(UifConstants.TableToolsValues.DOM_TEXT) + mData(useServerPaging, colIndex)
                    + "," + targets(colIndex) + "},");
            colIndex++;

            if (actionIndex == 2 && actionFieldVisible) {
                String options = constructTableColumnOptions(colIndex, false, useServerPaging, null, null);
                tableColumnOptions.append(options + ",");
                colIndex++;
            }
        }

        // skip select field if enabled
        if (collectionGroup.isIncludeLineSelectionField()) {
            String options = constructTableColumnOptions(colIndex, false, useServerPaging, null, null);
            tableColumnOptions.append(options + ",");
            colIndex++;
        }

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

            if (actionFieldVisible && (actionIndex == -1 || actionIndex >= colIndex)) {
                String options = constructTableColumnOptions(colIndex, false, useServerPaging, null, null);
                tableColumnOptions.append(options);
            } else {
                tableColumnOptions = new StringBuilder(
                        StringUtils.removeEnd(tableColumnOptions.toString(), ","));
            }

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

            if (actionFieldVisible && (actionIndex == -1 || actionIndex >= colIndex)) {
                String options = constructTableColumnOptions(colIndex, false, useServerPaging, null, null);
                tableColumnOptions.append(options);
            } else {
                tableColumnOptions = new StringBuilder(
                        StringUtils.removeEnd(tableColumnOptions.toString(), ","));
            }

            tableColumnOptions.append("]");
            templateOptions.put(UifConstants.TableToolsKeys.AO_COLUMN_DEFS, tableColumnOptions.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 && colIndex + 1 == actionIndex) {
                    String options = constructTableColumnOptions(colIndex, false, useServerPaging, null, null);
                    tableColumnOptions.append(options + ",");
                    colIndex++;
                }

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

                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())) {
                        tableColumnOptions.append("{" + visible(false) + "," + mData(useServerPaging, colIndex)
                                + targets(colIndex) + "},");
                    } else if (getSortableColumns() != null && !getSortableColumns().isEmpty()) {
                        // if specified as a column as sortable then add it
                        if (getSortableColumns().contains(field.getPropertyName())) {
                            tableColumnOptions
                                    .append(getDataFieldColumnOptions(colIndex, collectionGroup, field) + ",");
                        } else { // else designate it as not sortable
                            tableColumnOptions.append("{" + sortable(false) + ","
                                    + mData(useServerPaging, colIndex) + targets(colIndex) + "},");
                        }
                    } else { // sortable columns not defined
                        String options = getDataFieldColumnOptions(colIndex, collectionGroup, field);
                        tableColumnOptions.append(options + ",");
                    }
                    colIndex++;
                } else if (component instanceof MessageField) {
                    if (component.getDataAttributes() != null && UifConstants.RoleTypes.ROW_GROUPING
                            .equals(component.getDataAttributes().get(UifConstants.DataAttributes.ROLE))) {
                        // Grouping column is never shown, so skip
                        tableColumnOptions.append("{" + visible(false) + "," + mData(useServerPaging, colIndex)
                                + targets(colIndex) + "},");
                    } else {
                        String options = constructTableColumnOptions(colIndex, true, useServerPaging,
                                String.class, UifConstants.TableToolsValues.DOM_TEXT);
                        tableColumnOptions.append(options + ",");
                    }
                    colIndex++;
                } else if (component instanceof LinkField) {
                    LinkField linkField = (LinkField) component;

                    Class<?> dataTypeClass = String.class;
                    // check to see if field has custom sort type
                    if (linkField.getSortAs() != null && linkField.getSortAs().length() > 0) {
                        if (linkField.getSortAs().equals(UifConstants.TableToolsValues.DATE)) {
                            dataTypeClass = java.sql.Date.class;
                        } else if (linkField.getSortAs().equals(UifConstants.TableToolsValues.NUMERIC)) {
                            dataTypeClass = Number.class;
                        } else if (linkField.getSortAs().equals(UifConstants.TableToolsValues.STRING)) {
                            dataTypeClass = String.class;
                        }
                    }

                    String options = constructTableColumnOptions(colIndex, true, useServerPaging, dataTypeClass,
                            UifConstants.TableToolsValues.DOM_TEXT);
                    tableColumnOptions.append(options + ",");
                    colIndex++;
                } else {
                    String options = constructTableColumnOptions(colIndex, false, useServerPaging, null, null);
                    tableColumnOptions.append(options + ",");
                    colIndex++;
                }
            }

            if (actionFieldVisible && (actionIndex == -1 || actionIndex >= colIndex)) {
                String options = constructTableColumnOptions(colIndex, false, useServerPaging, null, null);
                tableColumnOptions.append(options);
            } else {
                tableColumnOptions = new StringBuilder(
                        StringUtils.removeEnd(tableColumnOptions.toString(), ","));
            }

            // merge the aoColumnDefs passed in
            if (!StringUtils.isEmpty(templateOptions.get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS))) {
                String origAoOptions = templateOptions.get(UifConstants.TableToolsKeys.AO_COLUMN_DEFS).trim();
                origAoOptions = StringUtils.removeStart(origAoOptions, "[");
                origAoOptions = StringUtils.removeEnd(origAoOptions, "]");
                tableColumnOptions.append("," + origAoOptions);
            }

            tableColumnOptions.append("]");
            templateOptions.put(UifConstants.TableToolsKeys.AO_COLUMN_DEFS, tableColumnOptions.toString());
        }
    }
}

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

/**
 * Returns the prefix of a nested attribute name, or the empty string if the attribute name is not nested.
 *
 * @param attributeName/*  w  w  w  . j av  a 2s .  com*/
 * @return everything BEFORE the last "." character in attributeName
 */
public static String getNestedAttributePrefix(String attributeName) {
    int lastIndex = PropertyAccessorUtils.getLastNestedPropertySeparatorIndex(attributeName);

    return lastIndex != -1 ? StringUtils.substring(attributeName, 0, lastIndex) : StringUtils.EMPTY;
}

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

/**
 * Builds column options for sorting//ww w . ja  v  a 2s  .c  o m
 *
 * @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.mangelp.fakeSmtpWeb.httpServer.mailBrowser.MailFile.java

/**
 * Returns the content but reduced to a maximum of size-4 characters.
 *
 * If the content text size is over size-4 characters then is cut down to
 * that length and an ellipsis is appended to it.
 *
 * @param size//from   w  ww . j  ava 2  s . co m
 * @return
 */
public String getExcerpt(int size) {
    String content = this.getContent();

    if (content.length() > (size - 4)) {
        content = StringUtils.substring(content, 0, size - 4) + " ...";
    }

    return content;
}

From source file:org.mule.module.netsuite.api.model.expression.Quotes.java

public static String removeQuotes(String quotedString) {
    return StringUtils.substring(quotedString, 1, quotedString.length() - 1);
}

From source file:org.mule.transport.legstar.gen.Samples.java

/**
 * @param serviceName the service name/* w  w w.  j a  v  a 2s  . c o  m*/
 * @param operationPackageName the operation classes package name
 * @return an operation corresponding to a Web Service operation.
 */
private static CixsOperation getMultiStructOperation(final String serviceName,
        final String operationPackageName) {
    CixsOperation cixsOperation = new CixsOperation();
    cixsOperation.setName(serviceName);
    cixsOperation.setCicsProgramName(StringUtils.upperCase(StringUtils.substring(serviceName, 0, 8)));
    cixsOperation.setPackageName(operationPackageName);

    CixsStructure recor1Struc = new CixsStructure();
    recor1Struc.setJaxbType("Record1");
    recor1Struc.setJaxbPackageName("org.mule.transport.legstar.test.jaxb");
    recor1Struc.setCoxbPackageName("org.mule.transport.legstar.test.coxb");
    CixsStructure record2Struc = new CixsStructure();
    record2Struc.setJaxbType("Record2");
    record2Struc.setJaxbPackageName("org.mule.transport.legstar.test.jaxb");
    record2Struc.setCoxbPackageName("org.mule.transport.legstar.test.coxb");

    cixsOperation.addInput(recor1Struc);
    cixsOperation.addInput(record2Struc);
    cixsOperation.addOutput(recor1Struc);
    cixsOperation.addOutput(record2Struc);

    return cixsOperation;
}

From source file:org.musicrecital.service.impl.PasswordTokenManagerImpl.java

private String getTimestamp(final String token) {
    return StringUtils.substring(token, 0, expirationTimeTokenLength);
}

From source file:org.musicrecital.service.impl.PasswordTokenManagerImpl.java

private String getTokenWithoutTimestamp(final String token) {
    return StringUtils.substring(token, expirationTimeTokenLength, token.length());
}