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
021package org.apache.directory.shared.ldap.model.schema.normalizers;
022
023import org.apache.directory.shared.ldap.model.schema.Normalizer;
024
025
026/**
027 * The OidNomalizer class contains a tuple: an OID with its Normalizer.  It itself
028 * is not a normalizer.
029 * 
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 */
032public class OidNormalizer
033{
034    /** The oid */
035    private String attributeTypeOid;
036
037    /** The normalizer to be used with this OID */
038    private Normalizer normalizer;
039
040
041    /**
042     * A constructor which accept two parameters
043     * 
044     * @param attributeTypeOid the oid of the attributeType mapped to the normalizer
045     * @param normalizer the associated equality match based normalizer
046     */
047    public OidNormalizer( String attributeTypeOid, Normalizer normalizer )
048    {
049        this.attributeTypeOid = attributeTypeOid;
050        this.normalizer = normalizer;
051    }
052
053
054    /**
055     * A copy constructor.
056     * 
057     * @param oidNormalizer the OidNormalizer to copy from
058     */
059    public OidNormalizer( OidNormalizer oidNormalizer )
060    {
061        attributeTypeOid = oidNormalizer.attributeTypeOid;
062        normalizer = oidNormalizer.normalizer;
063    }
064
065
066    /**
067     * Get the normalizer
068     * 
069     * @return The normalizer associated to the current OID
070     */
071    public Normalizer getNormalizer()
072    {
073        return normalizer;
074    }
075
076
077    /**
078     * Get the current name
079     * 
080     * @return The current name
081     */
082    public String getAttributeTypeOid()
083    {
084        return attributeTypeOid;
085    }
086    
087    
088    /**
089     * Copy an OidNormalizer(). The contained Normalizer will be cloned too.
090     * 
091     * @return A deep clone of the current OidNormalizer
092     */
093    public OidNormalizer copy() throws CloneNotSupportedException
094    {
095        OidNormalizer copy = new OidNormalizer( attributeTypeOid, normalizer );
096
097        // Copy the SchemaObject common data
098        copy.copy();
099        
100        return copy;
101    }
102
103
104    /**
105     * Return a String representation of this class
106     */
107    public String toString()
108    {
109        return "OidNormalizer : { " + attributeTypeOid + ", " + normalizer.toString() + "}";
110    }
111}