本文整理汇总了Java中org.apache.directory.api.util.Strings.getBytesUtf8方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.getBytesUtf8方法的具体用法?Java Strings.getBytesUtf8怎么用?Java Strings.getBytesUtf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.util.Strings
的用法示例。
在下文中一共展示了Strings.getBytesUtf8方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Thread safe method parses an OpenLDAP schemaObject element/object.
*
* @param schemaObject the String image of a complete schema object
* @return The list of parsed schema elements
* @throws java.io.IOException If the schema file can't be processed
* @throws java.text.ParseException If we weren't able to parse the schema
*/
public synchronized List<SchemaElement> parse( String schemaObject ) throws IOException, ParseException
{
if ( ( schemaObject == null ) || ( schemaObject.trim().equals( Strings.EMPTY_STRING ) ) )
{
throw new ParseException( I18n.err( I18n.ERR_06001_EMPTY_OR_NULL_SCHEMA_OBJECT ), 0 );
}
schemaIn = new ByteArrayInputStream( Strings.getBytesUtf8( schemaObject ) );
if ( producerThread == null )
{
producerThread = new Thread( new DataProducer() );
}
producerThread.start();
return invokeParser( schemaObject );
}
示例2: computeLength
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Compute the intermediateResponse length
* <br>
* intermediateResponse :
* <pre>
* 0x79 L1
* |
* [+--> 0x80 L2 name
* [+--> 0x81 L3 response]]
*
* L1 = [ + Length(0x80) + Length(L2) + L2
* [ + Length(0x81) + Length(L3) + L3]]
*
* Length(IntermediateResponse) = Length(0x79) + Length(L1) + L1
* </pre>
*
* @return The IntermediateResponse length
*/
@Override
public int computeLength()
{
intermediateResponseLength = 0;
if ( !Strings.isEmpty( getResponseName() ) )
{
responseNameBytes = Strings.getBytesUtf8( getResponseName() );
int responseNameLength = responseNameBytes.length;
intermediateResponseLength += 1 + TLV.getNbBytes( responseNameLength ) + responseNameLength;
}
encodedValueBytes = getResponseValue();
if ( encodedValueBytes != null )
{
intermediateResponseLength += 1 + TLV.getNbBytes( encodedValueBytes.length ) + encodedValueBytes.length;
}
return 1 + TLV.getNbBytes( intermediateResponseLength ) + intermediateResponseLength;
}
示例3: testSerializeAttributeBinaryValue
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Test the serialization of a client attribute with a binary value
*/
@Test
public void testSerializeAttributeBinaryValue() throws LdapException, IOException, ClassNotFoundException
{
DefaultAttribute dca = new DefaultAttribute( "UserPassword" );
byte[] password = Strings.getBytesUtf8( "secret" );
dca.add( password );
DefaultAttribute dcaSer = deserializeValue( serializeValue( dca ) );
assertEquals( dca.toString(), dcaSer.toString() );
assertEquals( "userpassword", dcaSer.getId() );
assertEquals( "UserPassword", dcaSer.getUpId() );
assertTrue( Arrays.equals( dca.getBytes(), dcaSer.getBytes() ) );
assertEquals( 1, dcaSer.size() );
assertTrue( dcaSer.contains( password ) );
assertFalse( dcaSer.isHumanReadable() );
}
示例4: computeLength
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* @return the control length.
*/
@Override
public int computeLength()
{
sortRespLen = 0;
valueLength = 0;
// result code value
sortRespLen += 1 + 1 + 1;
if ( getAttributeName() != null )
{
byte[] data = Strings.getBytesUtf8( getAttributeName() );
sortRespLen += 1 + TLV.getNbBytes( data.length ) + data.length;
}
valueLength = 1 + TLV.getNbBytes( sortRespLen ) + sortRespLen;
return valueLength;
}
示例5: StoredProcedureRequestImpl
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Instantiates a new stored procedure request.
*
* @param messageId the message id
* @param procedure the procedure
* @param language the language
*/
public StoredProcedureRequestImpl( int messageId, String procedure, String language )
{
super( messageId );
this.setRequestName( EXTENSION_OID );
this.language = language;
this.procedure = Strings.getBytesUtf8( procedure );
}
示例6: Value
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Creates a Value with an initial user provided String value.
*
* @param upValue the value to wrap. It can be null
*/
public Value( String upValue )
{
this.upValue = upValue;
// We can't normalize the value, we store it as is
normValue = upValue;
if ( upValue != null )
{
bytes = Strings.getBytesUtf8( upValue );
}
hashCode();
}
示例7: computeLength
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Compute the ProxiedAuthzControl length
* <pre>
* 0x04 L1 authzId]
* </pre>
*
* @return the control length.
*/
@Override
public int computeLength()
{
int valueLength = 0;
if ( getAuthzId() != null )
{
authzIdBytes = Strings.getBytesUtf8( getAuthzId() );
valueLength = authzIdBytes.length;
}
return valueLength;
}
示例8: if
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Compute the GracefulDisconnect length
* <pre>
* 0x30 L1
* |
* +--> [ 0x02 0x0(1-4) [0..720] ]
* +--> [ 0x80 0x0(1-3) [0..86400] ]
* +--> [ 0x30 L2
* |
* +--> (0x04 L3 value) + ]
* </pre>
*/
/* no qualifier */ int computeLengthInternal()
{
gracefulDisconnectSequenceLength = 0;
if ( gracefulDisconnectResponse.getTimeOffline() != 0 )
{
gracefulDisconnectSequenceLength += 1 + 1 + BerValue.getNbBytes( gracefulDisconnectResponse.getTimeOffline() );
}
if ( gracefulDisconnectResponse.getDelay() != 0 )
{
gracefulDisconnectSequenceLength += 1 + 1 + BerValue.getNbBytes( gracefulDisconnectResponse.getDelay() );
}
if ( ( gracefulDisconnectResponse.getReplicatedContexts() != null )
&& ( !gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().isEmpty() ) )
{
replicatedContextsLength = 0;
ldapUrlBytes = new ArrayList<>( gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls().size() );
// We may have more than one reference.
for ( String replicatedContext : gracefulDisconnectResponse.getReplicatedContexts().getLdapUrls() )
{
byte[] bytes = Strings.getBytesUtf8( replicatedContext );
ldapUrlBytes.add( bytes );
int ldapUrlLength = bytes.length;
replicatedContextsLength += 1 + TLV.getNbBytes( ldapUrlLength ) + ldapUrlLength;
}
gracefulDisconnectSequenceLength += 1 + TLV.getNbBytes( replicatedContextsLength )
+ replicatedContextsLength;
}
return 1 + TLV.getNbBytes( gracefulDisconnectSequenceLength ) + gracefulDisconnectSequenceLength;
}
示例9: getBytes
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Get the CSN as a byte array. The data are stored as :
* bytes 1 to 8 : timestamp, big-endian
* bytes 9 to 12 : change count, big endian
* bytes 13 to ... : ReplicaId
*
* @return A copy of the byte array representing theCSN
*/
public byte[] getBytes()
{
if ( bytes == null )
{
bytes = Strings.getBytesUtf8( csnStr );
}
byte[] copy = new byte[bytes.length];
System.arraycopy( bytes, 0, copy, 0, bytes.length );
return copy;
}
示例10: bind
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void bind( Dn name, String credentials ) throws LdapException
{
byte[] credBytes = credentials == null ? Strings.EMPTY_BYTES : Strings.getBytesUtf8( credentials );
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setDn( name );
bindRequest.setCredentials( credBytes );
BindResponse bindResponse = bind( bindRequest );
processResponse( bindResponse );
}
示例11: computeReferralLength
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Compute the referral's encoded length
* @param referral The referral to encode
* @return The length of the encoded PDU
*/
public static int computeReferralLength( Referral referral )
{
if ( referral != null )
{
Collection<String> ldapUrls = referral.getLdapUrls();
if ( ( ldapUrls != null ) && ( !ldapUrls.isEmpty() ) )
{
int referralLength = 0;
// Each referral
for ( String ldapUrl : ldapUrls )
{
byte[] ldapUrlBytes = Strings.getBytesUtf8( ldapUrl );
referralLength += 1 + TLV.getNbBytes( ldapUrlBytes.length ) + ldapUrlBytes.length;
referral.addLdapUrlBytes( ldapUrlBytes );
}
referral.setReferralLength( referralLength );
return referralLength;
}
else
{
return 0;
}
}
else
{
return 0;
}
}
示例12: computeLength
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Compute the CompareRequest length
* <br>
* CompareRequest :
* <pre>
* 0x6E L1
* |
* +--> 0x04 L2 entry
* +--> 0x30 L3 (ava)
* |
* +--> 0x04 L4 attributeDesc
* +--> 0x04 L5 assertionValue
*
* L3 = Length(0x04) + Length(L4) + L4 + Length(0x04) +
* Length(L5) + L5
* Length(CompareRequest) = Length(0x6E) + Length(L1) + L1 +
* Length(0x04) + Length(L2) + L2 + Length(0x30) + Length(L3) + L3
* </pre>
*
* @return The CompareRequest PDU's length
*/
@Override
public int computeLength()
{
// The entry Dn
dnBytes = Strings.getBytesUtf8( getName().getName() );
compareRequestLength = 1 + TLV.getNbBytes( dnBytes.length ) + dnBytes.length;
// The attribute value assertion
attrIdBytes = Strings.getBytesUtf8( getAttributeId() );
avaLength = 1 + TLV.getNbBytes( attrIdBytes.length ) + attrIdBytes.length;
attrValBytes = getAssertionValue().getBytes();
avaLength += 1 + TLV.getNbBytes( attrValBytes.length ) + attrValBytes.length;
compareRequestLength += 1 + TLV.getNbBytes( avaLength ) + avaLength;
return 1 + TLV.getNbBytes( compareRequestLength ) + compareRequestLength;
}
示例13: computeLength
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Compute the ModifyDNRequest length
* <br>
* ModifyDNRequest :
* <pre>
* 0x6C L1
* |
* +--> 0x04 L2 entry
* +--> 0x04 L3 newRDN
* +--> 0x01 0x01 (true/false) deleteOldRDN (3 bytes)
* [+--> 0x80 L4 newSuperior ]
*
* L2 = Length(0x04) + Length(Length(entry)) + Length(entry)
* L3 = Length(0x04) + Length(Length(newRDN)) + Length(newRDN)
* L4 = Length(0x80) + Length(Length(newSuperior)) + Length(newSuperior)
* L1 = L2 + L3 + 3 [+ L4]
*
* Length(ModifyDNRequest) = Length(0x6C) + Length(L1) + L1
* </pre>
*
* @return The PDU's length of a ModifyDN Request
*/
@Override
public int computeLength()
{
int newRdnlength = Strings.getBytesUtf8( getNewRdn().getName() ).length;
// deleteOldRDN
dnBytes = Strings.getBytesUtf8( getName().getName() );
modifyDnRequestLength = 1 + TLV.getNbBytes( dnBytes.length ) + dnBytes.length + 1 + TLV.getNbBytes( newRdnlength )
+ newRdnlength + 1 + 1 + 1;
if ( getNewSuperior() != null )
{
newSuperiorBytes = Strings.getBytesUtf8( getNewSuperior().getName() );
modifyDnRequestLength += 1 + TLV.getNbBytes( newSuperiorBytes.length ) + newSuperiorBytes.length;
}
return 1 + TLV.getNbBytes( modifyDnRequestLength ) + modifyDnRequestLength;
}
示例14: getDecorated
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Compute the StoredProcedure length
* <pre>
* 0x30 L1
* |
* +--> 0x04 L2 language
* +--> 0x04 L3 procedure
* [+--> 0x30 L4 (parameters)
* |
* +--> 0x30 L5-1 (parameter)
* | |
* | +--> 0x04 L6-1 type
* | +--> 0x04 L7-1 value
* |
* +--> 0x30 L5-2 (parameter)
* | |
* | +--> 0x04 L6-2 type
* | +--> 0x04 L7-2 value
* |
* +--> ...
* |
* +--> 0x30 L5-m (parameter)
* |
* +--> 0x04 L6-m type
* +--> 0x04 L7-m value
* </pre>
*/
/* no qualifier */ int computeLengthInternal()
{
// The language
byte[] languageBytes = Strings.getBytesUtf8( getDecorated().getLanguage() );
int languageLength = 1 + TLV.getNbBytes( languageBytes.length )
+ languageBytes.length;
byte[] procedure = getDecorated().getProcedure();
// The procedure
int procedureLength = 1 + TLV.getNbBytes( procedure.length )
+ procedure.length;
// Compute parameters length value
if ( getDecorated().getParameters() != null )
{
parameterLength = new LinkedList<>();
for ( StoredProcedureParameter spParam : getDecorated().getParameters() )
{
int localParameterLength;
int localParamTypeLength;
int localParamValueLength;
localParamTypeLength = 1 + TLV.getNbBytes( spParam.getType().length ) + spParam.getType().length;
localParamValueLength = 1 + TLV.getNbBytes( spParam.getValue().length ) + spParam.getValue().length;
localParameterLength = localParamTypeLength + localParamValueLength;
parametersLength += 1 + TLV.getNbBytes( localParameterLength ) + localParameterLength;
parameterLength.add( localParameterLength );
}
}
int localParametersLength = 1 + TLV.getNbBytes( parametersLength ) + parametersLength;
storedProcedureLength = languageLength + procedureLength + localParametersLength;
return 1 + TLV.getNbBytes( storedProcedureLength ) + storedProcedureLength;
}
示例15: computeLength
import org.apache.directory.api.util.Strings; //导入方法依赖的package包/类
/**
* Compute the SearchRequest length
* <br>
* SearchRequest :
* <pre>
* 0x63 L1
* |
* +--> 0x04 L2 baseObject
* +--> 0x0A 0x01 scope
* +--> 0x0A 0x01 derefAliases
* +--> 0x02 0x0(1..4) sizeLimit
* +--> 0x02 0x0(1..4) timeLimit
* +--> 0x01 0x01 typesOnly
* +--> filter.computeLength()
* +--> 0x30 L3 (Attribute description list)
* |
* +--> 0x04 L4-1 Attribute description
* +--> 0x04 L4-2 Attribute description
* +--> ...
* +--> 0x04 L4-i Attribute description
* +--> ...
* +--> 0x04 L4-n Attribute description
* </pre>
*/
@Override
public int computeLength()
{
searchRequestLength = 0;
// The baseObject
dnBytes = Strings.getBytesUtf8( getBase().getName() );
searchRequestLength += 1 + TLV.getNbBytes( dnBytes.length ) + dnBytes.length;
// The scope
searchRequestLength += 1 + 1 + 1;
// The derefAliases
searchRequestLength += 1 + 1 + 1;
// The sizeLimit
searchRequestLength += 1 + 1 + BerValue.getNbBytes( getSizeLimit() );
// The timeLimit
searchRequestLength += 1 + 1 + BerValue.getNbBytes( getTimeLimit() );
// The typesOnly
searchRequestLength += 1 + 1 + 1;
// The filter
setFilter( getFilter() );
searchRequestLength +=
getCodecFilter().computeLength();
// The attributes description list
attributeDescriptionListLength = 0;
if ( ( getAttributes() != null ) && ( !getAttributes().isEmpty() ) )
{
attributeNameBytes = new byte[getAttributes().size()][];
int attributeNb = 0;
// Compute the attributes length
for ( String attribute : getAttributes() )
{
// add the attribute length to the attributes length
attributeNameBytes[attributeNb] = Strings.getBytesUtf8( attribute );
int idLength = attributeNameBytes[attributeNb].length;
attributeDescriptionListLength += 1 + TLV.getNbBytes( idLength ) + idLength;
attributeNb++;
}
}
searchRequestLength += 1 + TLV.getNbBytes( attributeDescriptionListLength ) + attributeDescriptionListLength;
// Return the result.
return 1 + TLV.getNbBytes( searchRequestLength ) + searchRequestLength;
}