本文整理匯總了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();
}
示例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);
}
示例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 );
}
示例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." );
}
}
示例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 ) );
}
}
示例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 );
}
}
示例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;
}
示例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);
}
}
示例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));
}
}
示例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 + "\"");
}
}
示例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;
}
示例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 );
}
}
示例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;
}
示例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 );
}
}
示例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;
}