/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapInvalidDnException { if ( value == null ) { return null; } String strValue = value.getString(); return new StringValue( strValue.trim().toUpperCase() ); }
/** * Create a list of string from a multivalued attribute's values */ private List<String> getStrings( EntryAttribute attr ) { if ( attr == null ) { return EMPTY_LIST; } List<String> strings = new ArrayList<String>( attr.size() ); for ( Value<?> value : attr ) { strings.add( value.getString() ); } return strings; }
/** * Return the normalized value, or the first one of we have more than one (the lowest) * * @return The first normalized value of this RDN */ public String getNormValue() { switch ( nbAtavs ) { case 0: return null; case 1: return atav.getNormValue().getString(); default: return ( ( TreeSet<AVA> ) atavs ).first().getNormValue().getString(); } }
/** * A String representation of a AVA. * * @return A string representing a AVA */ public String toString() { StringBuffer sb = new StringBuffer(); if ( StringTools.isEmpty( normType ) || StringTools.isEmpty( normType.trim() ) ) { return ""; } sb.append( normType ).append( "=" ); if ( normValue != null ) { sb.append( normValue.getString() ); } return sb.toString(); } }
public Value<?> normalize( Value<?> value ) throws LdapException { if ( !value.isBinary() ) { return new StringValue( value.getString().toLowerCase() ); } throw new IllegalStateException( I18n.err( I18n.ERR_473 ) ); }
/** * get the Controls supported by server. * * @return a list of control OIDs supported by server * @throws LdapException */ public List<String> getSupportedControls() throws LdapException { if ( supportedControls != null ) { return supportedControls; } if ( rootDSE == null ) { fetchRootDSE(); } supportedControls = new ArrayList<String>(); EntryAttribute attr = rootDSE.get( SchemaConstants.SUPPORTED_CONTROL_AT ); for (Value<?> value:attr) { supportedControls.add( value.getString() ); } return supportedControls; }
/** * {@inheritDoc} */ public Value<?> normalize( final Value<?> value ) { if ( value == null ) { return null; } if ( !value.isBinary() ) { String str = value.getString(); for ( int i = 0; i < matchers.length; i++ ) { str = matchers[i].replaceAll( str ); } return new StringValue( str ); } return value; }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { if ( value == null ) { return null; } String str = value.getString().trim(); if ( str.length() == 0 ) { return new StringValue( "" ); } else if ( Character.isDigit( str.charAt( 0 ) ) ) { // We do this test to avoid a lowerCasing which cost time return new StringValue( str ); } else { return new StringValue( str.toLowerCase() ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { String str = value.getString(); if ( StringTools.isEmpty( str ) ) { return new StringValue( str ); } return new StringValue( str ); }
/** * <p> * Get the String value, if and only if the value is known to be a String, * otherwise a InvalidAttributeValueException will be thrown * </p> * <p> * Note that this method returns the first value only. * </p> * * @return The value as a String * @throws LdapInvalidAttributeValueException If the value is a byte[] */ public String getString() throws LdapInvalidAttributeValueException { Value<?> value = get(); if ( value instanceof StringValue ) { return value.getString(); } else { String message = I18n.err( I18n.ERR_04131 ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.DIRECTORY_STRING ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.DIRECTORY_STRING ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.TELEPHONE_NUMBER ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidDnException( I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { DN dn = null; String dnStr = value.getString(); dn = new DN( dnStr ); dn.normalize( schemaManager.getNormalizerMapping() ); return new StringValue( dn.getNormName() ); }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.NUMERIC_STRING ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidDnException( I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { if ( value == null ) { return null; } try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.CASE_IGNORE ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } }
/** * Convert the ServerAttribute to a ClientAttribute * * @return An instance of ClientAttribute */ public EntryAttribute toClientAttribute() { // Create the new EntryAttribute EntryAttribute clientAttribute = new DefaultClientAttribute( upId ); // Copy the values for ( Value<?> value:this ) { Value<?> clientValue = null; if ( value instanceof StringValue ) { clientValue = new StringValue( value.getString() ); } else { clientValue = new BinaryValue( value.getBytes() ); } clientAttribute.add( clientValue ); } return clientAttribute; }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { if ( value == null ) { return null; } String strValue = value.getString(); if ( strValue.length() == 0 ) { return new StringValue( "" ); } // if value is a numeric id then return it as is if ( checker.isValidSyntax( strValue ) ) { return value; } // if it is a name we need to do a lookup String oid = schemaManager.getRegistries().getOid( strValue ); if ( oid != null ) { return new StringValue( oid ); } // if all else fails throw new LdapOtherException( I18n.err( I18n.ERR_04225, value ) ); }