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

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

Introduction

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

Prototype

public static boolean startsWith(String str, String prefix) 

Source Link

Document

Check if a String starts with a specified prefix.

Usage

From source file:jp.primecloud.auto.process.vmware.VmwareCustomizeProcess.java

public void customize(VmwareProcessClient vmwareProcessClient, Long instanceNo) {
    VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo);
    VmwareClient vmwareClient = vmwareProcessClient.getVmwareClient();

    // VirtualMachine
    VirtualMachine machine = vmwareClient.search(VirtualMachine.class, vmwareInstance.getMachineName());
    if (machine == null) {
        // ??????
        throw new AutoException("EPROCESS-000501", vmwareInstance.getMachineName());
    }/*from w ww  .j  a  v  a  2s .  c  o  m*/

    // Windows??OS??
    Instance instance = instanceDao.read(instanceNo);
    Image image = imageDao.read(instance.getImageNo());
    if (StringUtils.startsWith(image.getOs(), PCCConstant.OS_NAME_WIN)) {
        if (log.isInfoEnabled()) {
            log.info(MessageUtils.getMessage("IPROCESS-100464", vmwareInstance.getMachineName()));
        }
        customizeWindows(vmwareProcessClient, vmwareInstance, machine);

        vmwareProcessClient.powerOnVM(vmwareInstance.getMachineName());

        vmwareProcessClient.waitForStopped(vmwareInstance.getMachineName());

        vmwareProcessClient.powerOnVM(vmwareInstance.getMachineName());

        vmwareProcessClient.waitForRunning(vmwareInstance.getMachineName());

        vmwareProcessClient.shutdownGuest(vmwareInstance.getMachineName());

        if (log.isInfoEnabled()) {
            log.info(MessageUtils.getMessage("IPROCESS-100465", vmwareInstance.getMachineName()));
        }
    }

}

From source file:com.kinglcc.spring.jms.core.DestinationType.java

public String getDestinationName(String destinationNameWithType) {
    switch (this) {
    case SHAREDDURABLETOPIC:
        String name = StringUtils.substringAfter(destinationNameWithType, SHARED_PREFIX);
        if (StringUtils.startsWith(name, DURABLE_PREFIX)) {
            return StringUtils.substringAfter(name, DURABLE_PREFIX);
        }//  ww  w  .  ja  v  a 2 s .  c  om
        return name;
    case SHAREDTOPIC:
        return StringUtils.substringAfter(destinationNameWithType, SHARED_PREFIX);
    case DURABLETOPIC:
        return StringUtils.substringAfter(destinationNameWithType, DURABLE_PREFIX);
    case TOPIC:
        return StringUtils.substringAfter(destinationNameWithType, TOPIC_PREFIX);
    default:
        if (StringUtils.startsWith(destinationNameWithType, QUEUE_PREFIX)) {
            return StringUtils.substringAfter(destinationNameWithType, QUEUE_PREFIX);
        }
        return destinationNameWithType;
    }

}

From source file:com.adobe.acs.commons.contentfinder.querybuilder.impl.viewhandler.GQLToQueryBuilderConverter.java

@SuppressWarnings("squid:S3776")
public static Map<String, String> addOrder(final SlingHttpServletRequest request, Map<String, String> map,
        final String queryString) {
    if (has(request, CF_ORDER)) {

        int count = 1;
        for (String value : getAll(request, CF_ORDER)) {
            value = StringUtils.trim(value);
            final String orderGroupId = String.valueOf(GROUP_ORDERBY_USERDEFINED + count) + SUFFIX_ORDERBY;
            boolean sortAsc = false;

            if (StringUtils.startsWith(value, "-")) {
                value = StringUtils.removeStart(value, "-");
            } else if (StringUtils.startsWith(value, "+")) {
                sortAsc = true;//  w  w  w  .j  av a2  s .co  m
                value = StringUtils.removeStart(value, "+");
            }

            map.put(orderGroupId, StringUtils.trim(value));
            map.put(orderGroupId + ".sort", sortAsc ? Predicate.SORT_ASCENDING : Predicate.SORT_DESCENDING);

            count++;
        }

    } else {

        final boolean isPage = isPage(request);
        final boolean isAsset = isAsset(request);
        final String prefix = getPropertyPrefix(request);

        if (StringUtils.isNotBlank(queryString)) {
            map.put(GROUP_ORDERBY_SCORE + SUFFIX_ORDERBY, AT + JcrConstants.JCR_SCORE);
            map.put(GROUP_ORDERBY_SCORE + SUFFIX_ORDERBY_SORT, Predicate.SORT_DESCENDING);
        }

        String modifiedOrderProperty = AT + JcrConstants.JCR_LASTMODIFIED;
        if (isPage) {
            modifiedOrderProperty = AT + prefix + NameConstants.PN_PAGE_LAST_MOD;
        } else if (isAsset) {
            modifiedOrderProperty = AT + prefix + JcrConstants.JCR_LASTMODIFIED;
        }

        map.put(GROUP_ORDERBY_MODIFIED + SUFFIX_ORDERBY, modifiedOrderProperty);
        map.put(GROUP_ORDERBY_MODIFIED + SUFFIX_ORDERBY_SORT, Predicate.SORT_DESCENDING);
    }

    return map;
}

From source file:it.av.eatt.service.impl.JcrApplicationServiceJackrabbit.java

@Transactional
public T insert(T object) throws JackWicketException, UserAlreadyExistsException {
    if (!(StringUtils.startsWith(object.getPath(), basePath))) {
        object.setPath(basePath + object.getPath());
    }//from  w w w .j a v  a2 s.  c om
    jcrMappingtemplate.insert(object);
    jcrMappingtemplate.save();
    jcrMappingtemplate.checkout(object.getPath());
    jcrMappingtemplate.checkin(object.getPath());
    //verify if necessary the save
    jcrMappingtemplate.save();
    jcrMappingtemplate.refresh(true);
    T returnObject = jcrMappingtemplate.getObject(object.getPath());
    returnObject.setVersion(jcrMappingtemplate.getBaseVersion(object.getPath()));
    return returnObject;
}

From source file:com.hangum.tadpole.sql.util.SQLUtil.java

/**
 * ?    ?.//from   www.j a va 2s  .co  m
 *  ? ?? ... -- / ** * / / * * /
 * 
 * @param strSQL
 * @return
 */
public static boolean isNotAllowed(String strSQL) {
    boolean isRet = false;
    strSQL = removeComment(strSQL);

    String cmpSql = StringUtils.trim(strSQL);

    for (String strNAllSQL : NOT_ALLOWED_SQL) {
        if (StringUtils.startsWith(cmpSql.toLowerCase(), strNAllSQL.toLowerCase())) {
            return true;
        }
    }

    return isRet;
}

From source file:com.adobe.acs.commons.forms.impl.FormsRouterImpl.java

@Override
public final boolean hasValidSuffix(final SlingHttpServletRequest slingRequest) {
    final String requestSuffix = slingRequest.getRequestPathInfo().getSuffix();
    if (StringUtils.equals(requestSuffix, this.getSuffix())
            || StringUtils.startsWith(requestSuffix, this.getSuffix() + "/")) {
        return true;
    }/* w w w  .ja  va2s .  co m*/

    return false;
}

From source file:hydrograph.ui.expression.editor.composites.CategoriesComposite.java

private void addSelectionListnerToClassNameList() {
    classNamelist.addSelectionListener(new SelectionListener() {

        @Override/* w  ww .  j  a  v a  2  s . c  o m*/
        public void widgetSelected(SelectionEvent e) {
            if (classNamelist.getItemCount() != 0
                    && !StringUtils.startsWith(classNamelist.getItem(0), Messages.CANNOT_SEARCH_INPUT_STRING)) {
                ClassDetails classDetails = (ClassDetails) classNamelist
                        .getData(String.valueOf(classNamelist.getSelectionIndex()));
                if (classDetails != null && StringUtils.isNotBlank(classDetails.getJavaDoc())) {
                    descriptionStyledText.setText(classDetails.getJavaDoc());
                } else {
                    descriptionStyledText.setText(Messages.JAVA_DOC_NOT_AVAILABLE);
                }
            } else {
                methodList.removeAll();
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {/* Do- nothing */
        }
    });
}

From source file:com.cognifide.slice.core.internal.injector.InjectorsRepositoryService.java

private String getIteratedPath(final String resourcePath) {
    String iteratedPath;//from w w w.  j a v a2 s.  c  o m
    if (!StringUtils.startsWith(resourcePath, InjectorConfig.DEFAULT_INJECTOR_PATH)) {
        iteratedPath = InjectorConfig.DEFAULT_INJECTOR_PATH + resourcePath;
    } else {
        iteratedPath = resourcePath;
    }
    return iteratedPath;
}

From source file:io.kamax.mxisd.config.rest.RestBackendConfig.java

private String buildEndpointUrl(String endpoint) {
    if (StringUtils.startsWith(endpoint, "/")) {
        if (StringUtils.isBlank(getHost())) {
            throw new ConfigurationException("rest.host");
        }//from  w  w w  .ja v a 2s .  c  o m

        try {
            new URL(getHost());
        } catch (MalformedURLException e) {
            throw new ConfigurationException("rest.host", e.getMessage());
        }

        return getHost() + endpoint;
    } else {
        return endpoint;
    }
}

From source file:net.shopxx.interceptor.MerchantInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    if (modelAndView != null) {
        String viewName = modelAndView.getViewName();
        if (!StringUtils.startsWith(viewName, REDIRECT_VIEW_NAME_PREFIX)) {
            modelAndView.addObject(MERCHANT_ATTRIBUTE_NAME, merchantService.getCurrent());
        }//from www.j a  va  2  s .c  om
    }
}