001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    package org.apache.directory.shared.ldap.schema.syntaxes;
021    
022    
023    import javax.naming.NamingException;
024    
025    import org.apache.directory.shared.ldap.schema.SyntaxChecker;
026    
027    
028    /**
029     * A SyntaxChecker implementation which accepts all values as valid.
030     * 
031     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032     * @version $Rev: 736240 $
033     */
034    public class AcceptAllSyntaxChecker implements SyntaxChecker
035    {
036        /** the OID of the Syntax this checker is associated with */
037        private String oid;
038    
039    
040        /**
041         * Creates a SyntaxChecker which accepts all values.
042         * 
043         * @param oid the oid of the Syntax this checker is associated with
044         */
045        public AcceptAllSyntaxChecker( String oid )
046        {
047            this.oid = oid;
048        }
049    
050        
051        public AcceptAllSyntaxChecker()
052        {
053        }
054    
055        
056        public void setSyntaxOid( String oid )
057        {
058            this.oid = oid;
059        }
060        
061        
062        /**
063         * @see SyntaxChecker#getSyntaxOid()
064         * 
065         * @return the OID syntax
066         */
067        public String getSyntaxOid()
068        {
069            return oid;
070        }
071    
072    
073        /**
074         * Returns true every time.
075         * 
076         * @see SyntaxChecker#isValidSyntax(Object)
077         * 
078         * @param value the value of some attribute with the syntax
079         * @return true if the value is in the valid syntax, false otherwise
080         */
081        public boolean isValidSyntax( Object value )
082        {
083            return true;
084        }
085    
086    
087        /**
088         * Does nothing but return immediately and no exceptions are ever thrown.
089         * 
090         * @see SyntaxChecker#assertSyntax(Object)
091         * 
092         * @param value the value of some attribute with the syntax
093         * @throws NamingException if the value does not conform to the attribute syntax.
094         */
095        public void assertSyntax( Object value ) throws NamingException
096        {
097        }
098    }