org.apache.directory.api.util.Strings.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中org.apache.directory.api.util.Strings.isEmpty()方法的一些代码示例,展示了Strings.isEmpty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Strings.isEmpty()方法的具体详情如下:
包路径:org.apache.directory.api.util.Strings
类名称:Strings
方法名:isEmpty

Strings.isEmpty介绍

[英]Checks if a String is empty ("") or null.

StringUtils.isEmpty(null)      = true 
StringUtils.isEmpty("")        = true 
StringUtils.isEmpty(" ")       = false 
StringUtils.isEmpty("bob")     = false 
StringUtils.isEmpty("  bob  ") = false

NOTE: This method changed in Lang version 2.0. It no longer trims the String. That functionality is available in isBlank().
[中]检查字符串是否为空(“”)或null。

StringUtils.isEmpty(null)      = true 
StringUtils.isEmpty("")        = true 
StringUtils.isEmpty(" ")       = false 
StringUtils.isEmpty("bob")     = false 
StringUtils.isEmpty("  bob  ") = false

注意:在Lang 2.0版中,此方法发生了更改。它不再修剪绳子。该功能在isBlank()中可用。

代码示例

代码示例来源:origin: apache/kylin

@Override
  public boolean apply(@Nullable CubingJob cubeJob) {
    if (cubeJob == null) {
      return false;
    }
    if (Strings.isEmpty(jobName)) {
      return true;
    }
    if (nameExactMatch) {
      return cubeJob.getName().equalsIgnoreCase(jobName);
    } else {
      return cubeJob.getName().toLowerCase(Locale.ROOT)
          .contains(jobName.toLowerCase(Locale.ROOT));
    }
  }
})));

代码示例来源:origin: apache/kylin

@Override
  public boolean apply(@Nullable CubingJob cubeJob) {
    if (cubeJob == null) {
      return false;
    }
    if (Strings.isEmpty(jobName)) {
      return true;
    }
    if (nameExactMatch) {
      return cubeJob.getName().equalsIgnoreCase(jobName);
    } else {
      return cubeJob.getName().toLowerCase(Locale.ROOT)
          .contains(jobName.toLowerCase(Locale.ROOT));
    }
  }
})));

代码示例来源:origin: apache/kylin

@Override
  public boolean apply(@Nullable CheckpointExecutable checkpointExecutable) {
    if (checkpointExecutable == null) {
      return false;
    }
    if (Strings.isEmpty(jobName)) {
      return true;
    }
    if (nameExactMatch) {
      return checkpointExecutable.getName().equalsIgnoreCase(jobName);
    } else {
      return checkpointExecutable.getName().toLowerCase(Locale.ROOT)
          .contains(jobName.toLowerCase(Locale.ROOT));
    }
  }
})));

代码示例来源:origin: apache/kylin

@Override
  public boolean apply(@Nullable CheckpointExecutable checkpointExecutable) {
    if (checkpointExecutable == null) {
      return false;
    }
    if (Strings.isEmpty(jobName)) {
      return true;
    }
    if (nameExactMatch) {
      return checkpointExecutable.getName().equalsIgnoreCase(jobName);
    } else {
      return checkpointExecutable.getName().toLowerCase(Locale.ROOT)
          .contains(jobName.toLowerCase(Locale.ROOT));
    }
  }
})));

代码示例来源:origin: apache/kylin

if (!Strings.isEmpty(projectName)) {
  readableProjects = Lists
      .newArrayList(Iterators.filter(readableProjects.iterator(), new Predicate<ProjectInstance>() {

代码示例来源:origin: cloudfoundry/uaa

private boolean originsEquivalent(ScimUser scimUserFromRequest, ScimUser scimUserFromDb) {
  return scimUserFromDb.getOrigin().equals(scimUserFromRequest.getOrigin()) ||
      (scimUserFromDb.getOrigin().equals(OriginKeys.UAA) && Strings.isEmpty(scimUserFromRequest.getOrigin()));
}

代码示例来源:origin: cloudfoundry/uaa

public EncryptionKeyService(String activeKeyLabel, List<EncryptionKey> encryptionKeys) {
  if (Strings.isEmpty(activeKeyLabel)) {
    throw new NoActiveEncryptionKeyProvided(
     "UAA cannot be started without encryption key value uaa.encryption.active_key_label"
  List<EncryptionKey> keysWithoutPassphrase = encryptionKeys.stream().filter(encryptionKey -> Strings.isEmpty(encryptionKey.getPassphrase())).collect(Collectors.toList());
  if (!keysWithoutPassphrase.isEmpty()) {
    throw new NoActiveEncryptionKeyProvided(

代码示例来源:origin: apache/metron

@Override
public GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException {
  Map<String, Object> results;
  try {
    if (grokValidation.getPatternLabel() == null) {
     throw new RestException("Pattern label is required");
    }
    if (Strings.isEmpty(grokValidation.getStatement())) {
     throw new RestException("Grok statement is required");
    }
    Grok grok = new Grok();
    grok.addPatternFromReader(new InputStreamReader(getClass().getResourceAsStream(
      "/patterns/common")));
    grok.addPatternFromReader(new StringReader(grokValidation.getStatement()));
    String grokPattern = "%{" + grokValidation.getPatternLabel() + "}";
    grok.compile(grokPattern);
    Match gm = grok.match(grokValidation.getSampleData());
    gm.captures();
    results = gm.toMap();
    results.remove(grokValidation.getPatternLabel());
  } catch (Exception e) {
    throw new RestException(e);
  }
  grokValidation.setResults(results);
  return grokValidation;
}

代码示例来源:origin: org.apache.directory.api/api-all

/**
 * Copy a byte array into a new byte array
 *
 * @param value the byte array to copy
 * @return The copied byte array
 */
public static byte[] copy( byte[] value )
{
  if ( isEmpty( value ) )
  {
    return EMPTY_BYTES;
  }
  byte[] copy = new byte[value.length];
  System.arraycopy( value, 0, copy, 0, value.length );
  return copy;
}

代码示例来源:origin: org.apache.directory.server/apacheds-server-config

/**
 * {@inheritDoc}
 */
public String toString( String tabs )
{
  StringBuilder sb = new StringBuilder();
  sb.append( toString( tabs, "enabled", enabled ) );
  if ( !Strings.isEmpty( description ) )
  {
    sb.append( tabs ).append( "description : '" ).append( description ).append( "'\n" );
  }
  if ( dn != null )
  {
    sb.append( tabs ).append( "DN: " ).append( dn ).append( "'\n" );
  }
  return sb.toString();
}

代码示例来源:origin: org.apache.directory.server/apacheds-protocol-dns

private void encodeDomainName( IoBuffer byteBuffer, String domainName )
{
  if ( !Strings.isEmpty( domainName ) )
  {
    String[] labels = domainName.split( "\\." );
  
    for ( String label : labels )
    {
      byteBuffer.put( ( byte ) label.length() );

      char[] characters = label.toCharArray();
      
      for ( char c : characters )
      {
        byteBuffer.put( ( byte ) c );
      }
    }
  }
  byteBuffer.put( ( byte ) 0x00 );
}

代码示例来源:origin: org.apache.directory.api/api-ldap-client-all

/**
 * Transform a value in a String, accordingly to RFC 2253
 *
 * @param attrValue The attribute value to be escaped
 * @return The escaped string value.
 */
public static String escapeValue( byte[] attrValue )
{
  if ( Strings.isEmpty( attrValue ) )
  {
    return "";
  }
  String value = Strings.utf8ToString( attrValue );
  return escapeValue( value );
}

代码示例来源:origin: org.apache.directory.api/api-all

/**
 * Transform a value in a String, accordingly to RFC 2253
 *
 * @param attrValue The attribute value to be escaped
 * @return The escaped string value.
 */
public static String escapeValue( byte[] attrValue )
{
  if ( Strings.isEmpty( attrValue ) )
  {
    return "";
  }
  String value = Strings.utf8ToString( attrValue );
  return escapeValue( value );
}

代码示例来源:origin: org.apache.directory.api/api-ldap-model

/**
 * Returns the attributeType from an Attribute ID.
 * 
 * @param upId The ID we are looking for
 * @return The found attributeType
 * @throws LdapException If the lookup failed
 */
protected AttributeType getAttributeType( String upId ) throws LdapException
{
  if ( Strings.isEmpty( Strings.trim( upId ) ) )
  {
    String message = I18n.err( I18n.ERR_13204_NULL_ATTRIBUTE_ID );
    LOG.error( message );
    throw new IllegalArgumentException( message );
  }
  return schemaManager.lookupAttributeTypeRegistry( upId );
}

代码示例来源:origin: org.apache.directory.api/api-ldap-model

/**
 * Transform a value in a String, accordingly to RFC 2253
 *
 * @param attrValue The attribute value to be escaped
 * @return The escaped string value.
 */
public static String escapeValue( byte[] attrValue )
{
  if ( Strings.isEmpty( attrValue ) )
  {
    return "";
  }
  String value = Strings.utf8ToString( attrValue );
  return escapeValue( value );
}

代码示例来源:origin: org.apache.directory.api/api-ldap-model

/**
 * {@inheritDoc}
 */
@Override
public void setUpId( String upId, AttributeType attributeType )
{
  String trimmed = Strings.trim( upId );
  if ( Strings.isEmpty( trimmed ) && ( attributeType == null ) )
  {
    throw new IllegalArgumentException( I18n.err( I18n.ERR_13235_NULL_ID_WITH_NULL_AT_NOT_ALLOWED ) );
  }
  String newId = Strings.toLowerCaseAscii( trimmed );
  setUpIdInternal( upId, newId, attributeType );
}

代码示例来源:origin: org.apache.directory.api/api-all

/**
 * {@inheritDoc}
 */
@Override
public void setUpId( String upId, AttributeType attributeType )
{
  String trimmed = Strings.trim( upId );
  if ( Strings.isEmpty( trimmed ) && ( attributeType == null ) )
  {
    throw new IllegalArgumentException( I18n.err( I18n.ERR_13235_NULL_ID_WITH_NULL_AT_NOT_ALLOWED ) );
  }
  String newId = Strings.toLowerCaseAscii( trimmed );
  setUpIdInternal( upId, newId, attributeType );
}

代码示例来源:origin: org.apache.directory.api/api-ldap-client-all

/**
 * {@inheritDoc}
 */
@Override
public void setUpId( String upId, AttributeType attributeType )
{
  String trimmed = Strings.trim( upId );
  if ( Strings.isEmpty( trimmed ) && ( attributeType == null ) )
  {
    throw new IllegalArgumentException( I18n.err( I18n.ERR_13235_NULL_ID_WITH_NULL_AT_NOT_ALLOWED ) );
  }
  String newId = Strings.toLowerCaseAscii( trimmed );
  setUpIdInternal( upId, newId, attributeType );
}

代码示例来源:origin: org.apache.directory.api/api-ldap-client-all

/**
 * Sets the User Provided ID as a byte[]
 * 
 * @param upId The User Provided ID
 * @param attributeType The asscoiated AttributeType
 */
public void setUpId( byte[] upId, AttributeType attributeType )
{
  byte[] trimmed = Strings.trim( upId );
  if ( Strings.isEmpty( trimmed ) && ( attributeType == null ) )
  {
    throw new IllegalArgumentException( I18n.err( I18n.ERR_13235_NULL_ID_WITH_NULL_AT_NOT_ALLOWED ) );
  }
  String newId = Strings.toLowerCase( trimmed );
  setUpIdInternal( Strings.utf8ToString( upId ), newId, attributeType );
}

代码示例来源:origin: org.apache.directory.server/apacheds-core-jndi

/**
 * @see javax.naming.Context#lookup(java.lang.String)
 */
public Object lookup( String name ) throws NamingException
{
  if ( Strings.isEmpty( name ) )
  {
    return lookup( new LdapName( "" ) );
  }
  else
  {
    return lookup( new LdapName( name ) );
  }
}

相关文章