Java Code Examples for org.apache.directory.api.util.Strings#lowerCaseAscii()
The following examples show how to use
org.apache.directory.api.util.Strings#lowerCaseAscii() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Rdn.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Get the Ava which type is given as an argument. If we * have more than one value associated with the type, we will return only * the first one. * * @param type The type of the NameArgument to be returned * @return The Ava, of null if none is found. */ public Ava getAva( String type ) { // First, let's normalize the type String normalizedType = Strings.lowerCaseAscii( Strings.trim( type ) ); switch ( nbAvas ) { case 0: return null; case 1: if ( ava.getNormType().equals( normalizedType ) ) { return ava; } return null; default: List<Ava> avaList = avaTypes.get( normalizedType ); if ( avaList != null ) { return avaList.get( 0 ); } return null; } }
Example 2
Source File: Ava.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Construct an Ava. The type and value are normalized : * <ul> * <li> the type is trimmed and lowercased </li> * <li> the value is trimmed </li> * </ul> * <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_13600_TYPE_IS_NULL_OR_EMPTY ); 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(); }
Example 3
Source File: Ava.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Construct an Ava. The type and value are normalized : * <ul> * <li> the type is trimmed and lowercased </li> * <li> the value is trimmed </li> * </ul> * <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_13600_TYPE_IS_NULL_OR_EMPTY ); // Do NOT log the message here. The error may be handled and therefore the log message may polute the log files. // Let the caller log the exception if needed. 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(); }
Example 4
Source File: Rdn.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Get the value of the Ava which type is given as an * argument. * * @param type the type of the NameArgument * @return the value to be returned, or null if none found. * @throws LdapInvalidDnException if the Rdn is invalid */ public Object getValue( String type ) throws LdapInvalidDnException { // First, let's normalize the type String normalizedType = Strings.lowerCaseAscii( Strings.trim( type ) ); if ( schemaManager != null ) { AttributeType attributeType = schemaManager.getAttributeType( normalizedType ); if ( attributeType != null ) { normalizedType = attributeType.getOid(); } } switch ( nbAvas ) { case 0: return ""; case 1: if ( ava.getNormType().equals( normalizedType ) ) { if ( ava.getValue() != null ) { return ava.getValue().getString(); } else { return null; } } return ""; default: List<Ava> avaList = avaTypes.get( normalizedType ); if ( avaList != null ) { for ( Ava elem : avaList ) { if ( elem.getNormType().equals( normalizedType ) ) { if ( elem.getValue() != null ) { return elem.getValue().getString(); } else { return null; } } } return null; } return null; } }