Example usage for org.apache.commons.lang3 StringUtils stripToNull

List of usage examples for org.apache.commons.lang3 StringUtils stripToNull

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils stripToNull.

Prototype

public static String stripToNull(String str) 

Source Link

Document

Strips whitespace from the start and end of a String returning null if the String is empty ("") after the strip.

This is similar to #trimToNull(String) but removes whitespace.

Usage

From source file:org.drombler.acp.core.action.spi.ToolBarDescriptor.java

public static <T, B> ToolBarDescriptor createToolBarDescriptor(ToolBarType toolBarType, Bundle bundle,
        ToolBarContainer<T, B> toolBarContainer) {
    ToolBarDescriptor toolBarDescriptor = new ToolBarDescriptor();

    toolBarDescriptor.setId(StringUtils.stripToNull(toolBarType.getId()));
    toolBarDescriptor.setDisplayName(OSGiResourceBundleUtils
            .getPackageResourceStringPrefixed(toolBarType.getPackage(), toolBarType.getDisplayName(), bundle));
    toolBarDescriptor.setPosition(toolBarType.getPosition());
    toolBarDescriptor.setVisible(toolBarType.isVisible());
    ToggleActionDescriptor actionDescriptor = createShowToolBarActionDescriptor(toolBarDescriptor,
            toolBarContainer);//from w  ww  .j a  va 2s  . c o m
    toolBarDescriptor.setShowToolBarActionDescriptor(actionDescriptor);
    toolBarDescriptor.setShowToolBarCheckMenuEntryDescriptor(new ToggleMenuEntryDescriptor(
            actionDescriptor.getId(), "View/Toolbars", toolBarType.getPosition()));
    return toolBarDescriptor;
}

From source file:org.drombler.acp.core.action.spi.ToolBarEntryDescriptor.java

public static ToolBarEntryDescriptor createToolBarEntryDescriptor(ToolBarEntryType toolBarEntryType) {
    return new ToolBarEntryDescriptor(StringUtils.stripToNull(toolBarEntryType.getActionId()),
            StringUtils.stripToNull(toolBarEntryType.getToolBarId()), toolBarEntryType.getPosition());
}

From source file:org.drombler.acp.core.action.spi.ToolBarToggleEntryDescriptor.java

public static ToolBarToggleEntryDescriptor createToolBarToggleEntryDescriptor(
        ToolBarToggleEntryType toolBarEntryType) {
    return new ToolBarToggleEntryDescriptor(StringUtils.stripToNull(toolBarEntryType.getActionId()),
            StringUtils.stripToNull(toolBarEntryType.getToolBarId()), toolBarEntryType.getPosition(),
            StringUtils.stripToNull(toolBarEntryType.getToggleGroupId()));
}

From source file:org.drombler.acp.core.docking.impl.DockingAnnotationProcessor.java

private void registerViewDocking(ViewDocking dockingAnnotation, Element element) {
    init(element);//from ww  w .  j  a  va  2 s . c o  m

    ViewDockingType docking = new ViewDockingType();
    configureDocking(docking, element, dockingAnnotation.areaId(), dockingAnnotation.icon(),
            dockingAnnotation.state());

    docking.setPosition(dockingAnnotation.position());
    //        docking.setSingleton(dockingAnnotation.singleton());
    docking.setDisplayName(StringUtils.stripToNull(dockingAnnotation.displayName()));
    docking.setAccelerator(StringUtils.stripToNull(dockingAnnotation.accelerator()));
    docking.setResourceBundleBaseName(StringUtils.stripToNull(dockingAnnotation.resourceBundleBaseName()));

    WindowMenuEntryType windowMenuEntry = new WindowMenuEntryType();
    windowMenuEntry.setPosition(dockingAnnotation.menuEntry().position());
    windowMenuEntry.setPath(StringUtils.stripToNull(dockingAnnotation.menuEntry().path()));
    docking.setMenuEntry(windowMenuEntry);

    dockings.getViewDocking().add(docking);
}

From source file:org.drombler.acp.core.docking.impl.DockingAnnotationProcessor.java

private void configureDocking(AbstractDockingType docking, Element element, String areaId, String icon,
        DockingState dockingState) {/*from  w w  w.j av a 2 s .co  m*/
    docking.setId(element.asType().toString());
    docking.setAreaId(StringUtils.stripToNull(areaId));
    docking.setIcon(StringUtils.stripToNull(icon));
    docking.setState(DOCKING_STATES.get(dockingState));
    docking.setDockableClass(element.asType().toString());
}

From source file:org.drombler.acp.core.docking.impl.DockingAreaAnnotationProcessor.java

private void registerDockingArea(DockingArea dockingAreaAnnotation, Element element) {
    init(element);/*from w ww  . j a v  a2  s  . c  o  m*/

    DockingAreaType dockingArea = new DockingAreaType();
    dockingArea.setId(StringUtils.stripToNull(dockingAreaAnnotation.id()));
    dockingArea.setKind(DOCKING_AREA_KINDS.get(dockingAreaAnnotation.kind()));
    dockingArea.setPosition(dockingAreaAnnotation.position());
    dockingArea.setPermanent(dockingAreaAnnotation.permanent());
    DockingAreaPathsType paths = new DockingAreaPathsType();
    for (int path : dockingAreaAnnotation.path()) {
        paths.getPath().add(path);
    }
    dockingArea.setPaths(paths);

    LayoutConstraintsType layoutConstraints = new LayoutConstraintsType();
    layoutConstraints.setPrefWidth(dockingAreaAnnotation.layoutConstraints().prefWidth());
    layoutConstraints.setPrefHeight(dockingAreaAnnotation.layoutConstraints().prefHeight());
    dockingArea.setLayoutConstraints(layoutConstraints);

    dockingAreas.getDockingArea().add(dockingArea);
}

From source file:org.drombler.acp.core.docking.spi.DockingAreaDescriptorUtils.java

public static DockingAreaDescriptor createDockingAreaDescriptor(DockingAreaType dockingArea) {
    DockingAreaDescriptor dockingAreaDescriptor = new DockingAreaDescriptor();
    dockingAreaDescriptor.setId(StringUtils.stripToNull(dockingArea.getId()));
    dockingAreaDescriptor.setKind(DOCKING_AREA_KINDS.get(dockingArea.getKind()));
    dockingAreaDescriptor.setPosition(dockingArea.getPosition());
    dockingAreaDescriptor.setParentPath(new ArrayList<>(dockingArea.getPaths().getPath()));
    dockingAreaDescriptor.setPermanent(dockingArea.isPermanent());
    dockingAreaDescriptor.setLayoutConstraints(LayoutConstraintsDescriptorUtils
            .createLayoutConstraintsDescriptor(dockingArea.getLayoutConstraints()));
    return dockingAreaDescriptor;
}

From source file:org.drombler.acp.core.docking.spi.DockingDescriptorUtils.java

public static void configureDockingDescriptor(AbstractDockableDockingDescriptor dockingDescriptor,
        AbstractDockingType dockingType, Bundle bundle) throws ClassNotFoundException {
    final Class<?> dockableClass = bundle.loadClass(StringUtils.stripToNull(dockingType.getDockableClass()));
    dockingDescriptor.setId(StringUtils.stripToNull(dockingType.getId()));
    dockingDescriptor.setIcon(StringUtils.stripToNull(dockingType.getIcon()));
    dockingDescriptor.setAreaId(StringUtils.stripToNull(dockingType.getAreaId()));
    dockingDescriptor.setDockableClass(dockableClass);
    dockingDescriptor.setResourceLoader(new ResourceLoader(dockableClass));
}

From source file:org.drombler.commons.client.util.ResourceBundleUtils.java

public static ResourceBundle getResourceBundle(Class<?> type, String resourceBundleBaseName,
        String resourceKey) {// ww w .j a v  a 2 s  . c  om
    ResourceBundle resourceBundle = null;
    if (isPrefixedResourceString(resourceKey)) {
        resourceBundleBaseName = StringUtils.stripToNull(resourceBundleBaseName);
        if (resourceBundleBaseName == null) {
            resourceBundle = getClassResourceBundle(type);
        } else if (resourceBundleBaseName.equals(PACKAGE_RESOURCE_BUNDLE_BASE_NAME)) {
            resourceBundle = getPackageResourceBundle(type);
        } else {
            resourceBundle = getResourceBundle(resourceBundleBaseName, type.getClassLoader());
        }
    }
    return resourceBundle;
}

From source file:org.drombler.commons.client.util.ResourceBundleUtils.java

private static String getResourceStringPrefixed(String resourceKey, String aPackage, String baseName,
        ClassLoader classLoader) {
    String strippedResourceKey = StringUtils.stripToNull(resourceKey);
    if (isPrefixedResourceString(strippedResourceKey)) {
        ResourceBundle rb = getResourceBundle(aPackage, baseName, classLoader);
        return getResourceStringPrefixed(resourceKey, rb);
    }//w w w  .  j a  va 2  s  .co m
    return resourceKey;
}