当前位置: 首页>>代码示例>>Java>>正文


Java Strings.trim方法代码示例

本文整理汇总了Java中org.apache.directory.api.util.Strings.trim方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.trim方法的具体用法?Java Strings.trim怎么用?Java Strings.trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.directory.api.util.Strings的用法示例。


在下文中一共展示了Strings.trim方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseSimpleValue

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Parse the value part.
 *
 * @param line The line which contains the value
 * @param pos The starting position in the line
 * @return A String or a byte[], depending of the kind of value we get
 */
protected static Object parseSimpleValue( String line, int pos )
{
    if ( line.length() > pos + 1 )
    {
        char c = line.charAt( pos + 1 );

        if ( c == ':' )
        {
            String value = Strings.trim( line.substring( pos + 2 ) );

            return Base64.decode( value.toCharArray() );
        }
        else
        {
            return Strings.trim( line.substring( pos + 1 ) );
        }
    }
    else
    {
        return null;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:30,代码来源:LdifReader.java

示例2: getId

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Get the trimmed and lower cased entry 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_04133 );
        LOG.error( message );
        throw new IllegalArgumentException( message );
    }

    return id;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:18,代码来源:DefaultEntry.java

示例3: getUpId

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Get the UpId if it is null.
 * 
 * @param upId The ID
 */
private String getUpId( String upId, AttributeType attributeType )
{
    String normUpId = Strings.trim( upId );

    if ( attributeType == null )
    {
        if ( Strings.isEmpty( normUpId ) )
        {
            String message = I18n.err( I18n.ERR_04458 );
            LOG.error( message );
            throw new IllegalArgumentException( message );
        }

        return upId;
    }
    else if ( Strings.isEmpty( normUpId ) )
    {
        String id = attributeType.getName();

        if ( Strings.isEmpty( id ) )
        {
            id = attributeType.getOid();
        }

        return id;
    }
    else
    {
        return upId;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:37,代码来源:DefaultEntry.java

示例4: setUpId

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void setUpId( String upId, AttributeType attributeType )
{
    String trimmed = Strings.trim( upId );

    if ( Strings.isEmpty( trimmed ) && ( attributeType == null ) )
    {
        throw new IllegalArgumentException( "Cannot set a null ID with a null AttributeType" );
    }

    String newId = Strings.toLowerCaseAscii( trimmed );

    setUpIdInternal( upId, newId, attributeType );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:18,代码来源:DefaultAttribute.java

示例5: parseChangeType

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Parse the changeType
 *
 * @param line The line which contains the changeType
 * @return The operation.
 */
protected ChangeType parseChangeType( String line )
{
    ChangeType operation = ChangeType.Add;

    String modOp = Strings.trim( line.substring( "changetype:".length() ) );

    if ( "add".equalsIgnoreCase( modOp ) )
    {
        operation = ChangeType.Add;
    }
    else if ( "delete".equalsIgnoreCase( modOp ) )
    {
        operation = ChangeType.Delete;
    }
    else if ( "modify".equalsIgnoreCase( modOp ) )
    {
        operation = ChangeType.Modify;
    }
    else if ( "moddn".equalsIgnoreCase( modOp ) )
    {
        operation = ChangeType.ModDn;
    }
    else if ( "modrdn".equalsIgnoreCase( modOp ) )
    {
        operation = ChangeType.ModRdn;
    }

    return operation;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:36,代码来源:LdifReader.java

示例6: createAva

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Construct an Ava. The type and value are normalized :
 * <li> the type is trimmed and lowercased </li>
 * <li> the value is trimmed </li>
 * <p>
 * Note that the upValue should <b>not</b> be null or empty, or resolved
 * to an empty string after having trimmed it.
 *
 * @param upType The User Provided type
 * @param upValue The User Provided value
 * 
 * @throws LdapInvalidDnException If the given type or value are invalid
 */
private void createAva( String upType, Value upValue ) throws LdapInvalidDnException
{
    String upTypeTrimmed = Strings.trim( upType );
    String normTypeTrimmed = Strings.trim( normType );

    if ( Strings.isEmpty( upTypeTrimmed ) )
    {
        if ( Strings.isEmpty( normTypeTrimmed ) )
        {
            String message = I18n.err( I18n.ERR_04188 );
            LOG.error( message );
            throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
        }
        else
        {
            // In this case, we will use the normType instead
            this.normType = Strings.lowerCaseAscii( normTypeTrimmed );
            this.upType = normType;
        }
    }
    else if ( Strings.isEmpty( normTypeTrimmed ) )
    {
        // In this case, we will use the upType instead
        this.normType = Strings.lowerCaseAscii( upTypeTrimmed );
        this.upType = upType;
    }
    else
    {
        this.normType = Strings.lowerCaseAscii( normTypeTrimmed );
        this.upType = upType;

    }

    value = upValue;

    upName = getEscaped();
    
    hashCode();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:53,代码来源:Ava.java

示例7: isValidSyntax

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean isValidSyntax( Object value )
{
    String strValue;

    if ( value == null )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_04489_SYNTAX_INVALID, "null" ) );
        }
        
        return false;
    }

    if ( value instanceof String )
    {
        strValue = ( String ) value;
    }
    else if ( value instanceof byte[] )
    {
        strValue = Strings.utf8ToString( ( byte[] ) value );
    }
    else
    {
        strValue = value.toString();
    }

    strValue = Strings.trim( Strings.toLowerCaseAscii( strValue ) );

    return "base".equals( strValue ) || "one".equals( strValue ) || "sub".equals( strValue );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:36,代码来源:SearchScopeSyntaxChecker.java

示例8: isValidSyntax

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean isValidSyntax( Object value )
{
    String strValue;

    if ( value == null )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_04489_SYNTAX_INVALID, "null" ) );
        }
        
        return false;
    }

    if ( value instanceof String )
    {
        strValue = ( String ) value;
    }
    else if ( value instanceof byte[] )
    {
        strValue = Strings.utf8ToString( ( byte[] ) value );
    }
    else
    {
        strValue = value.toString();
    }

    strValue = Strings.trim( Strings.toLowerCaseAscii( strValue ) );

    return "never".equals( strValue ) || "finding".equals( strValue ) || "searching".equals( strValue ) || "always"
        .equals( strValue );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:37,代码来源:DerefAliasSyntaxChecker.java

示例9: if

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Construct an Ava. The type and value are normalized :
 * <li> the type is trimmed and lowercased </li>
 * <li> the value is trimmed </li>
 * <p>
 * Note that the upValue should <b>not</b> be null or empty, or resolved
 * to an empty string after having trimmed it.
 *
 * @param attributeType The AttributeType for this value
 * @param upType The User Provided type
 * @param normType The normalized type
 * @param value The value
 * @param upName The User Provided name (may be escaped)
 * 
 * @throws LdapInvalidDnException If the given type or value are invalid
 */
// WARNING : The protection level is left unspecified intentionally.
// We need this method to be visible from the DnParser class, but not
// from outside this package.
/* Unspecified protection */Ava( AttributeType attributeType, String upType, String normType, Value value, String upName )
    throws LdapInvalidDnException
{
    this.attributeType = attributeType;
    String upTypeTrimmed = Strings.trim( upType );
    String normTypeTrimmed = Strings.trim( normType );

    if ( Strings.isEmpty( upTypeTrimmed ) )
    {
        if ( Strings.isEmpty( normTypeTrimmed ) )
        {
            String message = I18n.err( I18n.ERR_04188 );
            LOG.error( message );
            throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
        }
        else
        {
            // In this case, we will use the normType instead
            this.normType = Strings.lowerCaseAscii( normTypeTrimmed );
            this.upType = normType;
        }
    }
    else if ( Strings.isEmpty( normTypeTrimmed ) )
    {
        // In this case, we will use the upType instead
        this.normType = Strings.lowerCaseAscii( upTypeTrimmed );
        this.upType = upType;
    }
    else
    {
        this.normType = Strings.lowerCaseAscii( normTypeTrimmed );
        this.upType = upType;
    }

    this.value = value;
    this.upName = upName;
    hashCode();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:58,代码来源:Ava.java


注:本文中的org.apache.directory.api.util.Strings.trim方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。