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

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

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

Strings.trim介绍

[英]Removes spaces (char <= 32) from both start and ends of this String, handling null by returning null.
Trim removes start and end characters <= 32.

StringUtils.trim(null)          = null 
StringUtils.trim("")            = "" 
StringUtils.trim("     ")       = "" 
StringUtils.trim("abc")         = "abc" 
StringUtils.trim("    abc    ") = "abc"

[中]从字符串的开头和结尾移除空格(char<=32),通过返回null来处理null
Trim删除起始字符和结束字符<=32

StringUtils.trim(null)          = null 
StringUtils.trim("")            = "" 
StringUtils.trim("     ")       = "" 
StringUtils.trim("abc")         = "abc" 
StringUtils.trim("    abc    ") = "abc"

代码示例

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

/**
 * Creates an instance of AdministrativeRole
 * 
 * @param role The role's name
 */
AdministrativeRole( String role )
{
  this.role = Strings.toLowerCaseAscii( Strings.trim( role ) );
}

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

/**
 * Creates an instance of AdministrativeRole
 * 
 * @param role The role's name
 */
AdministrativeRole( String role )
{
  this.role = Strings.toLowerCaseAscii( Strings.trim( role ) );
}

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

/**
 * Creates an instance of AdministrativeRole
 * 
 * @param role The role's name
 */
AdministrativeRole( String role )
{
  this.role = Strings.toLowerCaseAscii( Strings.trim( role ) );
}

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

/**
 * Add a new option to the option set for this attributeType.
 *
 * @param option the option to add
 */
public void addOption( String option )
{
  if ( options == null )
  {
    options = new HashSet<>();
  }
  options.add( Strings.toLowerCaseAscii( Strings.trim( option ) ) );
}

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

/**
 * Tells if a given role is a valid administrative role. We check the lower cased
 * and trimmed value, and also the OID value.
 */
private boolean isValidRole( String role )
{
  return ROLES.contains( Strings.toLowerCaseAscii( Strings.trim( role ) ) );
}

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

/**
 * Add a new option to the option set for this attributeType.
 *
 * @param option the option to add
 */
public void addOption( String option )
{
  if ( options == null )
  {
    options = new HashSet<>();
  }
  options.add( Strings.toLowerCaseAscii( Strings.trim( option ) ) );
}

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

/**
 * Add a new option to the option set for this attributeType.
 *
 * @param option the option to add
 */
public void addOption( String option )
{
  if ( options == null )
  {
    options = new HashSet<>();
  }
  options.add( Strings.toLowerCaseAscii( Strings.trim( option ) ) );
}

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

/**
 * @param option the option to check
 * @return <code>true</code> if the attributeType has the given option
 */
public boolean hasOption( String option )
{
  if ( hasOption() )
  {
    return options.contains( Strings.toLowerCaseAscii( Strings.trim( option ) ) );
  }
  else
  {
    return false;
  }
}

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

/**
 * @param option the option to check
 * @return <code>true</code> if the attributeType has the given option
 */
public boolean hasOption( String option )
{
  if ( hasOption() )
  {
    return options.contains( Strings.toLowerCaseAscii( Strings.trim( option ) ) );
  }
  else
  {
    return false;
  }
}

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

/**
 * @param option the option to check
 * @return <code>true</code> if the attributeType has the given option
 */
public boolean hasOption( String option )
{
  if ( hasOption() )
  {
    return options.contains( Strings.toLowerCaseAscii( Strings.trim( option ) ) );
  }
  else
  {
    return false;
  }
}

代码示例来源: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-all

/**
 * 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-client-all

/**
 * 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

/**
 * Get the trimmed and lower cased entry ID
 * 
 * @param upId The ID
 * @return The retrieved ID
 */
private String getId( String upId )
{
  String id = Strings.trim( Strings.toLowerCaseAscii( upId ) );
  // If empty, throw an error
  if ( Strings.isEmpty( id ) )
  {
    String message = I18n.err( I18n.ERR_13216_AT_ID_NULL );
    LOG.error( message );
    throw new IllegalArgumentException( message );
  }
  return id;
}

代码示例来源: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.api/api-ldap-model

/**
 * 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.api/api-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 );
}

相关文章