當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.isBlank方法代碼示例

本文整理匯總了Java中org.codehaus.plexus.util.StringUtils.isBlank方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.isBlank方法的具體用法?Java StringUtils.isBlank怎麽用?Java StringUtils.isBlank使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.codehaus.plexus.util.StringUtils的用法示例。


在下文中一共展示了StringUtils.isBlank方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: format

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
/**
 * replaces inner references to other
 * 
 * @param message
 *          the message pattern
 * @param file
 *          the properties file model where to look for the references
 * @return the message with the inner resource references replaced by their corresponding values
 * @throws IllegalArgumentException
 *           when the references are not correct of referencing non existing keys in the properties file
 * @see Formatter#format(String, Object...)
 */
public String format(String message, PropertiesFile file) throws IllegalArgumentException {
  StringBuffer resultBuffer = new StringBuffer();
  Matcher matcher = innerResourcePattern.matcher(message);
  while (matcher.find()) {
    String innerKey = matcher.group(1);
    if (StringUtils.isBlank(innerKey)) {
      throw new IllegalArgumentException(String.format(
          "Could not extract inner key with regex %s in %s", innerResourceRegex, matcher.group()));
    }
    String value = file.getProperties().getProperty(innerKey);
    if (value == null) {
      throw new IllegalArgumentException(String.format(
          "Inner key <%s> not found in property file <%s>", innerKey, file.getFileName()));
    }
    matcher.appendReplacement(resultBuffer, value);
  }
  matcher.appendTail(resultBuffer);
  return resultBuffer.toString();
}
 
開發者ID:rquinio,項目名稱:l10n-maven-plugin,代碼行數:32,代碼來源:InnerResourcesFormatter.java

示例2: merge

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
/**
 * Applies the glossYaml on top of the baseYaml and returns the result.
 *
 * @param baseYaml  the base Yaml.
 * @param glossYaml the Yaml to overide the base with.
 * @return the resulting Yaml.
 */
public static String merge(String baseYaml, String glossYaml)
{
    if (StringUtils.isBlank(glossYaml))
    {
        return baseYaml;
    }
    if (StringUtils.isBlank(baseYaml))
    {
        return glossYaml;
    }
    Yaml yaml = new Yaml();
    Map<String, Object> baseMap = (Map<String, Object>) yaml.load(baseYaml);
    Map<String, Object> glossMap = (Map<String, Object>) yaml.load(glossYaml);
    for (Map.Entry<String, Object> glossEntry : glossMap.entrySet())
    {
        baseMap.put(glossEntry.getKey(), glossEntry.getValue());
    }
    return yaml.dump(baseMap);
}
 
開發者ID:mojohaus,項目名稱:cassandra-maven-plugin,代碼行數:27,代碼來源:Utils.java

示例3: info

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
/**
 * 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 );
}
 
開發者ID:mojohaus,項目名稱:buildnumber-maven-plugin,代碼行數:36,代碼來源:AbstractScmMojo.java

示例4: validate

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
public void validate()
{
    if ( StringUtils.isBlank( name ) )
    {
        throw new IllegalArgumentException( "name required" );
    }

    if ( StringUtils.isBlank( value ) )
    {
        throw new IllegalArgumentException( "value required" );
    }

    if ( StringUtils.isBlank( regex ) )
    {
        throw new IllegalArgumentException( "regex required" );
    }

    if ( toLowerCase && toUpperCase )
    {
        throw new IllegalArgumentException( "either toUpperCase or toLowerCase can be set, but not both." );
    }
}
 
開發者ID:mojohaus,項目名稱:build-helper-maven-plugin,代碼行數:23,代碼來源:RegexPropertySetting.java

示例5: checkPropValueNotBlank

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
/**
 * Checks that the property is not null or empty string
 *
 * @param propValue value of the property from the project.
 * @throws EnforcerRuleException
 */
void checkPropValueNotBlank( Object propValue ) throws EnforcerRuleException
{

    if ( propValue == null || StringUtils.isBlank( propValue.toString() ) )
    {
        throw new EnforcerRuleException( String.format(
                "Property '%s' is required for this build and not defined in hierarchy at all.", property ) );
    }
}
 
開發者ID:mojohaus,項目名稱:extra-enforcer-rules,代碼行數:16,代碼來源:RequirePropertyDiverges.java

示例6: attachGeneratedIncludeFilesAsIncZip

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
private void attachGeneratedIncludeFilesAsIncZip()
    throws MojoExecutionException
{
    try
    {
        ZipArchiver archiver = new ZipArchiver();
        DefaultFileSet fileSet = new DefaultFileSet();
        fileSet.setUsingDefaultExcludes( true );
        fileSet.setDirectory( javahOutputDirectory );
        archiver.addFileSet( fileSet );
        archiver.setDestFile( this.incZipFile );
        archiver.createArchive();

        if ( StringUtils.isBlank( this.classifier ) )
        {
            projectHelper.attachArtifact( this.project, INCZIP_TYPE, null, this.incZipFile );
        }
        else
        {
            projectHelper.attachArtifact( this.project, INCZIP_TYPE, this.classifier, this.incZipFile );
        }
    }
    catch ( Exception e )
    {
        throw new MojoExecutionException( "Unable to archive/deploy generated include files", e );
    }
}
 
開發者ID:mojohaus,項目名稱:maven-native,代碼行數:28,代碼來源:NativeJavahMojo.java

示例7: validateMojoParameters

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
@Override
protected String validateMojoParameters() {
  if (StringUtils.isBlank(this.sequence)) {
    return "sequence must not be empty.";
  }

  return null;
}
 
開發者ID:ferstl,項目名稱:jitwatch-jarscan-maven-plugin,代碼行數:9,代碼來源:SequenceSearchMojo.java

示例8: InnerResourcesFormattingValidator

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
public InnerResourcesFormattingValidator(L10nValidatorLogger logger, String innerResourceRegex) {
  super(logger);
  if (StringUtils.isBlank(innerResourceRegex)) {
    formatter = null;
  }
  else {
    formatter = new InnerResourcesFormatter(innerResourceRegex);
  }
}
 
開發者ID:rquinio,項目名稱:l10n-maven-plugin,代碼行數:10,代碼來源:InnerResourcesFormattingValidator.java

示例9: setContentDispositionAttachment

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
/**
 * Set the content disposition type to attachment. This will instruct the browser downloading the file to save it
 * instead of displaying it inline (for example html files). <p/>
 * We don't set the name here and let the browser decide based on download URL.
 * For more info read <a href="https://www.ietf.org/rfc/rfc2183.txt">RFC2183</a>
 */
@Override
public void setContentDispositionAttachment(String filename) {
    if (ConstantValues.responseDisableContentDispositionFilename.getBoolean() || StringUtils.isBlank(filename)) {
        response.setHeader("Content-Disposition", "attachment");
    } else {
        response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"" +
                "; filename*=UTF-8''" + HttpUtils.encodeQuery(filename));
    }
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:16,代碼來源:HttpArtifactoryResponse.java

示例10: setContentDispositionAttachment

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
@Override
public void setContentDispositionAttachment(String filename) {
    if (ConstantValues.responseDisableContentDispositionFilename.getBoolean() || StringUtils.isBlank(filename)) {
        response.header("Content-Disposition", "attachment");
    } else {
        response.header("Content-Disposition", "attachment; filename=\"" + filename + "\"");
    }
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:9,代碼來源:JerseyArtifactoryResponse.java

示例11: getEvn

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
private String getEvn() {
    String env = System.getProperty(ENV_KEY);
    if (StringUtils.isBlank(env)) {
        return DEFAULT_ENV;
    }
    return env;
}
 
開發者ID:liyebing,項目名稱:easyprofile-maven-plugin,代碼行數:8,代碼來源:ProfileMojo.java

示例12: validate

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
void validate()
{
    if ( StringUtils.isBlank( name ) )
    {
        throw new IllegalArgumentException( "name required" );
    }

    if ( StringUtils.isBlank( value ) )
    {
        throw new IllegalArgumentException( "value required" );
    }

    if ( StringUtils.equals( value, elseValue ) )
    {
        throw new IllegalArgumentException( "value and else cannot be the same" );
    }

    if ( fileSet == null )
    {
        throw new IllegalArgumentException( "fileSet required" );
    }

    if ( StringUtils.isBlank( fileSet.getDirectory() ) )
    {
        throw new IllegalArgumentException( "directory required for " + fileSet );
    }

    if ( fileSet.getMapper() == null )
    {
        throw new IllegalArgumentException( "mapper required for " + fileSet );
    }
}
 
開發者ID:mojohaus,項目名稱:build-helper-maven-plugin,代碼行數:33,代碼來源:UpToDatePropertySetting.java

示例13: createProject

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
/**
 * Creates the custom project structure at the specified location and name
 * The Project will have below natures:<br>
 * <b>Java</b> and Custom nature as per <b>ETL</b> project
 * @param projectName Project name
 * @param location Where should the project be saved
 * @return
 */
public IProject createProject(String projectName, URI location){
	if (StringUtils.isNotBlank(projectName) && projectName.contains(" ")){
		MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK);
		messageBox.setText("Error");
		messageBox.setMessage("The Project Name has spaces");
		if(messageBox.open()==SWT.OK)
		{
			return null;
		}
	}
	else if(StringUtils.isBlank(projectName)){
		throw new InvalidProjectNameException();
	}
	IProject project = null;
	try {
		project = createBaseProject(projectName, location);
		if(project!=null)
		{
			addNature(project);
			addToProjectStructure(project, paths);
			IJavaProject javaProject = JavaCore.create(project);

			IFolder binFolder = project.getFolder(CustomMessages.ProjectSupport_BIN);
			javaProject.setOutputLocation(binFolder.getFullPath(), null);

			List<IClasspathEntry> entries = addJavaLibrariesInClassPath();

			IFolder libFolder = project.getFolder(CustomMessages.ProjectSupport_LIB);

			//add libs to project class path 
			String installLocation = Platform.getInstallLocation().getURL().getPath();

			//copyExternalLibAndAddToClassPath(installLocation + CustomMessages.ProjectSupport_LIB, libFolder, entries);

			copyBuildFile(installLocation + CustomMessages.ProjectSupport_CONFIG_FOLDER + "/" + 
					CustomMessages.ProjectSupport_GRADLE + "/" + BUILD, project);
			
			copyBuildFile(installLocation + CustomMessages.ProjectSupport_CONFIG_FOLDER + "/" + 
					CustomMessages.ProjectSupport_GRADLE + "/" + PROPERTIES, project);
			
			copyBuildFile(installLocation + CustomMessages.ProjectSupport_CONFIG_FOLDER + "/" + 
					MAVEN, project);
			
			updateMavenFile(POM_XML, project);
			
			javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);

			//set source folder entry in classpath
			javaProject.setRawClasspath(setSourceFolderInClassPath(project, javaProject), null);
		}
	} catch (CoreException e) {
		logger.debug("Failed to create Project with parameters as projectName : {} location : {}, exception : {}", 
				new Object[]{projectName, location, e});
		project = null;
	}

	return project;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:67,代碼來源:ProjectStructureCreator.java

示例14: execute

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
public void execute( EnforcerRuleHelper helper )
    throws EnforcerRuleException
{
    try
    {
        if ( StringUtils.isBlank( encoding ) )
        {
            encoding = (String) helper.evaluate( "${project.build.sourceEncoding}" );
        }
        Log log = helper.getLog();
        if ( encoding.equals( StandardCharsets.US_ASCII.name() ) )
        {
            log.warn( "Encoding US-ASCII is hard to detect. Use UTF-8 or ISO-8859-1" );
        }
        String basedir = (String) helper.evaluate( "${basedir}" );
        DirectoryScanner ds = new DirectoryScanner();
        ds.setBasedir( basedir );
        if ( StringUtils.isNotBlank( includes ) )
        {
            ds.setIncludes( includes.split( "[,\\|]" ) );
        }
        if ( StringUtils.isNotBlank( excludes ) )
        {
            ds.setExcludes( excludes.split( "[,\\|]" ) );
        }
        if ( useDefaultExcludes )
        {
            ds.addDefaultExcludes();
        }
        ds.scan();
        StringBuilder filesInMsg = new StringBuilder();
        for ( String file : ds.getIncludedFiles() )
        {
            String fileEncoding = getEncoding( encoding, new File( basedir, file ), log );
            if ( log.isDebugEnabled() )
            {
                log.debug( file + "==>" + fileEncoding );
            }
            if ( fileEncoding != null && !fileEncoding.equals( encoding ) )
            {
                filesInMsg.append( file );
                filesInMsg.append( "==>" );
                filesInMsg.append( fileEncoding );
                filesInMsg.append( "\n" );
                if ( failFast )
                {
                    throw new EnforcerRuleException( filesInMsg.toString() );
                }
            }
        }
        if ( filesInMsg.length() > 0 )
        {
            throw new EnforcerRuleException( "Files not encoded in " + encoding + ":\n" + filesInMsg );
        }
    }
    catch ( IOException ex )
    {
        throw new EnforcerRuleException( "Reading Files", ex );
    }
    catch ( ExpressionEvaluationException e )
    {
        throw new EnforcerRuleException( "Unable to lookup an expression " + e.getLocalizedMessage(), e );
    }
}
 
開發者ID:mojohaus,項目名稱:extra-enforcer-rules,代碼行數:65,代碼來源:RequireEncoding.java

示例15: createLinkerCommandLine

import org.codehaus.plexus.util.StringUtils; //導入方法依賴的package包/類
protected Commandline createLinkerCommandLine( List objectFiles, LinkerConfiguration config )
{
    Commandline cl = new Commandline();

    cl.setWorkingDirectory( config.getWorkingDirectory().getPath() );

    String executable = EXECUTABLE;

    if ( !StringUtils.isBlank( config.getExecutable() ) )
    {
        executable = config.getExecutable();
    }

    cl.setExecutable( executable );

    for ( int i = 0; i < config.getStartOptions().length; ++i )
    {
        cl.createArg().setValue( config.getStartOptions()[i] );
    }

    // the next 2 are for completeness, the start options should be good enough
    for ( int i = 0; i < config.getMiddleOptions().length; ++i )
    {
        cl.createArg().setValue( config.getMiddleOptions()[i] );
    }

    for ( int i = 0; i < config.getEndOptions().length; ++i )
    {
        cl.createArg().setValue( config.getEndOptions()[i] );
    }

    cl.createArg().setFile( config.getOutputFile() );

    for ( int i = 0; i < objectFiles.size(); ++i )
    {
        File objFile = (File) objectFiles.get( i );

        cl.createArg().setValue( objFile.getPath() );
    }

    return cl;

}
 
開發者ID:mojohaus,項目名稱:maven-native,代碼行數:44,代碼來源:ArchiveLinker.java


注:本文中的org.codehaus.plexus.util.StringUtils.isBlank方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。