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

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

Introduction

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

Prototype

public static String substringAfter(String str, String separator) 

Source Link

Document

Gets the substring after the first occurrence of a separator.

Usage

From source file:com.microsoft.exchange.autodiscover.AbstractExchangeAutodiscoverService.java

protected String extractDomainFromEmail(String email) throws AutodiscoverException {
    EmailValidator validator = EmailValidator.getInstance(false);
    if (StringUtils.isNotBlank(email) && validator.isValid(email)) {
        String domain = StringUtils.substringAfter(email, "@");
        if (StringUtils.isNotBlank(domain)) {
            return domain;
        }//from   w ww .  j  a va  2 s  .  c  o m
    }
    throw new AutodiscoverException("INVALID EMAIL: " + email);
}

From source file:com.amalto.core.history.accessor.AttributeAccessor.java

private QName getQName(Document domDocument) {
    QName qName;/*  w  w  w .  j  av a 2s  .c o  m*/
    String prefix = StringUtils.substringBefore(attributeName, ":"); //$NON-NLS-1$
    String name = StringUtils.substringAfter(attributeName, ":"); //$NON-NLS-1$
    if (name.isEmpty()) {
        // No prefix (so prefix is attribute name due to substring calls).
        String attributeNamespaceURI = domDocument.getDocumentURI();
        if (attributeNamespaceURI == null || attributeNamespaceURI.isEmpty()) {
            Node attributeNode = getAttributeNode(domDocument);
            if (attributeNode != null) {
                attributeNamespaceURI = attributeNode.getNamespaceURI();
            }
        }
        qName = new QName(attributeNamespaceURI, prefix);
    } else {
        String attributeNamespaceURI = domDocument.lookupNamespaceURI(prefix);
        if (attributeNamespaceURI == null || attributeNamespaceURI.isEmpty()) {
            Node attributeNode = getAttributeNode(domDocument);
            if (attributeNode != null) {
                attributeNamespaceURI = attributeNode.lookupNamespaceURI(prefix);
            }
        }
        qName = new QName(attributeNamespaceURI, name, prefix);
    }
    return qName;
}

From source file:adalid.util.i18n.Mapper.java

private String locale(String name) {
    String substringBeforeLast = StringUtils.substringBeforeLast(name, ".");
    String substringAfter = StringUtils.substringAfter(substringBeforeLast, "_");
    return StringUtils.trimToNull(substringAfter);
}

From source file:de.tudarmstadt.ukp.csniper.webapp.search.cqp.CqpQuery.java

/**
 * Constructs a CQPManager.//from   w w w  .j  a v  a  2s.  co m
 */
public CqpQuery(CqpEngine aEngine, String aType, String aCorpus) {
    engine = aEngine;
    type = aType;
    corpus = aCorpus;

    if (corpus == null) {
        throw new InvalidDataAccessResourceUsageException("Corpus cannot be null.");
    }
    error = new ArrayList<String>();

    cqpProcess = getCQPProcess();

    // -- set obligatory options --
    // corpus
    List<String> output = exec(corpus);
    if (output.size() > 0) {
        version = StringUtils.substringAfter(output.get(0), CQP_VERSION_PREFIX);
    }
    // add macro definitions
    if (engine.getMacrosLocation() != null) {
        setMacrosLocation(engine.getMacrosLocation());
    }
    // set default delimiters (can be changed)
    setLeftDelim(leftDelim);
    setRightDelim(rightDelim);
    // show positional attributes
    send("show +" + ATTR_BEGIN);
    send("show +" + ATTR_END);
    send("set PrintStructures \"" + E_TEXT + "_" + ATTR_ID + "\"");
    // activate progressbar (essential, because we stop reading at EOL, which occurs after
    // the progress messages
    send("set ProgressBar on");
}

From source file:eionet.meta.service.TableServiceImpl.java

/**
 * {@inheritDoc}//from  w w w.  jav  a  2s . c om
 */
@Override
public List<DataSetTable> getTablesForObligation(String obligationId, boolean releasedOnly)
        throws ServiceException {

    List<DataSet> datasets = new ArrayList<DataSet>();
    try {
        DatasetFilter datasetFilter = new DatasetFilter();
        if (releasedOnly) {
            datasetFilter.setRegStatuses(Arrays.asList(DatasetRegStatus.RELEASED.toString()));
        } else {
            datasetFilter.setRegStatuses(
                    Arrays.asList(DatasetRegStatus.RELEASED.toString(), DatasetRegStatus.RECORDED.toString()));
        }
        // Search datasets by ROD numeric IDs from DST2ROD table
        if (obligationId.startsWith(Props.getRequiredProperty(PropsIF.OUTSERV_ROD_OBLIG_URL))) {
            int rodId = NumberUtils.toInt(StringUtils.substringAfter(obligationId,
                    Props.getRequiredProperty(PropsIF.OUTSERV_ROD_OBLIG_URL)));
            if (rodId > 0) {
                List<Integer> rodIds = new ArrayList<Integer>();
                rodIds.add(Integer.valueOf(rodId));
                datasetFilter.setRodIds(rodIds);
            }
            // search datasets
            List<DataSet> datasets1 = datasetDAO.searchDatasets(datasetFilter);
            datasets.addAll(datasets1);
            datasetFilter.setRodIds(null);
        }

        // Search datasets by ROD URLs stored in complex attributes
        ComplexAttribute rodAttr = attributeDAO.getComplexAttributeByName("ROD");
        ComplexAttributeField field = rodAttr.getField("url");
        if (field != null) {
            field.setValue(obligationId);
            field.setExactMatchInSearch(true);
        }
        List<ComplexAttribute> complexAttributes = new ArrayList<ComplexAttribute>();
        complexAttributes.add(rodAttr);
        datasetFilter.setComplexAttributes(complexAttributes);

        // search datasets
        List<DataSet> datasets2 = datasetDAO.searchDatasets(datasetFilter);
        datasets.addAll(datasets2);

        if (datasets != null && datasets.size() > 0) {
            return tableDAO.listForDatasets(datasets);
        } else {
            return new ArrayList<DataSetTable>();
        }
    } catch (Exception e) {
        throw new ServiceException("Failed to search tables for obligation: " + e.getMessage(), e);
    }
}

From source file:at.grahsl.kafka.connect.mongodb.MongoDbSinkTask.java

@Override
public void put(Collection<SinkRecord> records) {

    if (records.isEmpty()) {
        LOGGER.debug("no sink records to process for current poll operation");
        return;/*  w w w . ja  v  a2 s.  co  m*/
    }

    Map<String, MongoDbSinkRecordBatches> batchMapping = createSinkRecordBatchesPerTopic(records);

    batchMapping.forEach((namespace, batches) -> {

        String collection = StringUtils.substringAfter(namespace,
                MongoDbSinkConnectorConfig.MONGODB_NAMESPACE_SEPARATOR);

        batches.getBufferedBatches().forEach(batch -> {
            processSinkRecords(cachedCollections.get(namespace), batch);
            MongoDbSinkConnectorConfig.RateLimitSettings rls = rateLimitSettings.getOrDefault(collection,
                    rateLimitSettings.get(MongoDbSinkConnectorConfig.TOPIC_AGNOSTIC_KEY_NAME));
            if (rls.isTriggered()) {
                LOGGER.debug(
                        "rate limit settings triggering {}ms defer timeout"
                                + " after processing {} further batches for collection {}",
                        rls.getTimeoutMs(), rls.getEveryN(), collection);
                try {
                    Thread.sleep(rls.getTimeoutMs());
                } catch (InterruptedException e) {
                    LOGGER.error(e.getMessage());
                }
            }
        });
    });

}

From source file:com.bsi.summer.core.dao.PropertyFilter.java

/**
 * @param filterName ,???. //from  w  ww .j av  a 2 s  . c  o m
 *                      FILTER_LIKES_NAME_OR_LOGIN_NAME
 *                   
 *                value "SYS_" ??? 
 * 
 * @param value .
 */
public PropertyFilter(final String filterName, final String value) {

    String firstPart = StringUtils.substringBefore(filterName, "_");
    String matchTypeCode = StringUtils.substring(firstPart, 0, firstPart.length() - 1);
    String propertyTypeCode = StringUtils.substring(firstPart, firstPart.length() - 1, firstPart.length());

    try {
        matchType = Enum.valueOf(MatchType.class, matchTypeCode);
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    try {
        propertyClass = Enum.valueOf(PropertyType.class, propertyTypeCode);
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(
                "filter??" + filterName + ",.", e);
    }

    String propertyNameStr = StringUtils.substringAfter(filterName, "_");
    Assert.isTrue(StringUtils.isNotBlank(propertyNameStr),
            "filter??" + filterName + ",??.");
    propertyNames = StringUtils.splitByWholeSeparator(propertyNameStr, PropertyFilter.OR_SEPARATOR);
    if (StringUtils.split(value, "-").length == 1) {
        this.matchValue = getValue(value);
    } else {
        this.matchValue = getValue(StringUtils.split(value, "-")[0]);
        this.matchBetweenValue = getValue(StringUtils.split(value, "-")[1]);
    }
}

From source file:hydrograph.ui.expression.editor.pages.AddExternalJarPage.java

public boolean createPropertyFileForSavingData() {
    IProject iProject = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject();
    IFolder iFolder = iProject.getFolder(PathConstant.PROJECT_RESOURCES_FOLDER);
    Properties properties = new Properties();
    FileOutputStream file = null;
    boolean isFileCreated = false;
    try {// ww  w  . ja va2 s.c  o  m
        if (!iFolder.exists()) {
            iFolder.create(true, true, new NullProgressMonitor());
        }
        for (String items : categoriesDialogTargetComposite.getTargetList().getItems()) {
            String jarFileName = StringUtils.trim(StringUtils.substringAfter(items, Constants.DASH));
            String packageName = StringUtils.trim(StringUtils.substringBefore(items, Constants.DASH));
            properties.setProperty(packageName, jarFileName);
        }

        file = new FileOutputStream(iFolder.getLocation().toString() + File.separator
                + PathConstant.EXPRESSION_EDITOR_EXTERNAL_JARS_PROPERTIES_FILES);
        properties.store(file, "");
        ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE,
                new NullProgressMonitor());
        isFileCreated = true;
    } catch (IOException | CoreException exception) {
        LOGGER.error("Exception occurred while saving jar file path at projects setting folder", exception);
    } finally {
        if (file != null)
            try {
                file.close();
            } catch (IOException e) {
                LOGGER.warn("IOException occurred while closing output-stream of file", e);
            }
    }
    return isFileCreated;
}

From source file:com.opengamma.util.rest.RestUtils.java

private static void decode(MutableFudgeMsg msg, String key, String value) {
    if (key.contains(".")) {
        String key1 = StringUtils.substringBefore(key, ".");
        String key2 = StringUtils.substringAfter(key, ".");
        MutableFudgeMsg subMsg = msg.ensureSubMessage(key1, null);
        decode(subMsg, key2, value);/*from  w ww  .j av  a  2  s . co m*/
    } else {
        msg.add(key, value);
    }
}

From source file:com.prowidesoftware.swift.model.field.SwiftParseUtils.java

/**
 * Split components of a line using the parameter separator and returns the second token found or <code>null</code> if
 * second component is missing. Two adjacent separators are NOT treated as one.<br />
 * Examples with slash as separator:<ul>
 *       <li>for the literal "abc//def/ghi" will return null.</li>
 *       <li>for the literal "abc/foo/def" will return "foo".</li>
 *       <li>for the literal "abc/foo/def/ghi" will return "foo".</li>
 * </ul>// w w  w .j a  v a  2 s.co m
 *
 * @param line
 * @param separator
 * @return s
 */
public static String getTokenSecond(final String line, final String separator) {
    //notice we cannot use String.split nor StringUtils.split because in that implementations two adjacent separators are treated as one
    final String result = getTokenFirst(StringUtils.substringAfter(line, separator), null, separator);
    return result;
}