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

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

Introduction

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

Prototype

public static String capitalize(String str) 

Source Link

Document

Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .

Usage

From source file:com.netxforge.netxstudio.models.export.MasterDataExporterRevenge_sxssf.java

private void _generateMultiReferenceSource(EClass eClass, Sheet sheet) {
    // Generate name.
    {//from   w  w w .ja va2  s . c  o m
        // Style, cell color.
        CellStyle referenceStyle = workBook.createCellStyle();
        referenceStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        referenceStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

        // Style, font
        Font referenceFont = workBook.createFont();
        referenceFont.setFontName("Verdana");
        referenceFont.setColor(IndexedColors.DARK_RED.getIndex());
        referenceStyle.setFont(referenceFont);

        // Style, border.
        referenceStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);

        Row row = sheet.getRow(0);
        if (row == null) {
            row = sheet.createRow(0);
        }
        short lastCellNum = row.getLastCellNum();
        if (lastCellNum == -1) {
            lastCellNum = 0;
        }
        Cell cell = row.createCell(lastCellNum);
        cell.setCellValue(StringUtils.capitalize(eClass.getName()));
        cell.setCellStyle(referenceStyle);
    }
    // Generate type
    {

        CellStyle typeStyle = workBook.createCellStyle();
        typeStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);

        Row row = sheet.getRow(1);
        if (row == null) {
            row = sheet.createRow(1);
        }
        short lastCellNum = row.getLastCellNum();
        if (lastCellNum == -1) {
            lastCellNum = 0;
        }
        Cell cell = row.createCell(lastCellNum);
        cell.setCellStyle(typeStyle);
    }
}

From source file:com.netxforge.netxstudio.models.export.MasterDataExporterRevenge.java

private void _generateMultiRefCell(EReference eReference, Sheet sheet) {

    // Generate name.
    {/*from   w w  w . j a v  a 2s  . c  o  m*/
        // Style, cell color.
        CellStyle referenceStyle = workBook.createCellStyle();
        referenceStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        referenceStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

        // Style, font
        HSSFFont referenceFont = workBook.createFont();
        referenceFont.setFontName("Verdana");
        referenceFont.setColor(HSSFColor.DARK_RED.index);
        referenceStyle.setFont(referenceFont);

        // Style, border.
        referenceStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);

        Row row = sheet.getRow(0);
        if (row == null) {
            row = sheet.createRow(0);
        }
        short lastCellNum = row.getLastCellNum();
        if (lastCellNum == -1) {
            lastCellNum = 0;
        }
        Cell cell = row.createCell(lastCellNum);
        cell.setCellValue(StringUtils.capitalize(eReference.getName()));
        cell.setCellStyle(referenceStyle);
    }
    // Generate type
    {

        CellStyle typeStyle = workBook.createCellStyle();
        typeStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);

        Row row = sheet.getRow(1);
        if (row == null) {
            row = sheet.createRow(1);
        }
        short lastCellNum = row.getLastCellNum();
        if (lastCellNum == -1) {
            lastCellNum = 0;
        }
        Cell cell = row.createCell(lastCellNum);
        cell.setCellValue(eReference.getEType().getName());
        cell.setCellStyle(typeStyle);
    }
}

From source file:mrcg.MRCGInstance.java

private JavaField buildField(JavaClass jclass, String fieldName, String def, Visibility visibility) {
    String[] parts = splitFieldDef(def);
    LinkedHashSet<String> set = new LinkedHashSet<String>(Arrays.asList(parts));
    JavaField field = null;//ww  w  . jav  a2s  .co m
    if ("references".equals(parts[0])) {
        field = addReferenceProperty(fieldName, jclass, getType(parts[1]), parts);
        //         field.setLabel(StringUtils.toSpacedCamelCase(field.getReferences().getName()));
        field.setLabel(Utils.toSpacedCamelCase(StringUtils.capitalize(fieldName)));
    } else {
        String type = parts[0];
        int i = type.indexOf("(");
        Integer[] scale = null;
        if (i > 0) {
            scale = getScale(type.substring(i));
            type = type.substring(0, i);
        }

        field = new JavaField();
        field.setName(fieldName);

        if (scale != null) {
            field.setMinLength(scale[0]);
            field.setMaxLength(scale[1]);
        }

        // string, text, numeric, long, date
        if ("string".equals(type)) {
            if (scale == null) {
                throw new IllegalArgumentException("Type [string] requires scale");
            }
            field.setType(JavaType.STRING);
            field.setDbType(DBType.Varchar);
        } else if ("text".equals(type)) {
            field.setType(JavaType.STRING);
            field.setDbType(DBType.Text);
        } else if ("double".equals(type)) {
            field.setType(JavaType.DOUBLE);
            field.setDbType(DBType.DoublePrecision);
        } else if ("numeric".equals(type)) {
            if (scale == null) {
                throw new IllegalArgumentException("Type [numeric] requires scale");
            }
            field.setType(JavaType.DOUBLE);
            field.setDbType(DBType.Double);
        } else if ("money".equals(type)) {
            scale = new Integer[] { 8, 2 };
            field.setMinLength(8);
            field.setMaxLength(2);
            field.setType(JavaType.DOUBLE);
            field.setDbType(DBType.Double);
        } else if ("int".equals(type) || "integer".equals(type)) {
            field.setType(JavaType.INTEGER);
            field.setDbType(DBType.Integer);
        } else if ("long".equals(type)) {
            field.setType(JavaType.LONG);
            field.setDbType(DBType.Long);
        } else if ("date".equals(type)) {
            field.setType(getDateType());
            field.setDbType(DBType.Date);
        } else if ("justdate".equals(type)) {
            field.setType(getDateType());
            field.setDbType(DBType.JustDate);
        } else if ("boolean".equals(type)) {
            field.setType(JavaType.BOOLEAN);
            field.setDbType(DBType.Boolean);
        } else if ("time".equals(type)) {
            field.setType(getDateType());
            field.setDbType(DBType.Time);
        } else if ("email".equals(type)) {
            field.setType(JavaType.EMAIL);
            field.setDbType(DBType.Varchar);
            if (scale == null) {
                throw new IllegalArgumentException("Type [email] requires scale");
            }
        } else if ("binary".equals(type)) {
            field.setType(JavaType.BINARY);
            field.setDbType(DBType.Binary);
        } else {
            throw new IllegalArgumentException("Type [" + type + "] is not currently supported ["
                    + jclass.getName() + "." + fieldName + ": " + def + "]");
        }

        Utils.createBeanProperty(jclass, field, true);
    }

    field.setVisibility(visibility);

    if (set.contains("label")) {
        field.setLabel(getItemAfter(set, "label"));
    }

    if (set.contains("default")) {
        field.setDefaultValue(getItemAfter(set, "default"));
    }

    field.setEncrypted(set.contains("encrypted"));

    if (field != null) {
        field.setOnList(set.contains("list"));
        field.setOnView(!set.contains("noview"));
        field.setRequired(!set.contains("null"));
        field.setUnique(set.contains("unique"));
        field.setIdentifier(set.contains("identifier"));
        field.setOrder(set.contains("order"));
    }

    if (set.contains("index") || set.contains("indexed")) {
        field.setIndexed(true);
    }

    return field;

}

From source file:com.netxforge.netxstudio.models.export.MasterDataExporterRevenge_sxssf.java

private void _generateMultiRefCell(EReference eReference, Sheet sheet) {

    // Generate name.
    {//w w w  .j  a  v  a2  s . c o m
        // Style, cell color.
        CellStyle referenceStyle = workBook.createCellStyle();
        referenceStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        referenceStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

        // Style, font
        Font referenceFont = workBook.createFont();
        referenceFont.setFontName("Verdana");
        referenceFont.setColor(IndexedColors.DARK_RED.getIndex());
        referenceStyle.setFont(referenceFont);

        // Style, border.
        referenceStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);

        Row row = sheet.getRow(0);
        if (row == null) {
            row = sheet.createRow(0);
        }
        short lastCellNum = row.getLastCellNum();
        if (lastCellNum == -1) {
            lastCellNum = 0;
        }
        Cell cell = row.createCell(lastCellNum);
        cell.setCellValue(StringUtils.capitalize(eReference.getName()));
        cell.setCellStyle(referenceStyle);
    }
    // Generate type
    {

        CellStyle typeStyle = workBook.createCellStyle();
        typeStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);

        Row row = sheet.getRow(1);
        if (row == null) {
            row = sheet.createRow(1);
        }
        short lastCellNum = row.getLastCellNum();
        if (lastCellNum == -1) {
            lastCellNum = 0;
        }
        Cell cell = row.createCell(lastCellNum);
        cell.setCellValue(eReference.getEType().getName());
        cell.setCellStyle(typeStyle);
    }
}

From source file:com.bstek.dorado.idesupport.initializer.CommonRuleTemplateInitializer.java

protected List<AutoChildTemplate> getChildTemplatesBySubNode(RuleTemplate ruleTemplate, TypeInfo typeInfo,
        String propertyName, XmlSubNode xmlSubNode, TypeInfo propertyTypeInfo,
        InitializerContext initializerContext) throws Exception {
    List<AutoChildTemplate> childTemplates = new ArrayList<AutoChildTemplate>();

    boolean aggregated = xmlSubNode.aggregated();
    Class<?> propertyType = null;
    if (propertyTypeInfo != null) {
        propertyType = propertyTypeInfo.getType();
        aggregated = propertyTypeInfo.isAggregated();
    }/*w  w  w.  j  av a 2  s .c o m*/

    Set<Class<?>> implTypes = ClassUtils.findClassTypes(xmlSubNode.implTypes(), propertyType);
    for (Class<?> implType : implTypes) {
        if (implType.equals(typeInfo.getType())) {
            continue;
        }

        boolean isPublic = true;
        XmlNode implXmlNode = implType.getAnnotation(XmlNode.class);
        if (implXmlNode != null && ArrayUtils.indexOf(implType.getDeclaredAnnotations(), implXmlNode) >= 0
                && !implXmlNode.isPublic()) {
            if (ArrayUtils.indexOf(xmlSubNode.implTypes(), implType.getName()) < 0) {
                continue;
            } else {
                isPublic = false;
            }
        }

        AutoChildTemplate childTemplate = getChildNodeByBeanType(null, xmlSubNode, aggregated, implType,
                "protected", initializerContext);
        if (childTemplate != null) {
            childTemplate.setPublic(isPublic);
            childTemplates.add(childTemplate);
        }
    }

    if (propertyType != null) {
        XmlNode implXmlNode = propertyType.getAnnotation(XmlNode.class);
        if (implXmlNode == null || implXmlNode.isPublic()) {
            AutoChildTemplate childTemplate = getChildNodeByBeanType(StringUtils.capitalize(propertyName),
                    xmlSubNode, aggregated, propertyType, null, initializerContext);
            if (childTemplate != null) {
                childTemplates.add(childTemplate);
            }
        }
    }

    XmlNodeWrapper wrapper = xmlSubNode.wrapper();
    String wrapperName = wrapper.nodeName();
    if (StringUtils.isNotEmpty(wrapperName)) {
        List<AutoChildTemplate> wrapperTemplates = new ArrayList<AutoChildTemplate>();
        AutoRuleTemplate wrapperRuleTemplate = new AutoRuleTemplate("Wrapper." + wrapper.nodeName());
        wrapperRuleTemplate.setLabel(StringUtils.defaultIfEmpty(wrapper.label(), wrapper.nodeName()));
        if (StringUtils.isNotEmpty(wrapper.icon())) {
            wrapperRuleTemplate.setIcon(wrapper.icon());
        }
        wrapperRuleTemplate.setNodeName(wrapper.nodeName());
        for (ChildTemplate childTemplate : childTemplates) {
            wrapperRuleTemplate.addChild(childTemplate);
        }

        AutoChildTemplate wrapperChildTemplate = new AutoChildTemplate(wrapperName, wrapperRuleTemplate,
                xmlSubNode);
        wrapperChildTemplate.setFixed(wrapper.fixed());
        wrapperTemplates.add(wrapperChildTemplate);
        return wrapperTemplates;
    } else {
        return childTemplates;
    }
}

From source file:com.flexive.shared.scripting.groovy.GroovyTypeBuilder.java

/**
 * Refactorisation of PropertyNode creation
 *
 * @param am the ATtributeMapper//from ww  w.j  a  va  2s . c o  m
 * @return returns a new PropertyNode
 * @throws FxApplicationException on errors
 */
private Object createNewPropertyNode(AttributeMapper am) throws FxApplicationException {
    final FxPropertyEdit property = FxPropertyEdit.createNew(StringUtils.capitalize(am.elementName), am.label,
            am.hint, am.multiplicity, am.acl, am.dataType);
    am.setPropertyAttributes(property); // set property attributes

    if (this.getCurrent() instanceof GroupAssignmentNode) {
        final GroupAssignmentNode node = (GroupAssignmentNode) getCurrent(); // retrieve the parent
        return new PropertyNode(property, am.alias, type.getId(), node.getElement().getXPath());

    } else
        return new PropertyNode(property, am.alias, type.getId());
}

From source file:com.pari.reports.request.handlers.ManageExportHandlerImpl.java

private void processGroups(ColumnDefinition[] colDef, ServiceContainerImpl serviceContainer, String category,
        LWObjectGroup group, int level) {
    ServiceImpl service;//from w  w  w. j a v  a2s  .c om
    if (group != null) {
        service = new ServiceImpl();

        String name = group.getGroupName();

        for (int i = 0; i < level; i++) {
            if (i == 0) {
                name = " " + name;
            }
            name = "----" + name;
        }

        service.put(colDef[0].getId(), name);
        service.put(colDef[1].getId(), category);
        String customerName = getRequestDetails().getServerIf().getCustomerIf()
                .getCustomerNameById(group.getCustomerId());
        customerName = (null == customerName) ? "All Customers" : customerName;
        service.put(colDef[2].getId(), customerName);

        String type = null;
        if (group.isSystemGroup()) {
            type = "System";
        } else if (group.isCustomerGroup()) {
            type = "Customer";
        } else {
            type = "User Defined";
        }
        service.put(colDef[3].getId(), type);
        if (group.isDynamicGroup()) {
            service.put(colDef[4].getId(),
                    StringUtils.capitalize(DeviceGroupMembership.DYNAMIC.name().toLowerCase()));

        } else {
            service.put(colDef[4].getId(),
                    StringUtils.capitalize(DeviceGroupMembership.STATIC.name().toLowerCase()));
        }

        service.put(colDef[5].getId(), getMembers(group).size());
        service.put(colDef[6].getId(), group.getCreatedBy());
        service.put(colDef[7].getId(), group.getGroupDescription());
        serviceContainer.addManageServices(service);

        if (group.getChildren() != null) {
            for (LWObjectGroup child : group.getChildren()) {
                processGroups(colDef, serviceContainer, category, child, level + 1);
            }
        }
    }
}

From source file:com.haulmont.cuba.core.sys.MetaModelLoader.java

protected MetadataObjectInfo<Range> loadRange(MetaProperty metaProperty, Class<?> type,
        Map<String, Object> map) {
    Datatype datatype = (Datatype) map.get("datatype");
    if (datatype != null) {
        // A datatype is assigned explicitly
        return new MetadataObjectInfo<>(new DatatypeRange(datatype));
    }/* w w w . ja  v a  2 s. c  o  m*/

    datatype = getAdaptiveDatatype(metaProperty, type);
    if (datatype == null) {
        datatype = datatypes.get(type);
    }
    if (datatype != null) {
        MetaClass metaClass = metaProperty.getDomain();
        Class javaClass = metaClass.getJavaClass();

        try {
            String name = "get" + StringUtils.capitalize(metaProperty.getName());
            Method method = javaClass.getMethod(name);

            Class<Enum> returnType = (Class<Enum>) method.getReturnType();
            if (returnType.isEnum()) {
                return new MetadataObjectInfo<>(new EnumerationRange(new EnumerationImpl<>(returnType)));
            }
        } catch (NoSuchMethodException e) {
            // ignore
        }
        return new MetadataObjectInfo<>(new DatatypeRange(datatype));

    } else if (type.isEnum()) {
        return new MetadataObjectInfo<>(new EnumerationRange(new EnumerationImpl(type)));

    } else {
        return new MetadataObjectInfo<>(null,
                Collections.singletonList(new RangeInitTask(metaProperty, type, map)));
    }
}

From source file:mrcg.MRCGInstance.java

private JavaField addReferenceProperty(String fieldName, JavaClass jclass, JavaClass refClass, String[] parts) {
    JavaField jfield = null;//from w w w  .  j  a  v a2 s.  com
    if (refClass.isEnum()) {
        fieldName = StringUtils.capitalize(fieldName);

        jfield = new JavaField(refClass.getJavaType(), StringUtils.uncapitalize(fieldName) + "Code");
        if (new HashSet<String>(Arrays.asList(parts)).contains("nocode")) {
            jfield = new JavaField(refClass.getJavaType(), StringUtils.uncapitalize(fieldName));
        }
        jfield.setDbType(DBType.Varchar);
        jfield.setMaxLength(((JavaEnum) refClass).getMaxCodeLength());
    } else {
        fieldName = StringUtils.capitalize(fieldName);

        // refClass.getName()
        jfield = new JavaField(JavaType.LONG, StringUtils.uncapitalize(fieldName) + "Id");
        jfield.setDbType(DBType.Long);
        jfield.setRequired(true);

        // refClass.getName()
        String field2name = StringUtils.uncapitalize(fieldName);
        JavaField jfield2 = new JavaField(refClass.getJavaType(), field2name);
        jfield2.setAutoHandledField(true);
        jfield2.setDatabaseField(false);
        jclass.addField(jfield2);

        // jclass.getReferencedObject()
        jclass.addImport(JavaType.LOGIC_FACADE);
        JavaMethod jmethod = new JavaMethod(refClass.getJavaType(), "get" + fieldName);
        jmethod.setBody("\t\t" + field2name + " = (" + field2name + " == null)?"
                + JavaType.LOGIC_FACADE.getJustClassName() + ".get(" + refClass.getName() + ".class, "
                + jfield.getName() + "):" + field2name + ";\n\t\treturn " + field2name + ";");
        jclass.addMethod(jmethod);

        // if 'unique' add singular, else plural

        // refClass.getRefererObjects()
        String name = jclass.getName();
        //         if (fieldName != null) {
        //            name = fieldName;
        //         }
        //         String name = (fieldName == null)?jclass.getName():fieldName;

        if (isReverseReferenceEnabled(refClass.getName())) {
            refClass.addImport(JavaType.LOGIC_FACADE);
            JavaType jtl = new JavaType("java.util.List");
            jtl.addType(jclass.getJavaType());
            jmethod = new JavaMethod(jtl, "get" + Utils.pluralize(name));
            jmethod.setBody(
                    "\t\treturn " + JavaType.LOGIC_FACADE.getJustClassName() + ".list(" + jclass.getName()
                            + ".class, \"" + Utils.toDatabaseFormat(refClass.getName()) + "_id\", getId());");
            refClass.addMethod(jmethod);
        }

    }
    jfield.setReferences(refClass);
    Utils.createBeanProperty(jclass, jfield, true);
    return jfield;

}

From source file:ch.cyberduck.core.Preferences.java

/**
 * @param locale ISO Language identifier
 * @return Human readable language name in the target language
 *//*w  w w . j ava2  s  . c  o  m*/
public String getDisplayName(String locale) {
    java.util.Locale l;
    if (StringUtils.contains(locale, "_")) {
        l = new java.util.Locale(locale.split("_")[0], locale.split("_")[1]);
    } else {
        l = new java.util.Locale(locale);
    }
    return StringUtils.capitalize(l.getDisplayName(l));
}