/** * A local Syntax class used for the tests */ public static LdapSyntax syntaxFactory( String oid, boolean humanReadable ) { LdapSyntax ldapSyntax = new LdapSyntax( oid ); ldapSyntax.setHumanReadable( humanReadable ); return ldapSyntax; } static class S extends LdapSyntax
setUpId( null, attributeType ); if ( attributeType.getSyntax().isHumanReadable() )
/** * Attempts to resolve the SyntaxChecker associated with a Syntax. * * @param syntax the LdapSyntax to resolve the SyntaxChecker of * @param errors the list of errors to add exceptions to */ private void resolve( LdapSyntax syntax, List<Throwable> errors ) { // A LdapSyntax must point to a valid SyntaxChecker // or to the OctetString SyntaxChecker try { syntax.addToRegistries( errors, this ); } catch ( LdapException e ) { errors.add( e ); } }
/** * Copy a LdapSyntax */ public LdapSyntax copy() { LdapSyntax copy = new LdapSyntax( oid ); // Copy the SchemaObject common data copy.copy( this ); // Copy the HR flag copy.isHumanReadable = isHumanReadable; // All the references to other Registries object are set to null. copy.syntaxChecker = null; return copy; }
buf.append( syntax.getOid() ); buf.append( '\n' ); if ( syntax.getDescription() != null ) buf.append( syntax.getDescription() ); buf.append( '\n' ); if ( syntax.getExtensions() != null ) getExtensions( buf, syntax.getExtensions() );
buf.append( "( " ).append( syntax.getOid() ); if ( syntax.getDescription() != null ) renderQDString( buf, syntax.getDescription() ); buf.append( syntax.getSchemaName() ); if ( syntax.isHumanReadable() )
/* No protection */ static AttributeType getBytesAttributeType() LdapSyntax syntax = new LdapSyntax( "1.2.1", "", true ); syntax.setSyntaxChecker( new SyntaxChecker( "1.2.1" )
ldapSyntax = new LdapSyntax(numericoid(oid.getText())); et.track("NAME", name); ldapSyntax.setNames(qdescrs(name.getText())); et.track("DESC", desc); ldapSyntax.setDescription(qdstring(desc.getText())); ldapSyntax.addExtension(ex.key, ex.values);
return ldapSyntax.equals( that.ldapSyntax );
LdapSyntax syntax = new LdapSyntax( "1.1.1", "", true ); syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2" )
if ( syntax.equals( that.syntax ) )
/** * 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; }
LdapSyntax syntax = new LdapSyntax( oid ); syntax.setHumanReadable( val.toUpperCase().equals( "TRUE" ) );
/* no protection*/ static AttributeType getCaseIgnoringAttributeNoNumbersType() LdapSyntax syntax = new LdapSyntax( "1.1.1.1", "", true ); syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2.1" )
/** * 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; }
/** * @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() )
/** * @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 ); } } }
public ServerEntry getAttributes( LdapSyntax syntax, Schema schema, SchemaManager schemaManager ) throws LdapException { ServerEntry entry = new DefaultServerEntry( schemaManager ); entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SYNTAX_OC ); entry.put( MetaSchemaConstants.X_HUMAN_READABLE_AT, getBoolean( syntax.isHumanReadable() ) ); entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() ); entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ); injectCommon( syntax, entry, schemaManager ); return entry; }
if ( type.getSyntax().isHumanReadable() )