Example usage for com.liferay.portal.kernel.util TextFormatter I

List of usage examples for com.liferay.portal.kernel.util TextFormatter I

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util TextFormatter I.

Prototype

int I

To view the source code for com.liferay.portal.kernel.util TextFormatter I.

Click Source Link

Usage

From source file:com.liferay.util.xml.BeanToXMLUtil.java

License:Open Source License

public static void addFields(Object obj, Element parentEl) {
    Method[] methods = obj.getClass().getMethods();

    for (int i = 0; i < methods.length; i++) {
        Method method = methods[i];

        if (method.getName().startsWith("get") && !method.getName().equals("getClass")) {

            String memberName = StringUtil.replace(method.getName(), "get", StringPool.BLANK);

            memberName = TextFormatter.format(memberName, TextFormatter.I);
            memberName = TextFormatter.format(memberName, TextFormatter.K);

            try {
                Object returnValue = method.invoke(obj, new Object[] {});

                if (returnValue instanceof List<?>) {
                    List<Object> list = (List<Object>) returnValue;

                    Element listEl = parentEl.addElement(memberName);

                    for (int j = 0; j < list.size(); j++) {
                        addBean(list.get(j), listEl);
                    }/*from ww  w.j a va2s . co m*/
                } else {
                    DocUtil.add(parentEl, memberName, returnValue.toString());
                }
            } catch (Exception e) {
                if (_log.isWarnEnabled()) {
                    _log.warn(e.getMessage());
                }
            }
        }
    }
}

From source file:com.liferay.util.xml.BeanToXMLUtil.java

License:Open Source License

public static String getClassNameWithoutPackage(String className) {
    String[] classNameArray = StringUtil.split(className, CharPool.PERIOD);

    String classNameWithoutPackage = classNameArray[classNameArray.length - 1];

    classNameWithoutPackage = TextFormatter.format(classNameWithoutPackage, TextFormatter.I);
    classNameWithoutPackage = TextFormatter.format(classNameWithoutPackage, TextFormatter.K);

    return classNameWithoutPackage;
}