public Syntax getSyntax() throws NamingException { if ( syntaxId != null ) { return this.syntaxRegistry.lookup( syntaxId ); } if ( superiorId != null ) { return getSuperior().getSyntax(); } return null; }
/** * Creates a BinaryValue without an initial wrapped value. * * @param attributeType the schema type associated with this BinaryValue */ public BinaryValue( AttributeType attributeType ) { if ( attributeType == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_04442 ) ); } if ( attributeType.getSyntax() == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_04445 ) ); } if ( attributeType.getSyntax().isHumanReadable() ) { LOG.warn( "Treating a value of a human readible attribute {} as binary: ", attributeType.getName() ); } this.attributeType = attributeType; }
/** * Creates a StringValue without an initial wrapped value. * * @param attributeType the schema type associated with this StringValue */ public StringValue( AttributeType attributeType ) { if ( attributeType == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_04442 ) ); } if ( attributeType.getSyntax() == null ) { throw new IllegalArgumentException( I18n.err( I18n.ERR_04445 ) ); } if ( ! attributeType.getSyntax().isHumanReadable() ) { LOG.warn( "Treating a value of a binary attribute {} as a String: " + "\nthis could cause data corruption!", attributeType.getName() ); } this.attributeType = attributeType; }
/** * @return The Syntax associated with the AttributeType */ public Syntax getSyntax() throws NamingException { if ( syntax == null ) { if ( syntaxId != null ) { syntax = syntaxRegistry.lookup( syntaxId ); } else if ( superiorId != null ) { syntax = getSuperior().getSyntax(); } } return syntax; }
setUpId( null, attributeType ); if ( attributeType.getSyntax().isHumanReadable() )
return attributeType.getSyntax().getSyntaxChecker().isValidSyntax( null );
/** * Uses the syntaxChecker associated with the attributeType to check if the * value is valid. Repeated calls to this method do not attempt to re-check * the syntax of the wrapped value every time if the wrapped value does not * change. Syntax checks only result on the first check, and when the wrapped * value changes. * * @see Value#isValid() */ public final boolean isValid() { if ( valid != null ) { return valid; } if ( attributeType != null ) { valid = attributeType.getSyntax().getSyntaxChecker().isValidSyntax( get() ); } else { valid = false; } return valid; }
if ( !type.getSyntax().isHumanReadible() )
this.syntax = superior.getSyntax(); this.syntaxOid = this.syntax.getOid();
/** * @see NameComponentNormalizer#normalizeByName(String, String) */ public Object normalizeByName( String name, byte[] value ) throws LdapException { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name ); if ( !attributeType.getSyntax().isHumanReadable() ) { return lookup( name ).normalize( new BinaryValue( value ) ); } else { try { String valStr = new String( value, "UTF-8" ); return lookup( name ).normalize( valStr ); } catch ( UnsupportedEncodingException uee ) { String message = I18n.err( I18n.ERR_04223 ); LOG.error( message ); throw new LdapException( message ); } } }
if ( attributeType.getSyntax().isHumanReadable() )
asBinary = !type.getSyntax().isHumanReadible(); asBinary = asBinary || binaries.contains( type );
/** * @see NameComponentNormalizer#normalizeByName(String, String) */ public Object normalizeByName( String name, String value ) throws LdapException { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name ); if ( attributeType.getSyntax().isHumanReadable() ) { return lookup( name ).normalize( value ); } else { try { String unescaped = unescape( value ); byte[] valBytes = unescaped.getBytes( "UTF-8" ); return lookup( name ).normalize( new BinaryValue( valBytes ) ); } catch ( UnsupportedEncodingException uee ) { String message = I18n.err( I18n.ERR_04222 ); LOG.error( message ); throw new LdapException( message ); } } }
if ( attributeType.getSyntax().isHumanReadible() )
if ( type.getSyntax().isHumanReadable() )
if ( attributeType.getSyntax().isHumanReadable() )
isHR = attributeType.getSyntax().isHumanReadable();