本文整理了Java中org.apache.directory.api.util.Strings
类的一些代码示例,展示了Strings
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Strings
类的具体详情如下:
包路径:org.apache.directory.api.util.Strings
类名称:Strings
[英]Various string manipulation methods that are more efficient then chaining string operations: all is done in the same buffer without creating a bunch of string objects.
[中]各种比链接字符串操作更高效的字符串操作方法:所有操作都在同一个缓冲区中完成,而无需创建一组字符串对象。
代码示例来源: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: org.apache.directory.api/api-ldap-client-all
if ( ( schemaObject == null ) || Strings.isEmpty( schemaObject.trim() ) )
throw new ParseException( I18n.err( I18n.ERR_13716_NULL_OR_EMPTY_STRING_SCHEMA_OBJECT ), 0 );
throw new ParseException( e.getMessage(), 0 );
代码示例来源:origin: org.apache.directory.api/api-ldap-schema-converter
/**
* 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_15002_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 );
}
代码示例来源:origin: org.apache.directory.api/api-all
public Entry add( String upId, Value... values ) throws LdapException
if ( Strings.isEmpty( upId ) )
String message = I18n.err( I18n.ERR_13204_NULL_ATTRIBUTE_ID );
LOG.error( message );
throw new IllegalArgumentException( message );
add( upId, schemaManager.lookupAttributeTypeRegistry( upId ), values );
attribute.add( values );
attribute.setUpId( upId );
代码示例来源:origin: org.apache.directory.api/api-ldap-model
sb.append( " Entry : '" ).append( name.toString() ).append( "'\n" );
sb.append( " Attribute description : '" ).append( attrId ).append( "'\n" );
sb.append( " Attribute value : '" );
if ( attrVal.isHumanReadable() )
sb.append( attrVal.getValue() );
byte[] binVal = attrVal.getBytes();
sb.append( Strings.utf8ToString( binVal ) ).append( '/' ).append( Strings.dumpBytes( binVal ) )
.append( "'\n" );
代码示例来源:origin: org.apache.directory.api/api-all
public void action( CertGenerationContainer container ) throws DecoderException
{
BerValue value = container.getCurrentTLV().getValue();
String issuerDN = Strings.utf8ToString( value.getData() );
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_08207_ISSUER_DN, issuerDN ) );
}
if ( ( issuerDN != null ) && ( issuerDN.trim().length() > 0 ) )
{
if ( !Dn.isValid( issuerDN ) )
{
String msg = I18n.err( I18n.ERR_08203_INVALID_ISSUER_DN, issuerDN );
LOG.error( msg );
throw new DecoderException( msg );
}
container.getCertGenerationRequest().setIssuerDN( issuerDN );
}
}
} );
代码示例来源:origin: org.apache.directory.server/apacheds-core-api
/**
* @see Object#toString()
*/
public String toString()
{
return "CompareContext for Dn '" + getDn().getName() + "'"
+ ( ( oid != null ) ? ", oid : <" + oid + ">" : "" )
+ ( ( value != null )
? ", value :'"
+ ( ( value.isHumanReadable() )
? value.getValue()
: ( ( !value.isHumanReadable() )
? Strings.dumpBytes( value.getBytes() )
: "unknown value type" ) )
+ "'"
: "" );
}
}
代码示例来源: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
/**
* 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
/**
* {@inheritDoc}
*/
@Override
public BindFuture bindAsync( Dn name, String credentials ) throws LdapException
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_04102_BIND_REQUEST, name ) );
}
// The password must not be empty or null
if ( Strings.isEmpty( credentials ) && ( !Dn.EMPTY_DN.equals( name ) ) )
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_04105_MISSING_PASSWORD ) );
}
throw new LdapAuthenticationException( I18n.msg( I18n.MSG_04105_MISSING_PASSWORD ) );
}
// Create the BindRequest
BindRequest bindRequest = createBindRequest( name, Strings.getBytesUtf8( credentials ) );
return bindAsync( bindRequest );
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-all
/**
* Compute the DelRequest length
* <br>
* DelRequest :
* <pre>
* 0x4A L1 entry
*
* L1 = Length(entry)
* Length(DelRequest) = Length(0x4A) + Length(L1) + L1
* </pre>
*/
@Override
public int computeLength()
{
dnBytes = Strings.getBytesUtf8( getName().getName() );
int dnLength = dnBytes.length;
// The entry
return 1 + TLV.getNbBytes( dnLength ) + dnLength;
}
代码示例来源:origin: org.apache.directory.api/api-ldap-model
/**
* {@inheritDoc}
*/
@Override
public String normalize( String value, PrepareString.AssertionType assertionType ) throws LdapException
{
if ( Strings.isEmpty( value ) )
{
return value;
}
// if value is a numeric id then return it as is
if ( checker.isValidSyntax( value ) )
{
return value;
}
// if it is a name we need to do a lookup
String oid = schemaManager.getRegistries().getOid( value );
if ( oid != null )
{
return oid;
}
// if all else fails
throw new LdapOtherException( I18n.err( I18n.ERR_13725_CANNOT_HANDLE_NAME_AND_OPTIONAL_UID_NORM, value ) );
}
代码示例来源:origin: org.apache.directory.server/apacheds-protocol-ldap
/**
* Try to authenticate the usr against the underlying LDAP server.
*/
private CoreSession authenticate( String user, String password ) throws InvalidNameException, Exception
{
BindOperationContext bindContext = new BindOperationContext( getLdapSession().getCoreSession() );
bindContext.setDn( new Dn( user ) );
bindContext.setCredentials( Strings.getBytesUtf8( password ) );
getAdminSession().getDirectoryService().getOperationManager().bind( bindContext );
return bindContext.getSession();
}
代码示例来源:origin: org.apache.directory.server/apacheds-core-api
/**
* @see Object#toString()
*/
public String toString()
{
return "BindContext for Dn '" + getDn().getName() + "', credentials <"
+ ( credentials != null ? Strings.dumpBytes( credentials ) : "" ) + ">"
+ ( saslMechanism != null ? ", saslMechanism : <" + saslMechanism + ">" : "" )
+ ( saslAuthId != null ? ", saslAuthId <" + saslAuthId + ">" : "" );
}
代码示例来源:origin: org.apache.directory.api/api-ldap-model
/**
* {@inheritDoc}
*/
@Override
public boolean contains( String upId, byte[]... values )
{
if ( Strings.isEmpty( upId ) )
{
return false;
}
String id = getId( upId );
if ( schemaManager != null )
{
try
{
return contains( schemaManager.lookupAttributeTypeRegistry( id ), values );
}
catch ( LdapException le )
{
return false;
}
}
Attribute attribute = attributes.get( id );
if ( attribute == null )
{
return false;
}
return attribute.contains( values );
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-all
public void action( AdDirSyncContainer container )
{
BerValue value = container.getCurrentTLV().getValue();
byte[] cookie = value.getData();
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_08000_COOKIE, Strings.dumpBytes( cookie ) ) );
}
container.getAdDirSyncControl().setCookie( cookie );
container.setGrammarEndAllowed( true );
}
} );
代码示例来源:origin: org.apache.directory.server/apacheds-core-api
/**
* {@inheritDoc}
*/
@Override
public void dumpIndex( PartitionTxn partitionTxn, OutputStream stream, String name ) throws IOException
{
stream.write( Strings.getBytesUtf8( "Nothing to dump for index " + name ) );
}
代码示例来源:origin: org.apache.directory.api/api-all
/**
* {@inheritDoc}
*/
@Override
public String getProcedureSpecification()
{
return Strings.utf8ToString( procedure );
}
代码示例来源:origin: org.apache.directory.api/api-all
@Override
public void action( SortRequestContainer container ) throws DecoderException
{
BerValue value = container.getCurrentTLV().getValue();
String matchingRuleOid = Strings.utf8ToString( value.getData() );
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_05309_MATCHING_RULE_OID, matchingRuleOid ) );
}
container.getCurrentKey().setMatchingRuleId( matchingRuleOid );
container.setGrammarEndAllowed( true );
}
代码示例来源:origin: org.apache.directory.api/api-ldap-model
/**
* 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();
}
内容来源于网络,如有侵权,请联系作者删除!