org.codehaus.plexus.util.StringUtils Java Examples

The following examples show how to use org.codehaus.plexus.util.StringUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: maven-native   Author: mojohaus   File: EnvStreamConsumer.java    License: MIT License 6 votes vote down vote up
@Override
public void consumeLine( String line )
{

    if ( line.startsWith( START_PARSING_INDICATOR ) )
    {
        this.startParsing = true;
        return;
    }

    if ( this.startParsing )
    {
        String[] tokens = StringUtils.split( line, "=" );
        if ( tokens.length == 2 )
        {
            envs.put( tokens[0], tokens[1] );
        }
    }
    else
    {
        System.out.println( line );
    }

}
 
Example #2
Source Project: docker-maven-plugin   Author: fabric8io   File: StartContainerExecutor.java    License: Apache License 2.0 6 votes vote down vote up
private void exposeContainerProps(String containerId)
    throws DockerAccessException {
    String propKey = getExposedPropertyKeyPart();

    if (StringUtils.isNotEmpty(exposeContainerProps) && StringUtils.isNotEmpty(propKey)) {
        Container container = hub.getQueryService().getMandatoryContainer(containerId);

        String prefix = addDot(exposeContainerProps) + addDot(propKey);
        projectProperties.put(prefix + "id", containerId);
        String ip = container.getIPAddress();
        if (StringUtils.isNotEmpty(ip)) {
            projectProperties.put(prefix + "ip", ip);
        }

        Map<String, String> nets = container.getCustomNetworkIpAddresses();
        if (nets != null) {
            for (Map.Entry<String, String> entry : nets.entrySet()) {
                projectProperties.put(prefix + addDot("net") + addDot(entry.getKey()) + "ip", entry.getValue());
            }
        }
    }
}
 
Example #3
Source Project: helidon-build-tools   Author: oracle   File: StagerMojo.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void unpack(Path archive, Path target, String excludes, String includes) {
    File archiveFile = archive.toFile();
    UnArchiver unArchiver = null;
    try {
        unArchiver = archiverManager.getUnArchiver(archiveFile);
    } catch (NoSuchArchiverException ex) {
        throw new IllegalStateException(ex);
    }
    unArchiver.setSourceFile(archiveFile);
    unArchiver.setDestDirectory(target.toFile());
    if (StringUtils.isNotEmpty(excludes) || StringUtils.isNotEmpty(includes)) {
        IncludeExcludeFileSelector[] selectors = new IncludeExcludeFileSelector[]{
                new IncludeExcludeFileSelector()
        };
        if (StringUtils.isNotEmpty(excludes)) {
            selectors[0].setExcludes(excludes.split(","));
        }
        if (StringUtils.isNotEmpty(includes)) {
            selectors[0].setIncludes(includes.split(","));
        }
        unArchiver.setFileSelectors(selectors);
    }
    unArchiver.extract();
}
 
Example #4
Source Project: appassembler   Author: mojohaus   File: FormattedPropertiesTest.java    License: MIT License 6 votes vote down vote up
private void saveAndCompare( String expectedResource )
    throws IOException
{
    StringOutputStream string = new StringOutputStream();
    formattedProperties.save( string );

    StringOutputStream expected = new StringOutputStream();
    InputStream asStream = getClass().getResourceAsStream( expectedResource );
    try
    {
        IOUtil.copy( asStream, expected );
    }
    finally
    {
        IOUtil.close( asStream );
    }

    String unified = StringUtils.unifyLineSeparators( expected.toString() );
    assertEquals( unified, string.toString() );
}
 
Example #5
Source Project: hermes   Author: ctripcorp   File: MySQLMessageQueueStorage.java    License: Apache License 2.0 6 votes vote down vote up
private Map<String, String> getAppProperties(ByteBuf buf) {
	Map<String, String> map = new HashMap<>();
	if (buf != null) {
		HermesPrimitiveCodec codec = new HermesPrimitiveCodec(buf);
		byte firstByte = codec.readByte();
		if (HermesPrimitiveCodec.NULL != firstByte) {
			codec.readerIndexBack(1);
			int length = codec.readInt();
			if (length > 0) {
				for (int i = 0; i < length; i++) {
					String key = codec.readSuffixStringWithPrefix(PropertiesHolder.APP, true);
					if (!StringUtils.isBlank(key)) {
						map.put(key, codec.readString());
					} else {
						codec.skipString();
					}
				}
			}
		}
	}
	return map;
}
 
Example #6
Source Project: pitest   Author: hcoles   File: ScmMojo.java    License: Apache License 2.0 6 votes vote down vote up
private String getSCMConnection() throws MojoExecutionException {

    if (this.getProject().getScm() == null) {
      throw new MojoExecutionException("No SCM Connection configured.");
    }

    final String scmConnection = this.getProject().getScm().getConnection();
    if ("connection".equalsIgnoreCase(this.connectionType)
        && StringUtils.isNotEmpty(scmConnection)) {
      return scmConnection;
    }

    final String scmDeveloper = this.getProject().getScm().getDeveloperConnection();
    if ("developerconnection".equalsIgnoreCase(this.connectionType)
        && StringUtils.isNotEmpty(scmDeveloper)) {
      return scmDeveloper;
    }

    throw new MojoExecutionException("SCM Connection is not set.");

  }
 
Example #7
Source Project: KantaCDA-API   Author: TheFinnishSocialInsuranceInstitution   File: UusimispyyntoKasaaja.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void addRelatedDocument(POCDMT000040ClinicalDocument clinicalDocument, String oid, String setid,
        String propertycode, XActRelationshipDocument relationType) {
    POCDMT000040RelatedDocument relatedDocument = of.createPOCDMT000040RelatedDocument();

    relatedDocument.setTypeCode(relationType);
    relatedDocument.setParentDocument(of.createPOCDMT000040ParentDocument());
    relatedDocument.getParentDocument().getIds().add(of.createII());
    relatedDocument.getParentDocument().getIds().get(0).setRoot(oid);
    relatedDocument.getParentDocument().setCode(of.createCE());
    fetchAttributes(propertycode, relatedDocument.getParentDocument().getCode());
    clinicalDocument.getRelatedDocuments().add(relatedDocument);

    if ( !StringUtils.isEmpty(setid) ) {
        relatedDocument.getParentDocument().setSetId(of.createII());
        relatedDocument.getParentDocument().getSetId().setRoot(setid);
    }
}
 
Example #8
Source Project: netbeans   Author: apache   File: SourceJavadocByHash.java    License: Apache License 2.0 6 votes vote down vote up
public static @CheckForNull File[] find(@NonNull URL root, boolean javadoc) {
    String k = root.toString();
    Preferences n = node(javadoc);
    String v = n.get(k, null);
    if (v == null) {
        return null;
    }
    String[] split = StringUtils.split(v, "||");
    List<File> toRet = new ArrayList<File>();
    for (String vv : split) {
        File f = FileUtilities.convertStringToFile(vv);
        if (f.isFile()) {
            toRet.add(f);
        } else {
            //what do we do when one of the possibly more files is gone?
            //in most cases we are dealing with exactly one file, so keep the
            //previous behaviour of removing it.
            n.remove(k);
        }
    }
    return toRet.toArray(new File[0]);
}
 
Example #9
Source Project: netbeans   Author: apache   File: ModuleConvertor.java    License: Apache License 2.0 6 votes vote down vote up
private List<Token> getApplicableTokens(Map<String, String> moduleProps, String string) {
    String tokens = moduleProps.get(string);
    if (tokens == null) {
        return Arrays.asList(Token.values());
    }
    String[] split = StringUtils.split(tokens, ",");
    List<Token> toRet = new ArrayList<Token>();
    for (String val : split) {
        try {
            toRet.add(Token.valueOf(val.trim()));
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        }
    }
    return toRet;
}
 
Example #10
Source Project: opoopress   Author: opoo   File: ThemeMojo.java    License: Apache License 2.0 6 votes vote down vote up
private void updateThemeConfigurationFile(SiteConfigImpl siteConfig, File themeDir) throws MojoFailureException{
    File config = new File(themeDir, "theme.yml");
    if (!config.exists()) {
        throw new MojoFailureException("Config file '" + config + "' not exists.");
    }

    Locale loc = Locale.getDefault();
    //locale from parameter
    String localeString = locale;
    //locale from site configuration
    if(StringUtils.isBlank(localeString)){
        localeString = siteConfig.get("locale");
    }
    if (StringUtils.isNotEmpty(localeString)) {
        loc = LocaleUtils.toLocale(localeString);
    }

    File localeConfig = new File(themeDir, "theme_" + loc.toString() + ".yml");
    if (localeConfig.exists()) {
        config.renameTo(new File(themeDir, "theme-original.yml"));
        localeConfig.renameTo(config);
    }
}
 
Example #11
Source Project: dew   Author: gudaoxuri   File: MojoExecutor.java    License: Apache License 2.0 6 votes vote down vote up
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor )
{
    String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired();
    String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired();

    List<String> scopes = new ArrayList<>( 2 );
    if ( StringUtils.isNotEmpty( scopeToCollect ) )
    {
        scopes.add( scopeToCollect );
    }
    if ( StringUtils.isNotEmpty( scopeToResolve ) )
    {
        scopes.add( scopeToResolve );
    }

    if ( scopes.isEmpty() )
    {
        return null;
    }
    else
    {
        return new CumulativeScopeArtifactFilter( scopes );
    }
}
 
Example #12
Source Project: dew   Author: gudaoxuri   File: MojoExecutor.java    License: Apache License 2.0 6 votes vote down vote up
private ArtifactFilter getArtifactFilter(MojoDescriptor mojoDescriptor) {
    String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired();
    String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired();

    List<String> scopes = new ArrayList<String>(2);
    if (StringUtils.isNotEmpty(scopeToCollect)) {
        scopes.add(scopeToCollect);
    }
    if (StringUtils.isNotEmpty(scopeToResolve)) {
        scopes.add(scopeToResolve);
    }

    if (scopes.isEmpty()) {
        return null;
    } else {
        return new CumulativeScopeArtifactFilter(scopes);
    }
}
 
Example #13
Source Project: gitflow-maven-plugin   Author: aleksandr-m   File: AbstractGitFlowMojo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Validates plugin configuration. Throws exception if configuration is not
 * valid.
 * 
 * @param params
 *            Configuration parameters to validate.
 * @throws MojoFailureException
 *             If configuration is not valid.
 */
protected void validateConfiguration(String... params)
        throws MojoFailureException {
    if (StringUtils.isNotBlank(argLine)
            && MAVEN_DISALLOWED_PATTERN.matcher(argLine).find()) {
        throw new MojoFailureException(
                "The argLine doesn't match allowed pattern.");
    }
    if (params != null && params.length > 0) {
        for (String p : params) {
            if (StringUtils.isNotBlank(p)
                    && MAVEN_DISALLOWED_PATTERN.matcher(p).find()) {
                throw new MojoFailureException("The '" + p
                        + "' value doesn't match allowed pattern.");
            }
        }
    }
}
 
Example #14
Source Project: buildnumber-maven-plugin   Author: mojohaus   File: AbstractScmMojo.java    License: MIT License 6 votes vote down vote up
/**
 * Get info from scm.
 *
 * @param repository
 * @param fileSet
 * @return
 * @throws ScmException
 * @todo this should be rolled into org.apache.maven.scm.provider.ScmProvider and
 *       org.apache.maven.scm.provider.svn.SvnScmProvider
 */
protected InfoScmResult info( ScmRepository repository, ScmFileSet fileSet )
    throws ScmException
{
    CommandParameters commandParameters = new CommandParameters();

    // only for Git, we will make a test for shortRevisionLength parameter
    if ( GitScmProviderRepository.PROTOCOL_GIT.equals( scmManager.getProviderByRepository( repository ).getScmType() )
        && this.shortRevisionLength > 0 )
    {
        getLog().info( "ShortRevision tag detected. The value is '" + this.shortRevisionLength + "'." );
        if ( shortRevisionLength >= 0 && shortRevisionLength < 4 )
        {
            getLog().warn( "shortRevision parameter less then 4. ShortRevisionLength is relaying on 'git rev-parese --short=LENGTH' command, accordingly to Git rev-parse specification the LENGTH value is miminum 4. " );
        }
        commandParameters.setInt( CommandParameter.SCM_SHORT_REVISION_LENGTH, this.shortRevisionLength );
    }

    if ( !StringUtils.isBlank( scmTag ) && !"HEAD".equals( scmTag ) )
    {
        commandParameters.setScmVersion( CommandParameter.SCM_VERSION, new ScmTag( scmTag ) );
    }

    return scmManager.getProviderByRepository( repository ).info( repository.getProviderRepository(), fileSet,
                                                                  commandParameters );
}
 
Example #15
Source Project: helm-maven-plugin   Author: kiwigrid   File: DryRunMojo.java    License: MIT License 6 votes vote down vote up
public void execute() throws MojoExecutionException, MojoFailureException {
	if (skip || skipDryRun) {
		getLog().info("Skip dry run");
		return;
	}
	for (String inputDirectory : getChartDirectories(getChartDirectory())) {
		getLog().info("\n\nPerform dry-run for chart " + inputDirectory + "...");

		callCli(getHelmExecuteablePath()
				+ " " + action
				+ " " + inputDirectory
				+ " --dry-run --generate-name"
				+ (StringUtils.isNotEmpty(getRegistryConfig()) ? " --registry-config=" + getRegistryConfig() : "")
				+ (StringUtils.isNotEmpty(getRepositoryCache()) ? " --repository-cache=" + getRepositoryCache() : "")
				+ (StringUtils.isNotEmpty(getRepositoryConfig()) ? " --repository-config=" + getRepositoryConfig() : ""),
				"There are test failures", true);
	}
}
 
Example #16
Source Project: hub-detect   Author: blackducksoftware   File: VndrParser.java    License: Apache License 2.0 6 votes vote down vote up
public DependencyGraph parseVendorConf(final List<String> vendorConfContents) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();

    // TODO test against moby
    vendorConfContents.forEach(line -> {
        if (StringUtils.isNotBlank(line) && !line.startsWith("#")) {
            final String[] parts = line.split(" ");

            final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, parts[0], parts[1]);
            final Dependency dependency = new Dependency(parts[0], parts[1], dependencyExternalId);
            graph.addChildToRoot(dependency);
        }
    });

    return graph;
}
 
Example #17
Source Project: maven-confluence-plugin   Author: bsorrentino   File: ScmRenderer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create the documentation to provide an developer access with a
 * <code>Starteam</code> SCM. For example, generate the following command
 * line:
 * <p>
 * stcmd co -x -nologo -stop -p myusername:[email protected]:1234/projecturl
 * -is
 * </p>
 * <p>
 * stcmd ci -x -nologo -stop -p myusername:[email protected]:1234/projecturl
 * -f NCI -is
 * </p>
 *
 * @param starteamRepo
 */
private void developerAccessStarteam(StarteamScmProviderRepository starteamRepo) {
    paragraph(getI18nString("devaccess.starteam.intro"));

    StringBuilder command = new StringBuilder();

    // Safety: remove the username/password if present
    String fullUrl = StringUtils.replace(starteamRepo.getFullUrl(), starteamRepo.getUser(), "username");
    fullUrl = StringUtils.replace(fullUrl, starteamRepo.getPassword(), "password");

    command.append("$ stcmd co -x -nologo -stop -p ");
    command.append(fullUrl);
    command.append(" -is");
    command.append(SystemUtils.LINE_SEPARATOR);
    command.append("$ stcmd ci -x -nologo -stop -p ");
    command.append(fullUrl);
    command.append(" -f NCI -is");

    verbatimText(command.toString());
}
 
Example #18
Source Project: opoopress   Author: opoo   File: DefaultArtifactDownloader.java    License: Apache License 2.0 6 votes vote down vote up
private ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) throws MojoFailureException {
    // if it's a simple url
    String id = null;
    ArtifactRepositoryLayout layout = getLayout("default");
    String url = repo;

    // if it's an extended repo URL of the form id::layout::url
    if (repo.contains("::")) {
        Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(repo);
        if (!matcher.matches()) {
            throw new MojoFailureException(repo, "Invalid syntax for repository: " + repo,
                    "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\".");
        }

        id = matcher.group(1).trim();
        if (!StringUtils.isEmpty(matcher.group(2))) {
            layout = getLayout(matcher.group(2).trim());
        }
        url = matcher.group(3).trim();
    }
    return artifactRepositoryFactory.createArtifactRepository(id, url, layout, policy, policy);
}
 
Example #19
Source Project: appassembler   Author: mojohaus   File: AssembleMojo.java    License: MIT License 6 votes vote down vote up
private JvmSettings convertToJvmSettingsWithDefaultHandling( Program program )
{
    JvmSettings jvmSettings = new JvmSettings();

    if ( program.getJvmSettings() != null )
    {
        // Some kind of settings done on per program base so they take
        // precendence.
        jvmSettings = program.getJvmSettings();
    }
    else
    {
        // No settings in the program done so we use the default behaviour
        if ( StringUtils.isNotBlank( this.extraJvmArguments ) )
        {
            jvmSettings.setExtraArguments( parseTokens( this.extraJvmArguments ) );
        }
    }

    return jvmSettings;
}
 
Example #20
Source Project: buildnumber-maven-plugin   Author: mojohaus   File: CreateMetadataMojo.java    License: MIT License 6 votes vote down vote up
public String getRevision()
    throws MojoExecutionException
{
    try
    {
        return this.getScmRevision();
    }
    catch ( ScmException e )
    {
        if ( !StringUtils.isEmpty( revisionOnScmFailure ) )
        {
            getLog().warn( "Cannot get the revision information from the scm repository, proceeding with "
                + "revision of " + revisionOnScmFailure + " : \n" + e.getLocalizedMessage() );

            return revisionOnScmFailure;
        }

        throw new MojoExecutionException( "Cannot get the revision information from the scm repository : \n"
            + e.getLocalizedMessage(), e );

    }
}
 
Example #21
Source Project: sonarqube-licensecheck   Author: porscheinformatik   File: License.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated remove with later release
 * @param serializedLicensesString setting string
 * @return a list with licences
 */
@Deprecated
private static List<License> readLegacySeparated(String serializedLicensesString)
{
    List<License> licenses = new ArrayList<>();

    if (StringUtils.isNotEmpty(serializedLicensesString))
    {
        String[] parts = serializedLicensesString.split(";");

        for (String licenseString : parts)
        {
            String[] subParts = licenseString.split("~");
            String name = subParts.length > 0 ? subParts[0] : null;
            String identifier = subParts.length > 1 ? subParts[1] : null;
            String status = subParts.length > 2 ? subParts[2] : null;
            licenses.add(new License(name, identifier, status));
        }
    }

    return licenses;
}
 
Example #22
Source Project: eclipse.jdt.ls   Author: eclipse   File: AbstractInvisibleProjectBasedTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected IProject importRootFolder(IPath rootPath, String triggerFile) throws Exception {
	if (StringUtils.isNotBlank(triggerFile)) {
		IPath triggerFilePath = rootPath.append(triggerFile);
		Preferences preferences = preferenceManager.getPreferences();
		preferences.setTriggerFiles(Arrays.asList(triggerFilePath));
	}
	final List<IPath> roots = Arrays.asList(rootPath);
	IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			projectsManager.initializeProjects(roots, monitor);
		}
	};
	JavaCore.run(runnable, null, monitor);
	waitForBackgroundJobs();
	String invisibleProjectName = ProjectUtils.getWorkspaceInvisibleProjectName(rootPath);
	return ResourcesPlugin.getWorkspace().getRoot().getProject(invisibleProjectName);
}
 
Example #23
Source Project: exec-maven-plugin   Author: mojohaus   File: EnvStreamConsumer.java    License: Apache License 2.0 6 votes vote down vote up
public void consumeLine( String line )
{

    if ( line.startsWith( START_PARSING_INDICATOR ) )
    {
        this.startParsing = true;
        return;
    }

    if ( this.startParsing )
    {
        String[] tokens = StringUtils.split( line, "=" );
        if ( tokens.length == 2 )
        {
            envs.put( tokens[0], tokens[1] );
        }
    }
    else
    {
        System.out.println( line );
    }

}
 
Example #24
Source Project: jkube   Author: eclipse   File: AnsiLogger.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Update the progress
 */
@Override
public void progressUpdate(String layerId, String status, String progressMessage) {
    if (!batchMode && log.isInfoEnabled() && StringUtils.isNotEmpty(layerId)) {
        if (useAnsi) {
            updateAnsiProgress(layerId, status, progressMessage);
        } else {
            updateNonAnsiProgress();
        }
        flush();
    }
}
 
Example #25
Source Project: jkube   Author: eclipse   File: AnsiLogger.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void updateAnsiProgress(String imageId, String status, String progressMessage) {
    Map<String,Integer> imgLineMap = imageLines.get();
    Integer line = imgLineMap.get(imageId);

    int diff = 0;
    if (line == null) {
        line = imgLineMap.size();
        imgLineMap.put(imageId, line);
    } else {
        diff = imgLineMap.size() - line;
    }

    if (diff > 0) {
        print(ansi().cursorUp(diff).eraseLine(Ansi.Erase.ALL).toString());
    }

    // Status with progress bars: (max length = 11, hence pad to 11)
    // Extracting
    // Downloading
    String progress = progressMessage != null ? progressMessage : "";
    String msg =
            ansi()
                    .fg(PROGRESS_ID).a(imageId).reset().a(": ")
                    .fg(PROGRESS_STATUS).a(StringUtils.rightPad(status,11) + " ")
                    .fg(PROGRESS_BAR).a(progress).toString();
    println(msg);

    if (diff > 0) {
        // move cursor back down to bottom
        print(ansi().cursorDown(diff - 1).toString());
    }
}
 
Example #26
Source Project: jkube   Author: eclipse   File: MojoExecutionService.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private String[] splitGoalSpec(String fullGoal) {
    String[] parts = StringUtils.split(fullGoal, ":");
    if (parts.length != 3) {
        throw new IllegalStateException("Cannot parse " + fullGoal + " as a maven plugin goal. " +
                                       "It must be fully qualified as in <groupId>:<artifactId>:<goal>");
    }
    return new String[]{parts[0] + ":" + parts[1], parts[2]};
}
 
Example #27
Source Project: galleon   Author: wildfly   File: ArtifactItem.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    if (this.classifier == null) {
        return groupId + ":" + artifactId + ":" + StringUtils.defaultString(version, "?") + ":" + type;
    } else {
        return groupId + ":" + artifactId + ":" + classifier + ":" + StringUtils.defaultString(version, "?") + ":"
                + type;
    }
}
 
Example #28
Source Project: docker-maven-plugin   Author: fabric8io   File: AnsiLogger.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Update the progress
 */
public void progressUpdate(String layerId, String status, String progressMessage) {
    if (!batchMode && log.isInfoEnabled() && StringUtils.isNotEmpty(layerId)) {
        if (useAnsi) {
            updateAnsiProgress(layerId, status, progressMessage);
        } else {
            updateNonAnsiProgress(layerId);
        }
        flush();
    }
}
 
Example #29
Source Project: hermes   Author: ctripcorp   File: MySQLMessageQueueStorage.java    License: Apache License 2.0 5 votes vote down vote up
private boolean matchesFilter(String topic, MessagePriority dataObj, String filterString) {
	if (StringUtils.isBlank(filterString)) {
		return true;
	}
	ByteBuf byteBuf = Unpooled.wrappedBuffer(dataObj.getAttributes());
	try {
		return m_filter.isMatch(topic, filterString, getAppProperties(byteBuf));
	} catch (Exception e) {
		log.error("Can not find filter for: {}" + filterString);
		return false;
	}
}
 
Example #30
Source Project: maven-confluence-plugin   Author: bsorrentino   File: VersionUtil.java    License: Apache License 2.0 5 votes vote down vote up
protected static String removeNonDigitPrefix(String version) {
    if (version != null && !version.isEmpty()) {
        if (!Character.isDigit(version.charAt(0))) {
            Matcher matcher = Pattern.compile("\\d+").matcher(version);
            int i = 0;
            if (matcher.find()) {
                i = matcher.start();
            }
            if (i > 0) {
                version = StringUtils.substring(version, i, version.length());
            }
        }
    }
    return version;
}