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.normalizers;
021
022
023import org.apache.directory.api.ldap.model.constants.SchemaConstants;
024import org.apache.directory.api.ldap.model.exception.LdapException;
025import org.apache.directory.api.ldap.model.schema.Normalizer;
026import org.apache.directory.api.ldap.model.schema.PrepareString;
027
028
029/**
030 * Normalize Telephone Number Strings. We don't process substring differently, as we don't
031 * have any significant space in a Telephone Number.
032 *
033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
034 */
035@SuppressWarnings("serial")
036public class TelephoneNumberNormalizer extends Normalizer
037{
038    /**
039     * Creates a new instance of TelephoneNumberNormalizer.
040     */
041    public TelephoneNumberNormalizer()
042    {
043        super( SchemaConstants.TELEPHONE_NUMBER_MATCH_MR_OID );
044    }
045
046
047    /**
048     * {@inheritDoc}
049     */
050    @Override
051    public String normalize( String value ) throws LdapException
052    {
053        return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE );
054    }
055    
056
057    /**
058     * {@inheritDoc}
059     */
060    @Override
061    public String normalize( String value, PrepareString.AssertionType assertiontype ) throws LdapException
062    {
063        if ( value == null )
064        {
065            return null;
066        }
067
068        char[] chars = value.toCharArray();
069        
070        // Insignificant Characters Handling
071        return PrepareString.insignificantTelephoneNumberStringHandling( chars );
072    }
073}