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:jenkins.plugins.tanaguru.ProjectTanaguruAction.java

@Override
public String getUrlName() {
    String webappUrl = Jenkins.getInstance().getDescriptorByType(TanaguruRunnerBuilder.DescriptorImpl.class)
            .getInstallation().getWebappUrl();
    if (project.getLastBuild() != null) {
        try {//from   w w  w  .  ja v  a  2  s  . c o m
            for (String line : FileUtils.readLines(project.getLastBuild().getLogFile())) {
                if (StringUtils.startsWith(line, "Audit Id")) {
                    return buildAuditResultUrl(line, webappUrl);
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(ProjectTanaguruAction.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return webappUrl;
}

From source file:com.adobe.acs.commons.replication.BrandPortalAgentFilter.java

public boolean isIncluded(Agent agent) {
    final String transportURI = agent.getConfiguration().getTransportURI();

    for (final Resource config : brandPortalConfigs) {
        if (log.isDebugEnabled()) {
            log.debug(//from   w w  w.  j  a  va  2s  . c  o  m
                    "Checking Agent [ {} ] against Brand Portal cloud service config [ {} ] for property [ {} ]",
                    agent.getId(), config.getPath(), PROP_TENTANT_URL);
        }

        final ValueMap properties = config.getValueMap();
        final String tenantUrl = StringUtils.stripToNull(properties.get(PROP_TENTANT_URL, String.class));

        if (StringUtils.isNotBlank(tenantUrl)) {
            boolean included = StringUtils.startsWith(transportURI, tenantUrl + "/");

            if (included) {
                log.debug("Including replication agent [ {} ]", agent.getId());
                return true;
            }
        }
    }

    return false;
}

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

/**
 * Gets the Form Selector for the form POST request.
 *
 * @param slingRequest/*from w w w  . j  a  v a  2 s .  co  m*/
 * @return
 */
@Override
public final String getFormSelector(final SlingHttpServletRequest slingRequest) {
    final String requestSuffix = slingRequest.getRequestPathInfo().getSuffix();
    if (StringUtils.equals(requestSuffix, this.getSuffix())
            || !StringUtils.startsWith(requestSuffix, this.getSuffix() + "/")) {
        return null;
    }

    final int segments = StringUtils.split(this.getSuffix(), '/').length;
    if (segments < 1) {
        return null;
    }

    final String formSelector = PathInfoUtil.getSuffixSegment(slingRequest, segments);
    return StringUtils.stripToNull(formSelector);
}

From source file:com.hangum.tadpole.manager.core.export.SystemDBDataManager.java

/**
 * ?  import .// ww  w .  j  a v a  2  s. c o  m
 * 
 */
public static void importUserDB(String strSource) throws Exception {
    Gson gson = new Gson();

    String[] strUserdb = StringUtils.split(strSource, PublicTadpoleDefine.LINE_SEPARATOR);
    if (!StringUtils.startsWith(strUserdb[0], SystemDefine.NAME)) {
        throw new RuntimeException(Messages.get().SystemDBDataManager_8);
    }

    // int  1? ?    .
    for (int i = 3; i < strUserdb.length; i++) {
        UserDBDAO userDBDAO = gson.fromJson(strUserdb[i], UserDBDAO.class);
        TadpoleSystem_UserDBQuery.newUserDB(userDBDAO, SessionManager.getUserSeq());
    }

    // google analytic
    AnalyticCaller.track("import user DB");

}

From source file:com.cognifide.actions.msg.replication.reception.MessagePageListener.java

/**
 * Converts the JCR tree change event (creating new cq:Page node) to the the OSGI event with topic
 * com/cognifide/actions/defaultActionsTopic and sends it the queue.
 * //from   www. j  a  v  a  2 s .co  m
 * @param event
 * @throws RepositoryException
 */
@Override
public void handleEvent(Event event) {
    if (!(isAuthor() && EventUtil.isLocal(event))) {
        return;
    }
    final String path = (String) event.getProperty("path");
    if (!StringUtils.startsWith(path, config.getActionRoot())) {
        return;
    }

    final Map<String, Object> payload = new HashMap<String, Object>();
    payload.put(SlingConstants.PROPERTY_PATH, StringUtils.removeEnd(path, JCR_CONTENT_SUFFIX));
    jobManager.addJob(HandleMessageJob.TOPIC, null, payload);
}

From source file:com.taobao.tdhs.jdbc.util.StringUtil.java

public static String escapeValue(String value) {
    value = StringUtils.trim(value);//from ww w .j  a v a2  s  .c om
    if (StringUtils.startsWith(value, FIELD_ESCAPE_QUOTATION)
            || StringUtils.endsWith(value, FIELD_ESCAPE_QUOTATION)) {
        return null;
    }
    if (StringUtils.startsWith(value, VALUE_ESCAPE_QUOTATION_1)
            && !StringUtils.endsWith(value, VALUE_ESCAPE_QUOTATION_1)) {
        return null;
    }
    if (!StringUtils.startsWith(value, VALUE_ESCAPE_QUOTATION_1)
            && StringUtils.endsWith(value, VALUE_ESCAPE_QUOTATION_1)) {
        return null;
    }
    if (StringUtils.startsWith(value, VALUE_ESCAPE_QUOTATION_2)
            && !StringUtils.endsWith(value, VALUE_ESCAPE_QUOTATION_2)) {
        return null;
    }
    if (!StringUtils.startsWith(value, VALUE_ESCAPE_QUOTATION_2)
            && StringUtils.endsWith(value, VALUE_ESCAPE_QUOTATION_2)) {
        return null;
    }

    if (StringUtils.startsWith(value, VALUE_ESCAPE_QUOTATION_1)
            && StringUtils.endsWith(value, VALUE_ESCAPE_QUOTATION_1)) {
        if (value.length() > 1)
            return value.substring(1, value.length() - 1);
        else
            return null;
    }

    if (StringUtils.startsWith(value, VALUE_ESCAPE_QUOTATION_2)
            && StringUtils.endsWith(value, VALUE_ESCAPE_QUOTATION_2)) {
        if (value.length() > 1)
            return value.substring(1, value.length() - 1);
        else
            return null;
    }

    return value;
}

From source file:com.thoughtworks.go.buildsession.UploadArtifactCommandExecutor.java

protected String destURL(File rootPath, File file, String src, String dest) {
    String trimmedPattern = rtrimStandardrizedWildcardTokens(src);
    if (StringUtils.equals(normalizePath(trimmedPattern), normalizePath(src))) {
        return dest;
    }//from www . j a v  a2 s . c o m
    String trimmedPath = removeStart(subtractPath(rootPath, file), normalizePath(trimmedPattern));
    if (!StringUtils.startsWith(trimmedPath, "/") && StringUtils.isNotEmpty(trimmedPath)) {
        trimmedPath = "/" + trimmedPath;
    }
    return dest + trimmedPath;
}

From source file:com.cognifide.slice.mapper.impl.processor.SliceReferenceFieldProcessor.java

private String getFullPath(final String initialPath) {
    if (StringUtils.isBlank(initialPath)) {
        return StringUtils.EMPTY;
    }/*from   w  w  w  .j a  v  a2s. c  om*/

    final String fullPath = getResolvedPath(initialPath);
    if (StringUtils.isBlank(fullPath)) {
        return StringUtils.EMPTY;
    }

    if ((fullPath.charAt(0) != '/') && !StringUtils.startsWith(fullPath, "./")) {
        return "./" + fullPath;
    }
    return fullPath;
}

From source file:com.mmounirou.spotirss.spotify.tracks.XTracks.java

private String cleanTrackName(String trackName) {
    String[] spotifyExtensions = new String[] { " - Explicit Version", " - Live", " - Radio Edit" };
    String strSong = trackName;/*from   w  w w.jav  a2  s .c o  m*/

    for (String extensions : spotifyExtensions) {
        if (StringUtils.contains(strSong, extensions)) {
            strSong = "X " + StringUtils.remove(trackName, extensions);
        }
    }

    String[] braces = { "[]", "()" };

    for (String brace : braces) {

        String extendedinfo = null;
        do {
            extendedinfo = StringUtils.defaultString(
                    StringUtils.substringBetween(strSong, brace.charAt(0) + "", brace.charAt(1) + ""));
            if (StringUtils.isNotBlank(extendedinfo)) {
                if (StringUtils.startsWith(extendedinfo, "feat.")) {
                    String strArtist = StringUtils.removeStart("feat.", extendedinfo);
                    strSong = StringUtils.replace(strSong,
                            String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), "");
                    m_artistsInTrackName.addAll(cleanArtist(strArtist));
                }

                else {
                    strSong = StringUtils.replace(strSong,
                            String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), "");
                    strSong = "X " + strSong;
                }
            }

        } while (StringUtils.isNotBlank(extendedinfo));

    }

    String[] strSongSplitted = strSong.split("featuring");
    if (strSongSplitted.length > 1) {
        strSong = strSongSplitted[0];
        m_artistsInTrackName.add(strSongSplitted[1]);
    }

    String[] strSongWithFeaturing = strSong.split("-");
    if (strSongWithFeaturing.length > 1 && strSongWithFeaturing[1].contains("feat.")) {
        strSong = strSongWithFeaturing[0];
        m_artistsInTrackName.addAll(cleanArtist(StringUtils.remove(strSongWithFeaturing[1], "feat.")));
    } else {
        strSongWithFeaturing = strSong.split("feat.");
        if (strSongWithFeaturing.length > 1) {
            strSong = strSongWithFeaturing[0];
            m_artistsInTrackName.addAll(cleanArtist(strSongWithFeaturing[1]));
        }
    }

    return strSong.trim().toLowerCase();
}

From source file:com.alipay.mile.benchmark.Workload.java

/**
 * Initialize the workload. Called once, in the main client thread, before
 * any operations are started./*from w  w w.j a v  a2 s .com*/
 * @throws IOException
 * @throws ClassNotFoundException 
 */
public void init(Props props) throws IOException {
    CmdProvider cmdProvider;
    int readPercent = props.getInt(Benchmark.SELECT, 0);
    int writePercent = props.getInt(Benchmark.INSERT, 0);

    double readProportion = (double) readPercent / (double) 100;
    double writeProportion = (double) writePercent / (double) 100;

    if (readProportion + writeProportion > 0) {
        double sum = readProportion + writeProportion;
        readProportion = readProportion / sum;
        writeProportion = writeProportion / sum;
    }

    if (readProportion > 0) {
        cmdProvider = new QueryProvider(props);
        operationChooser.addValue(readProportion, cmdProvider.getName());
        operations.put(cmdProvider.getName(), cmdProvider);
    }
    if (writeProportion > 0) {
        cmdProvider = new InsertProvider(props);
        operationChooser.addValue(writeProportion, cmdProvider.getName());
        operations.put(cmdProvider.getName(), cmdProvider);
    }
    if (props.containsKey(Benchmark.RECORD_FILE)) {
        String cmd = props.getString(Benchmark.CMD_PROVIDER, "");
        if (StringUtils.startsWith(cmd, "ctu_minisearch")) {
            cmdProvider = new CtuMiniSearchProvider(props);
        } else {
            cmdProvider = new SqlFileProvider(props);
        }
        operationChooser.addValue(1.0, cmdProvider.getName());
        operations.put(cmdProvider.getName(), cmdProvider);
    }

}