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:hydrograph.ui.expression.editor.composites.CategoriesComposite.java

private void addListnersToClassNameList(final List classNamelist) {
    classNamelist.addSelectionListener(new SelectionListener() {

        @Override/*from  www.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()));
                methodList.removeAll();
                functionSearchTextBox.setEnabled(true);
                if (classDetails != null) {
                    for (MethodDetails methodDetails : classDetails.getMethodList()) {
                        methodList.add(methodDetails.getSignature());
                        methodList.setData(String.valueOf(methodList.getItemCount() - 1), methodDetails);
                        methodList.setData(KEY_FOR_ACCESSING_CLASS_FROM_METHOD_LIST, classDetails);
                    }
                }
                if (functionsComposite != null) {
                    functionsComposite.refresh();
                }
            } else {
                functionSearchTextBox.setEnabled(false);
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            // TODO Auto-generated method stub

        }
    });

}

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.TabDelimitedFileParser.java

/**
 * Loads the tab delimited file into a HashMap containing rows of data.  Row 0 represents the header of the tab delimited file.
 * Each ROW loaded contains the row number (0-based) and a String[] of the values for each row)
 *
 * @param file         the tab delimited file we want to load
 * @param commentToken if the line begins with this, it will be skipped.  may be null for no skipping.
 * @throws IOException when the exception can't be found.
 *//*ww  w .  j a  va  2s.  c o  m*/
public void loadTabDelimitedContent(final File file, final String commentToken,
        final boolean validateColumnsSize) throws IOException, ParseException {

    final Map<Integer, String[]> dataMap = new HashMap<Integer, String[]>();
    final Map<Integer, Integer> allDataLinesMapIncludingComments = new HashMap<Integer, Integer>();
    String dataLine;
    Integer rowCount = 0;
    Integer rowCountCommentEmptyLines = 0;

    FileReader fReader = new FileReader(file);
    @SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed" })
    BufferedReader in = new BufferedReader(fReader);
    int columnCount = -1;
    try {
        while ((dataLine = in.readLine()) != null) {
            //count comment of empty lines also
            if (StringUtils.isEmpty(dataLine.trim()) || StringUtils.startsWith(dataLine, commentToken)) {
                rowCountCommentEmptyLines++;
            }
            // ignore blank lines!
            if (dataLine.trim().length() > 0 && (commentToken == null || !dataLine.startsWith(commentToken))) {
                final String[] rowCols = dataLine.split("\t", -1);
                //Initialize columnCount
                columnCount = (columnCount == -1) ? rowCols.length : columnCount;

                if (validateColumnsSize && (columnCount != rowCols.length)) {
                    throw new ParseException("Error at line no " + rowCount + ": Expected " + columnCount
                            + " columns but found " + rowCols.length + " columns.", rowCols.length);
                }
                dataMap.put(rowCount, rowCols);
                rowCount++;
            }

            //setup the map like this <currentDataLineNum,total no. of commentOrEmptyLines>
            allDataLinesMapIncludingComments.put(rowCount, rowCountCommentEmptyLines);

        }
        getTabDelimitedContent().setTabDelimitedContents(dataMap);
        setCommentAndEmptyLineMap(allDataLinesMapIncludingComments);
    } finally {
        IOUtils.closeQuietly(fReader);
        IOUtils.closeQuietly(in);

        fReader = null;
        in = null;
    }
}

From source file:com.baidu.rigel.biplatform.ac.util.MetaNameUtil.java

/**
 * ?Allname//from w  ww .  j a  v  a 2  s .  com
 * 
 * @param name name
 * @return ?allname
 */
public static boolean isAllMemberName(String name) {
    if (StringUtils.startsWith(name, SUMMARY_MEMBER_NAME_PRE)) {
        return true;
    }
    return false;
}

From source file:com.enitalk.controllers.OpentokSessionController.java

@RequestMapping(method = RequestMethod.GET, value = "/session/student/{id}", produces = "text/html")
@ResponseBody/*from   w ww  . j a  va  2 s  .  c  o  m*/
public byte[] sessionStudent(@PathVariable String id, HttpServletResponse res) throws IOException {

    try {
        byte[] baseUrl = sessionTeacher(id, res, true);
        String url = new String(baseUrl);
        if (!StringUtils.startsWith(url, "events")) {
            return baseUrl;
        }

        Query q = Query.query(Criteria.where("ii").is(id).andOperator(Criteria.where("status").is(2)));
        q.fields().exclude("_id").include("student").include("ii");
        HashMap ev = mongo.findOne(q, HashMap.class, "events");
        ObjectNode evJson = jackson.convertValue(ev, ObjectNode.class);

        //            url += "?dest=" + evJson.at("/student/dest/sendTo").asLong() + "&i=" + evJson.path("ii").asText();
        url += "?dest=" + evJson.at("/student/email").asText() + "&i=" + evJson.path("ii").asText();
        String signed = signer.signUrl(url, new DateTime().plusMinutes(80));
        res.sendRedirect(signed);

    } catch (Exception e) {
        logger.error(ExceptionUtils.getFullStackTrace(e));
        return "Oops.Something went wrong. Contact us at ceo@enitalk.com".getBytes();
    }

    return null;
}

From source file:com.zb.app.web.controller.account.AccountController.java

/**
 * ??/* ww  w  .jav  a 2  s. com*/
 * 
 * @param q
 * @param limit
 * @return
 */
@RequestMapping(value = "/autocompleteCompany.htm", produces = "application/json")
@ResponseBody
public JsonResult autocompleteCompany(String q, Integer limit) {
    List<TravelCompanyDO> list = companyService.list();
    final List<Long> cIdList = orderService
            .getTourCompany(new TravelOrderQuery(WebUserTools.getCid(), OrderStateEnum.CONFIRM));
    if (cIdList == null || cIdList.size() == 0) {
        return JsonResultUtils.success("?!");
    }
    CollectionUtils.remove(list, new Grep<TravelCompanyDO>() {

        @Override
        public boolean grep(TravelCompanyDO comapny) {
            return !cIdList.contains(comapny.getcId());
        }

    });

    List<Map<String, ?>> mapList = CollectionUtils.toMapList(list, "cId", "cName", "cSpell");

    // StringBuilder sb = new StringBuilder();
    String cond = q == null ? StringUtils.EMPTY : q;
    cond = cond.toLowerCase();
    // String temp;
    int maxSize = getLimit(limit);
    int size = 0;

    List<Map<String, ?>> result = new LinkedList<Map<String, ?>>();
    String property = cond.matches("[a-zA-Z]+") ? "cSpell" : "cName";
    for (Map<String, ?> map : mapList) {
        Object cName = null;
        for (Entry<String, ?> entry : map.entrySet()) {
            if (StringUtils.equals(entry.getKey(), property)) {
                cName = entry.getValue();
            }
        }
        if (cond.matches("[a-zA-Z]+") ? StringUtils.startsWith((String) cName, cond)
                : StringUtils.containsIgnoreCase((String) cName, cond)) {
            result.add(map);
            size++;
            if (size > maxSize) {
                break;
            }
        }
    }
    return JsonResultUtils.success(result);
}

From source file:com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter.java

/**
 * Checks if the agent has a valid transport URI set.
 *
 * @param agent Agent to check/*from   ww w .ja v  a2s  .c o  m*/
 * @return true if the Agent's transport URI is in the proper form
 */
private boolean isDispatcherTransportURI(final Agent agent) {
    final String transportURI = agent.getConfiguration().getTransportURI();

    return (StringUtils.startsWith(transportURI, HTTP) || StringUtils.startsWith(transportURI, HTTPS));
}

From source file:com.btobits.automator.fix.comparator.MailComparator.java

public static final String getFixField(final String inName, final SMTPMessage inSmtpMessage) {
    final List<Object> lines = inSmtpMessage.getDataLines();
    int index = 0;
    final String header = inName;
    for (final Object obj : lines) {
        final String val = (String) obj;
        if (!StringUtils.isBlank(val)) {
            if (StringUtils.startsWith(val, header)) {
                break;
            }/*from   w  w  w  .  j a va  2s  . co m*/
        }
        index++;
    }

    if (index == lines.size()) {
        return null;
    }

    final StringBuilder sb = new StringBuilder();
    for (int i = index; i < lines.size(); i++) {
        final String line = lines.get(i) + "";
        if (i == index) {
            sb.append(StringUtils.substringAfter(line, header));
        } else {
            if (StringUtils.isBlank(line)) {
                break; // end email message
            }
            sb.append(line.trim());
        }
    }

    return sb.toString().replaceAll("/u0001", "\u0001");
}

From source file:com.adobe.acs.commons.wcm.notifications.impl.SystemNotificationsImpl.java

@Override
protected boolean accepts(final ServletRequest servletRequest, final ServletResponse servletResponse) {

    if (!(servletRequest instanceof SlingHttpServletRequest)
            || !(servletResponse instanceof SlingHttpServletResponse)) {
        return false;
    }/*from ww  w  .j  ava2  s .com*/

    final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) servletRequest;

    if (StringUtils.startsWith(slingRequest.getResource().getPath(), PATH_NOTIFICATIONS)) {
        // Do NOT inject on the notifications Authoring pages
        return false;
    }

    final Resource notificationsFolder = slingRequest.getResourceResolver().getResource(PATH_NOTIFICATIONS);
    if (notificationsFolder == null || this.getNotifications(slingRequest, notificationsFolder).size() < 1) {
        // If no notifications folder or no active notifications; do not inject JS
        return false;
    }

    return super.accepts(servletRequest, servletResponse);
}

From source file:com.nridge.ds.content.ds_content.ContentExtractor.java

/**
 * Convenience method that returns the value of an application
 * manager configuration property using the concatenation of
 * the property prefix and suffix values.  If the property is
 * not found, then the default value parameter will be returned.
 *
 * @param aSuffix Property name suffix.//from w w  w  . ja  v  a2  s  . c  o  m
 * @param aDefaultValue Default value.
 *
 * @return Matching property value or the default value.
 */
public String getCfgString(String aSuffix, String aDefaultValue) {
    String propertyName;

    if (StringUtils.startsWith(aSuffix, "."))
        propertyName = mCfgPropertyPrefix + aSuffix;
    else
        propertyName = mCfgPropertyPrefix + "." + aSuffix;

    return mAppMgr.getString(propertyName, aDefaultValue);
}

From source file:com.steeleforge.aem.ironsites.wcm.WCMUtil.java

/**
 * Retrieve AEM Page from PageManager based on path
 * //from   w  ww  .j a v a  2  s.  co  m
 * @param request
 * @param path
 * @return Page, null if request or path are empty, or if path doesn't resolve
 */
public static Page getPage(SlingHttpServletRequest request, String path) {
    Page page = null;
    if (null == request) {
        return page;
    }
    ResourceResolver resolver = request.getResourceResolver();
    if (StringUtils.startsWith(path, "/") && null != resolver) {
        PageManager pageManager = resolver.adaptTo(PageManager.class);
        page = pageManager.getContainingPage(path);
        pageManager = null;
    }
    return page;
}