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 */
020package org.apache.directory.api.ldap.model.schema.syntaxCheckers;
021
022
023import org.apache.directory.api.ldap.model.constants.SchemaConstants;
024import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
025
026
027/**
028 * A SyntaxChecker which verifies that a value is a Octet String according to RFC 4517.
029 * <p>
030 * From RFC 4517 :
031 * <pre>
032 * OctetString = *OCTET
033 * </pre>
034 * From RFC 4512 :
035 * <pre>
036 * OCTET   = %x00-FF ; Any octet (8-bit data unit)
037 * </pre>
038 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
039 */
040@SuppressWarnings("serial")
041public final class OctetStringSyntaxChecker extends SyntaxChecker
042{
043    /**
044     * A static instance of OctetStringSyntaxChecker
045     */
046    public static final OctetStringSyntaxChecker INSTANCE = 
047        new OctetStringSyntaxChecker( SchemaConstants.OCTET_STRING_SYNTAX );
048    
049    /**
050     * A static Builder for this class
051     */
052    public static final class Builder extends SCBuilder<OctetStringSyntaxChecker>
053    {
054        /**
055         * The Builder constructor
056         */
057        private Builder()
058        {
059            super( SchemaConstants.OCTET_STRING_SYNTAX );
060        }
061        
062        
063        /**
064         * Create a new instance of OctetStringSyntaxChecker
065         * @return A new instance of OctetStringSyntaxChecker
066         */
067        @Override
068        public OctetStringSyntaxChecker build()
069        {
070            return new OctetStringSyntaxChecker( oid );
071        }
072    }
073
074    
075    /**
076     * Creates a new instance of OctetStringSyntaxChecker, with a specific OID
077     * 
078     * @param oid The Syntax's OID 
079     */
080    private OctetStringSyntaxChecker( String oid )
081    {
082        super( oid );
083    }
084
085    
086    /**
087     * @return An instance of the Builder for this class
088     */
089    public static Builder builder()
090    {
091        return new Builder();
092    }
093}