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


Java Strings.utf8ToString方法代码示例

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


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

示例1: action

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
{
    SearchRequestDecorator searchRequestDecorator = container.getMessage();

    TLV tlv = container.getCurrentTLV();

    // Store the value.
    SubstringFilter substringFilter = ( SubstringFilter ) searchRequestDecorator.getTerminalFilter();

    if ( tlv.getLength() == 0 )
    {
        String msg = I18n.err( I18n.ERR_04106 );
        LOG.error( msg );
        throw new DecoderException( msg );
    }
    else
    {
        String type = Strings.utf8ToString( tlv.getValue().getData() );
        substringFilter.setType( type );

        // We now have to get back to the nearest filter which
        // is not terminal.
        searchRequestDecorator.setTerminalFilter( substringFilter );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:StoreSubstringFilterType.java

示例2: action

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
{
    SearchRequestDecorator searchRequestDecorator = container.getMessage();
    TLV tlv = container.getCurrentTLV();
    String attributeDescription = null;

    if ( tlv.getLength() != 0 )
    {
        attributeDescription = Strings.utf8ToString( tlv.getValue().getData() );

        // If the attributeDescription is empty, we won't add it
        if ( !Strings.isEmpty( attributeDescription.trim() ) )
        {
            searchRequestDecorator.getDecorated().addAttributes( attributeDescription );
        }
    }

    // We can have an END transition
    container.setGrammarEndAllowed( true );

    if ( IS_DEBUG )
    {
        LOG.debug( "Decoded Attribute Description : {}", attributeDescription );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:StoreSearchRequestAttributeDesc.java

示例3: getString

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
String getString( T obj )
{
    String strValue;

    if ( obj == null )
    {
        return null;
    }

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

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

示例4: action

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
{
    SearchRequestDecorator searchRequestDecorator = container.getMessage();

    TLV tlv = container.getCurrentTLV();

    // We can allocate the Attribute Value Assertion
    PresentFilter presentFilter = new PresentFilter( container.getTlvId() );

    // add the filter to the request filter
    searchRequestDecorator.addCurrentFilter( presentFilter );
    searchRequestDecorator.setTerminalFilter( presentFilter );

    String value = Strings.utf8ToString( tlv.getValue().getData() );

    if ( Strings.isEmpty( value ) )
    {
        presentFilter.setAttributeDescription( "" );
    }
    else
    {
        // Store the value.
        String type = Strings.utf8ToString( tlv.getValue().getData() );
        presentFilter.setAttributeDescription( type );
    }

    // We now have to get back to the nearest filter which is
    // not terminal.
    searchRequestDecorator.unstackFilters( container );

    if ( IS_DEBUG )
    {
        LOG.debug( "Initialize Present filter" );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:39,代码来源:InitPresentFilter.java

示例5: testStringParserShort

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
@Test
public void testStringParserShort() throws LdapException
{
    String dn = Strings.utf8ToString( new byte[]
        { 'C', '=', ' ', 'E', ( byte ) 0xc3, ( byte ) 0xa9, 'c' } );

    Dn name = FastDnParser.parse( dn );

    assertEquals( "C= E\u00e9c", name.getName() );
    assertEquals( "C=E\u00e9c", name.getEscaped() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:12,代码来源:FastDnParserTest.java

示例6: action

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void action( LdapMessageContainer<ModifyRequestDecorator> container ) throws DecoderException
{
    ModifyRequestDecorator modifyRequestDecorator = container.getMessage();
    ModifyRequest modifyRequest = modifyRequestDecorator.getDecorated();

    TLV tlv = container.getCurrentTLV();

    // Store the value. It can't be null
    String type;

    if ( tlv.getLength() == 0 )
    {
        String msg = I18n.err( I18n.ERR_04083 );
        LOG.error( msg );

        ModifyResponseImpl response = new ModifyResponseImpl( modifyRequest.getMessageId() );
        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX,
            modifyRequest.getName(), null );
    }
    else
    {
        type = Strings.utf8ToString( tlv.getValue().getData() );
        modifyRequestDecorator.addAttributeTypeAndValues( type );
    }

    if ( IS_DEBUG )
    {
        LOG.debug( "Modifying type : {}", type );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:34,代码来源:AddModifyRequestAttribute.java

示例7: getParameterValueString

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * Get a parameter value
 * 
 * @param index The position of the parameter in the list of parameters
 * @return The paremeter's value
 */
public Object getParameterValueString( int index )
{
    if ( !"java".equals( language ) )
    {
        Object obj = parameters.get( index ).getValue();
        
        if ( obj instanceof byte[] )
        {
            String str = Strings.utf8ToString( ( byte[] ) obj );
            String type = ( String ) getParameterTypeString( index );

            if ( "int".equals( type ) )
            {
                try
                {
                    return IntegerDecoder.parse( new BerValue( ( byte[] ) obj ) );
                }
                catch ( IntegerDecoderException e )
                {
                    throw new RuntimeException( "Failed to decode INTEGER: "
                        + Strings.dumpBytes( ( byte[] ) obj ), e );
                }
            }
            else
            {
                return str;
            }
        }
    }

    return getJavaParameterValue( index );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:39,代码来源:StoredProcedureRequestImpl.java

示例8: action

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
{
    SearchRequestDecorator decorator = container.getMessage();

    TLV tlv = container.getCurrentTLV();

    // Store the value.
    SubstringFilter substringFilter = ( SubstringFilter ) decorator.getTerminalFilter();

    if ( tlv.getLength() == 0 )
    {
        String msg = I18n.err( I18n.ERR_04019 );
        LOG.error( msg );
        throw new DecoderException( msg );
    }

    String any = Strings.utf8ToString( tlv.getValue().getData() );
    substringFilter.addAnySubstrings( any );

    // We now have to get back to the nearest filter which is
    // not terminal.
    decorator.unstackFilters( container );

    if ( IS_DEBUG )
    {
        LOG.debug( "Stored a any substring : {}", any );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:32,代码来源:StoreAny.java

示例9: 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

示例10: 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();
    }

    switch ( strValue )
    {
        case "dSAOperation" :
        case "directoryOperation" :
        case "distributedOperation" :
        case "userApplications" :
            if ( LOG.isDebugEnabled() )
            {
                LOG.debug( I18n.msg( I18n.MSG_04490_SYNTAX_VALID, value ) );
            }
            
            return true;

        default :
            if ( LOG.isDebugEnabled() )
            {
                LOG.debug( I18n.err( I18n.ERR_04489_SYNTAX_INVALID, value ) );
            }
            
            return false;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:54,代码来源:AttributeTypeUsageSyntaxChecker.java

示例11: 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 true;
    }

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

    boolean result = Strings.isIA5String( strValue );

    if ( LOG.isDebugEnabled() )
    {
        if ( result )
        {
            LOG.debug( I18n.msg( I18n.MSG_04490_SYNTAX_VALID, value ) );
        }
        else
        {
            LOG.debug( I18n.err( I18n.ERR_04489_SYNTAX_INVALID, value ) );
        }
    }
    
    return result;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:48,代码来源:NormalizerSyntaxChecker.java

示例12: 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();
    }

    try
    {
        schemaParser.parseDITContentRuleDescription( strValue );

        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.msg( I18n.MSG_04490_SYNTAX_VALID, value ) );
        }
        
        return true;
    }
    catch ( ParseException pe )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_04489_SYNTAX_INVALID, value ) );
        }
        
        return false;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:53,代码来源:DitContentRuleDescriptionSyntaxChecker.java

示例13: SortResponseGrammar

import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private SortResponseGrammar()
{
    setName( SortResponseGrammar.class.getName() );

    // Create the transitions table
    super.transitions = new GrammarTransition[SortResponseStates.END_STATE.ordinal()][256];

    super.transitions[SortResponseStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
        new GrammarTransition<SortResponseContainer>( SortResponseStates.START_STATE,
            SortResponseStates.SEQUENCE_STATE,
            UniversalTag.SEQUENCE.getValue(), null );
    
    super.transitions[SortResponseStates.SEQUENCE_STATE.ordinal()][UniversalTag.ENUMERATED.getValue()] =
        new GrammarTransition<SortResponseContainer>( SortResponseStates.SEQUENCE_STATE,
            SortResponseStates.RESULT_CODE_STATE,
            UniversalTag.ENUMERATED.getValue(), new StoreSortResponseResultCode<SortResponseContainer>() );

    super.transitions[SortResponseStates.RESULT_CODE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
        new GrammarTransition<SortResponseContainer>( SortResponseStates.RESULT_CODE_STATE,
            SortResponseStates.AT_DESC_STATE,
            UniversalTag.OCTET_STRING.getValue(), new GrammarAction<SortResponseContainer>()
            {

                @Override
                public void action( SortResponseContainer container ) throws DecoderException
                {
                    BerValue value = container.getCurrentTLV().getValue();

                    String atType = Strings.utf8ToString( value.getData() );
                    if ( IS_DEBUG )
                    {
                        LOG.debug( "AttributeType = " + atType );
                    }
                    
                    container.getControl().setAttributeName( atType );
                    container.setGrammarEndAllowed( true );
                }
            } );

}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:42,代码来源:SortResponseGrammar.java

示例14: 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();
    }

    try
    {
        schemaParser.parseLdapSyntaxDescription( strValue );

        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.msg( I18n.MSG_04490_SYNTAX_VALID, value ) );
        }

        return true;
    }
    catch ( ParseException pe )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_04489_SYNTAX_INVALID, value ) );
        }
        
        return false;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:53,代码来源:LdapSyntaxDescriptionSyntaxChecker.java

示例15: 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();
    }

    if ( strValue.length() == 0 )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_04489_SYNTAX_INVALID, value ) );
        }
        
        return false;
    }

    boolean result = COUNTRIES.contains( Strings.toUpperCaseAscii( strValue ) );

    if ( LOG.isDebugEnabled() )
    {
        if ( result )
        {
            LOG.debug( I18n.msg( I18n.MSG_04490_SYNTAX_VALID, value ) );
        }
        else
        {
            LOG.debug( I18n.err( I18n.ERR_04489_SYNTAX_INVALID, value ) );
        }
    }

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


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