本文整理汇总了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;
}
}
示例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;
}
示例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;
}
}
示例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 );
}
示例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;
}
示例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();
}
示例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 );
}
示例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 );
}
示例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();
}