directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1789428 [4/5] - in /directory/shared/trunk: integ/src/test/java/org/apache/directory/api/ldap/schema/syntaxCheckers/ ldap/extras/aci/src/main/java/org/apache/directory/api/ldap/aci/ ldap/model/src/main/java/org/apache/directory/api/ldap/mo...
Date Thu, 30 Mar 2017 03:28:29 GMT
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidLenSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidLenSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidLenSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidLenSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -25,8 +25,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -49,15 +47,38 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class OidLenSyntaxChecker extends SyntaxChecker
+public final class OidLenSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( OidLenSyntaxChecker.class );
-    
     /**
      * A static instance of OidLenSyntaxChecker
      */
-    public static final OidLenSyntaxChecker INSTANCE = new OidLenSyntaxChecker();
+    public static final OidLenSyntaxChecker INSTANCE = 
+        new OidLenSyntaxChecker( SchemaConstants.OID_LEN_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<OidLenSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.OID_LEN_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of OidLenSyntaxChecker
+         * @return A new instance of OidLenSyntaxChecker
+         */
+        @Override
+        public OidLenSyntaxChecker build()
+        {
+            return new OidLenSyntaxChecker( oid );
+        }
+    }
 
     
     /**
@@ -65,9 +86,18 @@ public class OidLenSyntaxChecker extends
      * Creates a new instance of OidLenSyntaxChecker.
      *
      */
-    public OidLenSyntaxChecker()
+    private OidLenSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
+     */
+    public static Builder builder()
     {
-        super( SchemaConstants.OID_LEN_SYNTAX );
+        return new Builder();
     }
 
 
@@ -81,7 +111,11 @@ public class OidLenSyntaxChecker extends
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -100,7 +134,11 @@ public class OidLenSyntaxChecker extends
 
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -112,13 +150,16 @@ public class OidLenSyntaxChecker extends
             // Not found ... but it may still be a valid OID
             boolean result = Oid.isOid( strValue );
 
-            if ( result )
+            if ( LOG.isDebugEnabled() )
             {
-                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-            }
-            else
-            {
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                if ( result )
+                {
+                    LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+                }
+                else
+                {
+                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                }
             }
 
             return result;
@@ -130,7 +171,11 @@ public class OidLenSyntaxChecker extends
 
             if ( !Oid.isOid( oid ) )
             {
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                if ( LOG.isDebugEnabled() )
+                {
+                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                }
+                
                 return false;
             }
 
@@ -140,7 +185,11 @@ public class OidLenSyntaxChecker extends
             if ( len.charAt( len.length() - 1 ) != '}' )
             {
                 // No final '}'
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                if ( LOG.isDebugEnabled() )
+                {
+                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                }
+                
                 return false;
             }
 
@@ -161,7 +210,11 @@ public class OidLenSyntaxChecker extends
                         break;
 
                     default:
-                        LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                        if ( LOG.isDebugEnabled() )
+                        {
+                            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                        }
+                        
                         return false;
                 }
             }
@@ -170,11 +223,19 @@ public class OidLenSyntaxChecker extends
             {
                 // A number can't start with a '0' unless it's the only
                 // number
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                if ( LOG.isDebugEnabled() )
+                {
+                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                }
+                
                 return false;
             }
 
-            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            }
+            
             return true;
         }
     }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OidSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -26,8 +26,6 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Chars;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -52,23 +50,56 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class OidSyntaxChecker extends SyntaxChecker
+public final class OidSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( OidSyntaxChecker.class );
-    
     /**
      * A static instance of OidSyntaxChecker
      */
-    public static final OidSyntaxChecker INSTANCE = new OidSyntaxChecker();
+    public static final OidSyntaxChecker INSTANCE = new OidSyntaxChecker( SchemaConstants.OID_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<OidSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.OID_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of OidSyntaxChecker
+         * @return A new instance of OidSyntaxChecker
+         */
+        @Override
+        public OidSyntaxChecker build()
+        {
+            return new OidSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of OidSyntaxChecker.
+     * 
+     * @param oid The OID to use for this SyntaxChecker
+     */
+    private OidSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
      */
-    public OidSyntaxChecker()
+    public static Builder builder()
     {
-        super( SchemaConstants.OID_SYNTAX );
+        return new Builder();
     }
 
 
@@ -82,7 +113,11 @@ public class OidSyntaxChecker extends Sy
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -101,7 +136,11 @@ public class OidSyntaxChecker extends Sy
 
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -109,16 +148,21 @@ public class OidSyntaxChecker extends Sy
         // checked to make sure there are no other chars except '.' and digits.
         if ( Chars.isDigit( strValue.charAt( 0 ) ) )
         {
-            if ( !Oid.isOid( strValue ) )
+            boolean result = Oid.isOid(  strValue  );
+            
+            if ( LOG.isDebugEnabled() )
             {
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
-                return false;
-            }
-            else
-            {
-                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-                return true;
+                if ( result )
+                {
+                    LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+                }
+                else
+                {
+                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                }
             }
+            
+            return result;
         }
 
         // here we just need to make sure that we have the right characters in the 
@@ -131,17 +175,29 @@ public class OidSyntaxChecker extends Sy
                 
                 if ( !Chars.isAlphaDigitMinus( c ) )
                 {
-                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                    if ( LOG.isDebugEnabled() )
+                    {
+                        LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                    }
+                    
                     return false;
                 }
             }
 
-            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            }
+            
             return true;
         }
         else
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
     }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OtherMailboxSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OtherMailboxSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OtherMailboxSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/OtherMailboxSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -24,8 +24,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -39,23 +37,55 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class OtherMailboxSyntaxChecker extends SyntaxChecker
+public final class OtherMailboxSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( OtherMailboxSyntaxChecker.class );
-    
     /**
      * A static instance of OtherMailboxSyntaxChecker
      */
-    public static final OtherMailboxSyntaxChecker INSTANCE = new OtherMailboxSyntaxChecker();
+    public static final OtherMailboxSyntaxChecker INSTANCE = 
+        new OtherMailboxSyntaxChecker( SchemaConstants.OTHER_MAILBOX_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<OtherMailboxSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.OTHER_MAILBOX_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of OtherMailboxSyntaxChecker
+         * @return A new instance of OtherMailboxSyntaxChecker
+         */
+        @Override
+        public OtherMailboxSyntaxChecker build()
+        {
+            return new OtherMailboxSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of OtherMailboxSyntaxChecker.
      */
-    public OtherMailboxSyntaxChecker()
+    private OtherMailboxSyntaxChecker( String oid )
     {
-        super( SchemaConstants.OTHER_MAILBOX_SYNTAX );
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
+     */
+    public static Builder builder()
+    {
+        return new Builder();
     }
 
 
@@ -69,7 +99,11 @@ public class OtherMailboxSyntaxChecker e
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -88,7 +122,11 @@ public class OtherMailboxSyntaxChecker e
 
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -98,7 +136,11 @@ public class OtherMailboxSyntaxChecker e
         if ( dollar == -1 )
         {
             // No '$' => error
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -110,27 +152,38 @@ public class OtherMailboxSyntaxChecker e
         // The mailbox should not contains a '$'
         if ( mailbox.indexOf( '$' ) != -1 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         // Check that the mailboxType is a PrintableString
         if ( !Strings.isPrintableString( mailboxType ) )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         // Check that the mailbox is an IA5String
         boolean result = Strings.isIA5String( mailbox );
 
-        if ( result )
-        {
-            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        }
-        else
+        if ( LOG.isDebugEnabled() )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( result )
+            {
+                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            }
+            else
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
         }
 
         return result;

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PostalAddressSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PostalAddressSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PostalAddressSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PostalAddressSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -24,8 +24,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -39,23 +37,57 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class PostalAddressSyntaxChecker extends SyntaxChecker
+public final class PostalAddressSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( PostalAddressSyntaxChecker.class );
-    
     /**
      * A static instance of PostalAddressSyntaxChecker
      */
-    public static final PostalAddressSyntaxChecker INSTANCE = new PostalAddressSyntaxChecker();
+    public static final PostalAddressSyntaxChecker INSTANCE = 
+        new PostalAddressSyntaxChecker( SchemaConstants.POSTAL_ADDRESS_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<PostalAddressSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.POSTAL_ADDRESS_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of PostalAddressSyntaxChecker
+         * @return A new instance of PostalAddressSyntaxChecker
+         */
+        @Override
+        public PostalAddressSyntaxChecker build()
+        {
+            return new PostalAddressSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of PostalAddressSyntaxChecker.
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public PostalAddressSyntaxChecker()
+    private PostalAddressSyntaxChecker( String oid )
     {
-        super( SchemaConstants.POSTAL_ADDRESS_SYNTAX );
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
+     */
+    public static Builder builder()
+    {
+        return new Builder();
     }
 
 
@@ -69,7 +101,11 @@ public class PostalAddressSyntaxChecker
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -88,7 +124,11 @@ public class PostalAddressSyntaxChecker
 
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -110,7 +150,11 @@ public class PostalAddressSyntaxChecker
 
             if ( Strings.isEmpty( address ) )
             {
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                if ( LOG.isDebugEnabled() )
+                {
+                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                }
+                
                 return false;
             }
 
@@ -119,7 +163,11 @@ public class PostalAddressSyntaxChecker
             if ( pos == strValue.length() )
             {
                 // we should not have a '$' at the end
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                if ( LOG.isDebugEnabled() )
+                {
+                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                }
+                
                 return false;
             }
 

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PresentationAddressSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PresentationAddressSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PresentationAddressSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PresentationAddressSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,10 +20,8 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
-import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 
 
 /**
@@ -34,33 +32,56 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class PresentationAddressSyntaxChecker extends BinarySyntaxChecker
+public final class PresentationAddressSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( PresentationAddressSyntaxChecker.class );
-    
     /**
      * A static instance of PresentationAddressSyntaxChecker
      */
-    public static final PresentationAddressSyntaxChecker INSTANCE = new PresentationAddressSyntaxChecker();
+    public static final PresentationAddressSyntaxChecker INSTANCE = 
+        new PresentationAddressSyntaxChecker( SchemaConstants.PRESENTATION_ADDRESS_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<PresentationAddressSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.PRESENTATION_ADDRESS_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of PresentationAddressSyntaxChecker
+         * @return A new instance of PresentationAddressSyntaxChecker
+         */
+        @Override
+        public PresentationAddressSyntaxChecker build()
+        {
+            return new PresentationAddressSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates an instance of PresentationAddressSyntaxChecker
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public PresentationAddressSyntaxChecker()
+    private PresentationAddressSyntaxChecker( String oid )
     {
-        super( SchemaConstants.PRESENTATION_ADDRESS_SYNTAX );
+        super( oid );
     }
 
-
+    
     /**
-     * {@inheritDoc}
+     * @return An instance of the Builder for this class
      */
-    @Override
-    public boolean isValidSyntax( Object value )
+    public static Builder builder()
     {
-        LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        return true;
+        return new Builder();
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PrintableStringSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PrintableStringSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PrintableStringSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/PrintableStringSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -24,8 +24,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -61,23 +59,57 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class PrintableStringSyntaxChecker extends SyntaxChecker
+public final class PrintableStringSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( PrintableStringSyntaxChecker.class );
-    
     /**
      * A static instance of PrintableStringSyntaxChecker
      */
-    public static final PrintableStringSyntaxChecker INSTANCE = new PrintableStringSyntaxChecker();
+    public static final PrintableStringSyntaxChecker INSTANCE = 
+        new PrintableStringSyntaxChecker( SchemaConstants.PRINTABLE_STRING_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<PrintableStringSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.PRINTABLE_STRING_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of PrintableStringSyntaxChecker
+         * @return A new instance of PrintableStringSyntaxChecker
+         */
+        @Override
+        public PrintableStringSyntaxChecker build()
+        {
+            return new PrintableStringSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of PrintableStringSyntaxChecker.
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public PrintableStringSyntaxChecker()
+    private PrintableStringSyntaxChecker( String oid )
     {
-        super( SchemaConstants.PRINTABLE_STRING_SYNTAX );
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
+     */
+    public static Builder builder()
+    {
+        return new Builder();
     }
 
 
@@ -91,7 +123,11 @@ public class PrintableStringSyntaxChecke
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -110,26 +146,37 @@ public class PrintableStringSyntaxChecke
 
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         // We must have at least one char
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         boolean result = Strings.isPrintableString( strValue );
 
-        if ( result )
-        {
-            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        }
-        else
+        if ( LOG.isDebugEnabled() )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( result )
+            {
+                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            }
+            else
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
         }
 
         return result;

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ProtocolInformationSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ProtocolInformationSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ProtocolInformationSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/ProtocolInformationSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,11 +20,8 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
-import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -34,33 +31,56 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class ProtocolInformationSyntaxChecker extends SyntaxChecker
+public final class ProtocolInformationSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( ProtocolInformationSyntaxChecker.class );
-    
     /**
      * A static instance of ProtocolInformationSyntaxChecker
      */
-    public static final ProtocolInformationSyntaxChecker INSTANCE = new ProtocolInformationSyntaxChecker();
+    public static final ProtocolInformationSyntaxChecker INSTANCE = 
+        new ProtocolInformationSyntaxChecker( SchemaConstants.PROTOCOL_INFORMATION_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<ProtocolInformationSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.PROTOCOL_INFORMATION_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of ProtocolInformationSyntaxChecker
+         * @return A new instance of ProtocolInformationSyntaxChecker
+         */
+        @Override
+        public ProtocolInformationSyntaxChecker build()
+        {
+            return new ProtocolInformationSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of ProtocolInformationSyntaxChecker.
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public ProtocolInformationSyntaxChecker()
+    private ProtocolInformationSyntaxChecker( String oid )
     {
-        super( SchemaConstants.PROTOCOL_INFORMATION_SYNTAX );
+        super( oid );
     }
 
-
+    
     /**
-     * {@inheritDoc}
+     * @return An instance of the Builder for this class
      */
-    @Override
-    public boolean isValidSyntax( Object value )
+    public static Builder builder()
     {
-        LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        return true;
+        return new Builder();
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/RegexSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/RegexSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/RegexSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/RegexSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,13 +20,9 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.util.Strings;
 
 
 /**
@@ -36,55 +32,77 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class RegexSyntaxChecker extends SyntaxChecker
+public final class RegexSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( RegexSyntaxChecker.class );
-
     /** the set of regular expressions */
-    private List<String> expressions;
-    
+    private String[] expressions;
     
     /**
-     * Creates a Syntax validator for a specific Syntax using Perl5 matching
-     * rules for validation.
-     * 
-     * @param oid
-     *            the oid of the Syntax values checked
-     * @param matchExprArray
-     *            the array of matching expressions
+     * A static Builder for this class
      */
-    public RegexSyntaxChecker( String oid, String[] matchExprArray )
+    public static final class Builder extends SCBuilder<RegexSyntaxChecker>
     {
-        super( oid );
-
-        if ( ( matchExprArray != null ) && ( matchExprArray.length != 0 ) )
+        /** the set of regular expressions */
+        private String[] expressions;
+        
+        /**
+         * The Builder constructor
+         */
+        private Builder()
         {
-            expressions = new ArrayList<>( matchExprArray.length );
+            super( null );
+        }
+
 
-            for ( String regexp : matchExprArray )
+        /**
+         * Add a list of regexp to be applied by this SyntaxChecker
+         * 
+         * @param expressions The regexp list to add
+         */
+        public Builder setExpressions( String[] expressions )
+        {
+            if ( ( expressions != null ) && ( expressions.length > 0 ) )
             {
-                expressions.add( regexp );
+                this.expressions = new String[expressions.length];
+                System.arraycopy( expressions, 0, this.expressions, 0, expressions.length );
             }
+            
+            return this;
         }
-        else
+        
+        
+        /**
+         * Create a new instance of RegexSyntaxChecker
+         * @return A new instance of RegexSyntaxChecker
+         */
+        public RegexSyntaxChecker build()
         {
-            expressions = new ArrayList<>();
+            return new RegexSyntaxChecker( oid, expressions );
         }
     }
 
-
+    
     /**
+     * Creates a Syntax validator for a specific Syntax using Perl5 matching
+     * rules for validation.
      * 
-     * Creates a new instance of RegexSyntaxChecker.
-     * 
-     * @param oid the oid to associate with this new SyntaxChecker
-     *
+     * @param oid the oid of the Syntax values checked
+     * @param matchExprArray the array of matching expressions
      */
-    public RegexSyntaxChecker( String oid )
+    private RegexSyntaxChecker( String oid, String[] matchExprArray )
     {
         super( oid );
-        expressions = new ArrayList<>();
+
+        this.expressions = matchExprArray;
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
+     */
+    public static Builder builder()
+    {
+        return new Builder();
     }
 
 
@@ -104,14 +122,20 @@ public class RegexSyntaxChecker extends
             {
                 if ( !str.matches( regexp ) )
                 {
-                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                    if ( LOG.isDebugEnabled() )
+                    {
+                        LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                    }
                     
                     return false;
                 }
             }
         }
 
-        LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+        if ( LOG.isDebugEnabled() )
+        {
+            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+        }
 
         return true;
     }
@@ -124,21 +148,14 @@ public class RegexSyntaxChecker extends
      */
     public String[] getExpressions()
     {
-        String[] exprs = new String[expressions.size()];
-        return expressions.toArray( exprs );
-    }
-
-
-    /**
-     * Add a list of regexp to be applied by this SyntaxChecker
-     * 
-     * @param expressions The regexp list to add
-     */
-    public void setExpressions( String[] expressions )
-    {
-        for ( String regexp : expressions )
+        if ( expressions == null )
         {
-            this.expressions.add( regexp );
+            return Strings.EMPTY_STRING_ARRAY;
         }
+        
+        String[] exprs = new String[expressions.length];
+        System.arraycopy( expressions, 0, exprs, 0, expressions.length );
+        
+        return exprs;
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -24,8 +24,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -41,23 +39,57 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class SearchScopeSyntaxChecker extends SyntaxChecker
+public final class SearchScopeSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( SearchScopeSyntaxChecker.class );
-    
     /**
      * A static instance of SearchScopeSyntaxChecker
      */
-    public static final SearchScopeSyntaxChecker INSTANCE = new SearchScopeSyntaxChecker();
+    public static final SearchScopeSyntaxChecker INSTANCE = 
+        new SearchScopeSyntaxChecker( SchemaConstants.SEARCH_SCOPE_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<SearchScopeSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.SEARCH_SCOPE_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of SearchScopeSyntaxChecker
+         * @return A new instance of SearchScopeSyntaxChecker
+         */
+        @Override
+        public SearchScopeSyntaxChecker build()
+        {
+            return new SearchScopeSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of SearchScopeSyntaxChecker.
+     * 
+     * @param oid The OID to use for this SyntaxChecker
+     */
+    private SearchScopeSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
      */
-    public SearchScopeSyntaxChecker()
+    public static Builder builder()
     {
-        super( SchemaConstants.SEARCH_SCOPE_SYNTAX );
+        return new Builder();
     }
 
 
@@ -71,7 +103,11 @@ public class SearchScopeSyntaxChecker ex
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubstringAssertionSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubstringAssertionSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubstringAssertionSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubstringAssertionSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,10 +20,8 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
-import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 
 
 /**
@@ -35,33 +33,56 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class SubstringAssertionSyntaxChecker extends BinarySyntaxChecker
+public final class SubstringAssertionSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( SubstringAssertionSyntaxChecker.class );
-    
     /**
      * A static instance of SubstringAssertionSyntaxChecker
      */
-    public static final SubstringAssertionSyntaxChecker INSTANCE = new SubstringAssertionSyntaxChecker();
+    public static final SubstringAssertionSyntaxChecker INSTANCE = 
+        new SubstringAssertionSyntaxChecker( SchemaConstants.SUBSTRING_ASSERTION_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<SubstringAssertionSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.SUBSTRING_ASSERTION_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of SubstringAssertionSyntaxChecker
+         * @return A new instance of SubstringAssertionSyntaxChecker
+         */
+        @Override
+        public SubstringAssertionSyntaxChecker build()
+        {
+            return new SubstringAssertionSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates an instance of SubstringAssertionSyntaxChecker
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public SubstringAssertionSyntaxChecker()
+    private SubstringAssertionSyntaxChecker( String oid )
     {
-        super( SchemaConstants.SUBSTRING_ASSERTION_SYNTAX );
+        super( oid );
     }
 
-
+    
     /**
-     * {@inheritDoc}
+     * @return An instance of the Builder for this class
      */
-    @Override
-    public boolean isValidSyntax( Object value )
+    public static Builder builder()
     {
-        LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        return true;
+        return new Builder();
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -28,8 +28,6 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.ldap.model.subtree.SubtreeSpecificationChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -40,26 +38,71 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class SubtreeSpecificationSyntaxChecker extends SyntaxChecker
+public final class SubtreeSpecificationSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( SubtreeSpecificationSyntaxChecker.class );
-
     /** The associated checker */
     private transient SubtreeSpecificationChecker subtreeSpecificationChecker;
     
     /**
      * A static instance of SubtreeSpecificationSyntaxChecker
      */
-    public static final SubtreeSpecificationSyntaxChecker INSTANCE = new SubtreeSpecificationSyntaxChecker();
-
+    public static final SubtreeSpecificationSyntaxChecker INSTANCE = 
+        new SubtreeSpecificationSyntaxChecker( SchemaConstants.SUBTREE_SPECIFICATION_SYNTAX, null );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<SubtreeSpecificationSyntaxChecker>
+    {
+        /** The schemaManager */
+        private SchemaManager schemaManager;
+        
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.SUBTREE_SPECIFICATION_SYNTAX );
+        }
+        
+        
+        public Builder setSchemaManager( SchemaManager schemaManager )
+        {
+            this.schemaManager = schemaManager;
+                
+            return this;
+        }
+        
+        
+        /**
+         * Create a new instance of SubtreeSpecificationSyntaxChecker
+         * @return A new instance of SubtreeSpecificationSyntaxChecker
+         */
+        @Override
+        public SubtreeSpecificationSyntaxChecker build()
+        {
+            return new SubtreeSpecificationSyntaxChecker( oid, schemaManager );
+        }
+    }
     
     /**
      * Creates an instance of SubtreeSpecificationSyntaxChecker
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public SubtreeSpecificationSyntaxChecker()
+    private SubtreeSpecificationSyntaxChecker( String oid, SchemaManager schemaManager )
     {
-        super( SchemaConstants.SUBTREE_SPECIFICATION_SYNTAX );
+        super( oid );
+        subtreeSpecificationChecker = new SubtreeSpecificationChecker( schemaManager );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
+     */
+    public static Builder builder()
+    {
+        return new Builder();
     }
 
 
@@ -73,7 +116,11 @@ public class SubtreeSpecificationSyntaxC
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -92,7 +139,11 @@ public class SubtreeSpecificationSyntaxC
 
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -103,23 +154,21 @@ public class SubtreeSpecificationSyntaxC
                 subtreeSpecificationChecker.parse( strValue );
             }
 
-            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            }
+            
             return true;
         }
         catch ( ParseException pe )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
     }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setSchemaManager( SchemaManager schemaManager )
-    {
-        subtreeSpecificationChecker = new SubtreeSpecificationChecker( schemaManager );
-    }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierAndConsumerSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierAndConsumerSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierAndConsumerSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierAndConsumerSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,11 +20,8 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
-import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -33,33 +30,56 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class SupplierAndConsumerSyntaxChecker extends SyntaxChecker
+public final class SupplierAndConsumerSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( SupplierAndConsumerSyntaxChecker.class );
-    
     /**
      * A static instance of SupplierAndConsumerSyntaxChecker
      */
-    public static final SupplierAndConsumerSyntaxChecker INSTANCE = new SupplierAndConsumerSyntaxChecker();
+    public static final SupplierAndConsumerSyntaxChecker INSTANCE = 
+        new SupplierAndConsumerSyntaxChecker( SchemaConstants.SUPPLIER_AND_CONSUMER_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<SupplierAndConsumerSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.SUPPLIER_AND_CONSUMER_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of SupplierAndConsumerSyntaxChecker
+         * @return A new instance of SupplierAndConsumerSyntaxChecker
+         */
+        @Override
+        public SupplierAndConsumerSyntaxChecker build()
+        {
+            return new SupplierAndConsumerSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates an instance of SupplierAndConsumerSyntaxChecker
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public SupplierAndConsumerSyntaxChecker()
+    private SupplierAndConsumerSyntaxChecker( String oid )
     {
-        super( SchemaConstants.SUPPLIER_AND_CONSUMER_SYNTAX );
+        super( oid );
     }
 
-
+    
     /**
-     * {@inheritDoc}
+     * @return An instance of the Builder for this class
      */
-    @Override
-    public boolean isValidSyntax( Object value )
+    public static Builder builder()
     {
-        LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        return true;
+        return new Builder();
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierInformationSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierInformationSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierInformationSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierInformationSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,11 +20,8 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
-import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -33,33 +30,56 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class SupplierInformationSyntaxChecker extends SyntaxChecker
+public final class SupplierInformationSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( SupplierInformationSyntaxChecker.class );
-    
     /**
      * A static instance of SupplierInformationSyntaxChecker
      */
-    public static final SupplierInformationSyntaxChecker INSTANCE = new SupplierInformationSyntaxChecker();
+    public static final SupplierInformationSyntaxChecker INSTANCE = 
+        new SupplierInformationSyntaxChecker( SchemaConstants.SUPPLIER_INFORMATION_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<SupplierInformationSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.SUPPLIER_INFORMATION_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of SupplierInformationSyntaxChecker
+         * @return A new instance of SupplierInformationSyntaxChecker
+         */
+        @Override
+        public SupplierInformationSyntaxChecker build()
+        {
+            return new SupplierInformationSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates an instance of SupplierInformationSyntaxChecker
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public SupplierInformationSyntaxChecker()
+    private SupplierInformationSyntaxChecker( String oid )
     {
-        super( SchemaConstants.SUPPLIER_INFORMATION_SYNTAX );
+        super( oid );
     }
 
-
+    
     /**
-     * {@inheritDoc}
+     * @return An instance of the Builder for this class
      */
-    @Override
-    public boolean isValidSyntax( Object value )
+    public static Builder builder()
     {
-        LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        return true;
+        return new Builder();
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierOrConsumerSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierOrConsumerSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierOrConsumerSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupplierOrConsumerSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,11 +20,8 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
-import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -33,33 +30,56 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class SupplierOrConsumerSyntaxChecker extends SyntaxChecker
+public final class SupplierOrConsumerSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( SupplierOrConsumerSyntaxChecker.class );
-    
     /**
      * A static instance of SupplierOrConsumerSyntaxChecker
      */
-    public static final SupplierOrConsumerSyntaxChecker INSTANCE = new SupplierOrConsumerSyntaxChecker();
+    public static final SupplierOrConsumerSyntaxChecker INSTANCE = 
+        new SupplierOrConsumerSyntaxChecker( SchemaConstants.SUPPLIER_OR_CONSUMER_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<SupplierOrConsumerSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.SUPPLIER_OR_CONSUMER_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of SupplierOrConsumerSyntaxChecker
+         * @return A new instance of SupplierOrConsumerSyntaxChecker
+         */
+        @Override
+        public SupplierOrConsumerSyntaxChecker build()
+        {
+            return new SupplierOrConsumerSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of SupplierOrConsumerSyntaxChecker.
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public SupplierOrConsumerSyntaxChecker()
+    private SupplierOrConsumerSyntaxChecker( String oid )
     {
-        super( SchemaConstants.SUPPLIER_OR_CONSUMER_SYNTAX );
+        super( oid );
     }
 
-
+    
     /**
-     * {@inheritDoc}
+     * @return An instance of the Builder for this class
      */
-    @Override
-    public boolean isValidSyntax( Object value )
+    public static Builder builder()
     {
-        LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        return true;
+        return new Builder();
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupportedAlgorithmSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupportedAlgorithmSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupportedAlgorithmSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SupportedAlgorithmSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,10 +20,8 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
-import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 
 
 /**
@@ -34,33 +32,56 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class SupportedAlgorithmSyntaxChecker extends BinarySyntaxChecker
+public final class SupportedAlgorithmSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( SupportedAlgorithmSyntaxChecker.class );
-    
     /**
      * A static instance of SupportedAlgorithmSyntaxChecker
      */
-    public static final SupportedAlgorithmSyntaxChecker INSTANCE = new SupportedAlgorithmSyntaxChecker();
+    public static final SupportedAlgorithmSyntaxChecker INSTANCE = 
+        new SupportedAlgorithmSyntaxChecker( SchemaConstants.SUPPORTED_ALGORITHM_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<SupportedAlgorithmSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.SUPPORTED_ALGORITHM_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of SupportedAlgorithmSyntaxChecker
+         * @return A new instance of SupportedAlgorithmSyntaxChecker
+         */
+        @Override
+        public SupportedAlgorithmSyntaxChecker build()
+        {
+            return new SupportedAlgorithmSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of SupportedAlgorithmSyntaxChecker.
+     * 
+     * @param oid The OID to use for this SyntaxChecker
      */
-    public SupportedAlgorithmSyntaxChecker()
+    private SupportedAlgorithmSyntaxChecker( String oid )
     {
-        super( SchemaConstants.SUPPORTED_ALGORITHM_SYNTAX );
+        super( oid );
     }
 
-
+    
     /**
-     * {@inheritDoc}
+     * @return An instance of the Builder for this class
      */
-    @Override
-    public boolean isValidSyntax( Object value )
+    public static Builder builder()
     {
-        LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-        return true;
+        return new Builder();
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SyntaxCheckerSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SyntaxCheckerSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SyntaxCheckerSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/SyntaxCheckerSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,7 +20,10 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
+import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.api.util.Strings;
 
 
 /**
@@ -29,18 +32,104 @@ import org.apache.directory.api.ldap.mod
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class SyntaxCheckerSyntaxChecker extends Ia5StringSyntaxChecker
+public final class SyntaxCheckerSyntaxChecker extends SyntaxChecker
 {
     /**
      * A static instance of SyntaxCheckerSyntaxChecker
      */
-    public static final SyntaxCheckerSyntaxChecker INSTANCE = new SyntaxCheckerSyntaxChecker();
+    public static final SyntaxCheckerSyntaxChecker INSTANCE = 
+        new SyntaxCheckerSyntaxChecker( SchemaConstants.SYNTAX_CHECKER_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<SyntaxCheckerSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.SYNTAX_CHECKER_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of SyntaxCheckerSyntaxChecker
+         * @return A new instance of SyntaxCheckerSyntaxChecker
+         */
+        @Override
+        public SyntaxCheckerSyntaxChecker build()
+        {
+            return new SyntaxCheckerSyntaxChecker( oid );
+        }
+    }
 
     /**
      * Creates a new instance of SyntaxCheckerSyntaxChecker.
+     * 
+     * @param oid The OID to use for this SyntaxChecker
+     */
+    private SyntaxCheckerSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
      */
-    public SyntaxCheckerSyntaxChecker()
+    public static Builder builder()
     {
-        super( SchemaConstants.SYNTAX_CHECKER_SYNTAX );
+        return new Builder();
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isValidSyntax( Object value )
+    {
+        String strValue;
+
+        if ( value == null )
+        {
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
+            return true;
+        }
+
+        if ( value instanceof String )
+        {
+            strValue = ( String ) value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            strValue = Strings.utf8ToString( ( byte[] ) value );
+        }
+        else
+        {
+            strValue = value.toString();
+        }
+
+        boolean result = Strings.isIA5String( strValue );
+
+        if ( LOG.isDebugEnabled() )
+        {
+            if ( result )
+            {
+                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            }
+            else
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+        }
+
+        return result;
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TelephoneNumberSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -20,8 +20,6 @@
 package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
 
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
@@ -29,8 +27,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -49,38 +45,75 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class TelephoneNumberSyntaxChecker extends SyntaxChecker
+public final class TelephoneNumberSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( TelephoneNumberSyntaxChecker.class );
-
-    /** Other regexps to extend the initial one */
-    private List<String> regexps;
-
-    /** Other regexp to extend the initial one, compiled */
-    private List<Pattern> compiledREs;
-
     /** The default pattern used to check a TelephoneNumber */
     private static final String DEFAULT_REGEXP = "^ *[+]? *((\\([0-9- ,;/#*]+\\))|[0-9- ,;/#*]+)+$";
+    
+    /** The compiled default pattern */
+    private String defaultRegexp;
 
     /** The compiled default pattern */
     private Pattern defaultPattern = Pattern.compile( DEFAULT_REGEXP );
 
-    /** A flag set when only the default regexp should be tested */
-    protected boolean defaultMandatory = false;
-    
     /**
      * A static instance of TelephoneNumberSyntaxChecker
      */
-    public static final TelephoneNumberSyntaxChecker INSTANCE = new TelephoneNumberSyntaxChecker();
-
+    public static final TelephoneNumberSyntaxChecker INSTANCE = 
+        new TelephoneNumberSyntaxChecker( SchemaConstants.TELEPHONE_NUMBER_SYNTAX );
     
     /**
-     * Creates a new instance of TelephoneNumberSyntaxChecker.
+     * A static Builder for this class
      */
-    public TelephoneNumberSyntaxChecker()
+    public static final class Builder extends SCBuilder<TelephoneNumberSyntaxChecker>
     {
-        super( SchemaConstants.TELEPHONE_NUMBER_SYNTAX );
+        /** The compiled default pattern */
+        private String defaultRegexp;
+
+        /** The compiled default pattern */
+        private Pattern defaultPattern;
+
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.TELEPHONE_NUMBER_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of TelephoneNumberSyntaxChecker
+         * @return A new instance of TelephoneNumberSyntaxChecker
+         */
+        @Override
+        public TelephoneNumberSyntaxChecker build()
+        {
+            return new TelephoneNumberSyntaxChecker( oid, defaultRegexp, defaultPattern );
+        }
+
+
+        /**
+         * Set the default regular expression for the Telephone number
+         * 
+         * @param regexp the default regular expression.
+         */
+        public Builder setDefaultRegexp( String regexp )
+        {
+            defaultRegexp = regexp;
+            
+            try
+            {
+                defaultPattern = Pattern.compile( regexp );
+            }
+            catch ( PatternSyntaxException pse )
+            {
+                // Roll back to the default pattern
+                defaultPattern = Pattern.compile( DEFAULT_REGEXP );
+            }
+
+            return this;
+        }
     }
 
     
@@ -89,61 +122,51 @@ public class TelephoneNumberSyntaxChecke
      * 
      * @param oid the child's OID
      */
-    protected TelephoneNumberSyntaxChecker( String oid )
+    private TelephoneNumberSyntaxChecker( String oid )
     {
         super( oid );
     }
 
-
+    
     /**
-     * Add a new valid regexp for a Telephone number
-     * @param regexp The new regexp to check
+     * Creates a new instance of a child of this class, with an OID.
+     * 
+     * @param oid the child's OID
+     * @param defaultRegexp The regexp to use
+     * @param defaultPattern The compiled version of the regexp
      */
-    public void addRegexp( String regexp )
+    private TelephoneNumberSyntaxChecker( String oid, String defaultRegexp, Pattern defaultPattern )
     {
-        if ( defaultMandatory )
-        {
-            return;
-        }
-
-        try
-        {
-            Pattern compiledRE = Pattern.compile( regexp );
-
-            if ( regexps == null )
-            {
-                regexps = new ArrayList<>();
-                compiledREs = new ArrayList<>();
-            }
+        super( oid );
+        
+        this.defaultPattern = defaultPattern;
+        this.defaultRegexp = defaultRegexp;
+    }
 
-            regexps.add( regexp );
-            compiledREs.add( compiledRE );
-        }
-        catch ( PatternSyntaxException pse )
-        {
-            return;
-        }
+    
+    /**
+     * @return An instance of the Builder for this class
+     */
+    public static Builder builder()
+    {
+        return new Builder();
     }
 
 
     /**
-     * Set the defaut regular expression for the Telephone number
+     * Get the default regexp (either the original one, or the one that has been set)
      * 
-     * @param regexp the default regular expression.
+     * @return The default regexp
      */
-    public void setDefaultRegexp( String regexp )
+    public String getRegexp()
     {
-        try
+        if ( defaultRegexp == null )
         {
-            defaultPattern = Pattern.compile( regexp );
-
-            defaultMandatory = true;
-            regexps = null;
-            compiledREs = null;
+            return DEFAULT_REGEXP;
         }
-        catch ( PatternSyntaxException pse )
+        else
         {
-            return;
+            return defaultRegexp;
         }
     }
 
@@ -158,7 +181,11 @@ public class TelephoneNumberSyntaxChecke
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -177,72 +204,35 @@ public class TelephoneNumberSyntaxChecke
 
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         // We will use a regexp to check the TelephoneNumber.
-        if ( defaultMandatory )
+        boolean result;
+        
+        // Not sure this is 100% necessary...
+        synchronized ( defaultPattern )
         {
-            // We have a unique regexp to check, the default one
-            // We have to do that in a protected section
-            boolean result;
-            
-            synchronized ( defaultPattern )
-            {
-                result = defaultPattern.matcher( strValue ).matches();
-            }
-
-            if ( result )
-            {
-                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-            }
-            else
-            {
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
-            }
-
-            return result;
+            result = defaultPattern.matcher( strValue ).matches();
         }
-        else
+
+        if ( LOG.isDebugEnabled() )
         {
-            boolean result;
-        
-            synchronized ( defaultPattern )
-            {
-                result = defaultPattern.matcher( strValue ).matches();
-            }
-            
             if ( result )
             {
                 LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-                return true;
             }
             else
             {
-                if ( compiledREs == null )
-                {
-                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
-                    return false;
-                }
-
-                synchronized ( compiledREs )
-                {
-                    // The default is not enough, let's try
-                    // the other regexps
-                    for ( Pattern pattern : compiledREs )
-                    {
-                        if ( pattern.matcher( strValue ).matches() )
-                        {
-                            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
-                            return true;
-                        }
-                    }
-                }
-
                 LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
-                return false;
             }
         }
+
+        return result;
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TeletexTerminalIdentifierSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TeletexTerminalIdentifierSyntaxChecker.java?rev=1789428&r1=1789427&r2=1789428&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TeletexTerminalIdentifierSyntaxChecker.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/syntaxCheckers/TeletexTerminalIdentifierSyntaxChecker.java Thu Mar 30 03:28:27 2017
@@ -24,8 +24,6 @@ import org.apache.directory.api.i18n.I18
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
 import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -43,23 +41,57 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @SuppressWarnings("serial")
-public class TeletexTerminalIdentifierSyntaxChecker extends SyntaxChecker
+public final class TeletexTerminalIdentifierSyntaxChecker extends SyntaxChecker
 {
-    /** A logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( TeletexTerminalIdentifierSyntaxChecker.class );
-    
     /**
      * A static instance of TeletexTerminalIdentifierSyntaxChecker
      */
-    public static final TeletexTerminalIdentifierSyntaxChecker INSTANCE = new TeletexTerminalIdentifierSyntaxChecker();
+    public static final TeletexTerminalIdentifierSyntaxChecker INSTANCE = 
+        new TeletexTerminalIdentifierSyntaxChecker( SchemaConstants.TELETEX_TERMINAL_IDENTIFIER_SYNTAX );
+    
+    /**
+     * A static Builder for this class
+     */
+    public static final class Builder extends SCBuilder<TeletexTerminalIdentifierSyntaxChecker>
+    {
+        /**
+         * The Builder constructor
+         */
+        private Builder()
+        {
+            super( SchemaConstants.TELETEX_TERMINAL_IDENTIFIER_SYNTAX );
+        }
+        
+        
+        /**
+         * Create a new instance of TeletexTerminalIdentifierSyntaxChecker
+         * @return A new instance of TeletexTerminalIdentifierSyntaxChecker
+         */
+        @Override
+        public TeletexTerminalIdentifierSyntaxChecker build()
+        {
+            return new TeletexTerminalIdentifierSyntaxChecker( oid );
+        }
+    }
 
     
     /**
      * Creates a new instance of TeletexTerminalIdentifier.
+     * 
+     * @param oid the child's OID
+     */
+    private TeletexTerminalIdentifierSyntaxChecker( String oid )
+    {
+        super( oid );
+    }
+
+    
+    /**
+     * @return An instance of the Builder for this class
      */
-    public TeletexTerminalIdentifierSyntaxChecker()
+    public static Builder builder()
     {
-        super( SchemaConstants.TELETEX_TERMINAL_IDENTIFIER_SYNTAX );
+        return new Builder();
     }
 
 
@@ -73,7 +105,11 @@ public class TeletexTerminalIdentifierSy
 
         if ( value == null )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, "null" ) );
+            }
+            
             return false;
         }
 
@@ -92,7 +128,11 @@ public class TeletexTerminalIdentifierSy
 
         if ( strValue.length() == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
@@ -104,30 +144,46 @@ public class TeletexTerminalIdentifierSy
         if ( terminalIdentifier.length() == 0 )
         {
             // It should not be null
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         if ( !Strings.isPrintableString( terminalIdentifier ) )
         {
             // It's not a valid PrintableString 
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+            
             return false;
         }
 
         if ( dollar == -1 )
         {
             // No ttx-param : let's get out
-            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+            }
+            
             return true;
         }
 
-        // Ok, now let's deal withh optional ttx-params
+        // Ok, now let's deal with optional ttx-params
         String[] ttxParams = strValue.substring( dollar + 1 ).split( "\\$" );
 
         if ( ttxParams.length == 0 )
         {
-            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+            }
+                
             return false;
         }
 
@@ -138,7 +194,11 @@ public class TeletexTerminalIdentifierSy
             if ( colon == -1 )
             {
                 // we must have a ':' separator
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                if ( LOG.isDebugEnabled() )
+                {
+                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                }
+                
                 return false;
             }
 
@@ -152,7 +212,11 @@ public class TeletexTerminalIdentifierSy
             {
                 if ( colon + 1 == ttxParam.length() )
                 {
-                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                    if ( LOG.isDebugEnabled() )
+                    {
+                        LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                    }
+                    
                     return false;
                 }
 
@@ -164,14 +228,22 @@ public class TeletexTerminalIdentifierSy
                     {
                         case 0x24:
                             // '$' is not accepted
-                            LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                            if ( LOG.isDebugEnabled() )
+                            {
+                                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                            }
+                            
                             return false;
 
                         case 0x5c:
                             if ( hasEsc )
                             {
                                 // two following \ are not accepted
-                                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                                if ( LOG.isDebugEnabled() )
+                                {
+                                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                                }
+                                
                                 return false;
                             }
                             else
@@ -211,12 +283,20 @@ public class TeletexTerminalIdentifierSy
             }
             else
             {
-                LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                if ( LOG.isDebugEnabled() )
+                {
+                    LOG.debug( I18n.err( I18n.ERR_04488_SYNTAX_INVALID, value ) );
+                }
+                
                 return false;
             }
         }
 
-        LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+        if ( LOG.isDebugEnabled() )
+        {
+            LOG.debug( I18n.msg( I18n.MSG_04489_SYNTAX_VALID, value ) );
+        }
+        
         return true;
     }
 }



Mime
View raw message