Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 90071 invoked from network); 29 Dec 2006 17:02:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Dec 2006 17:02:13 -0000 Received: (qmail 91571 invoked by uid 500); 29 Dec 2006 17:02:20 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 91515 invoked by uid 500); 29 Dec 2006 17:02:20 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 91504 invoked by uid 99); 29 Dec 2006 17:02:20 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Dec 2006 09:02:20 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Dec 2006 09:02:12 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id F25141A981D; Fri, 29 Dec 2006 09:01:18 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r491049 - /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/GeneralizedTimeNormalizer.java Date: Fri, 29 Dec 2006 17:01:18 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061229170118.F25141A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Fri Dec 29 09:01:18 2006 New Revision: 491049 URL: http://svn.apache.org/viewvc?view=rev&rev=491049 Log: Created the class. It is not implemented yet. Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/GeneralizedTimeNormalizer.java Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/GeneralizedTimeNormalizer.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/GeneralizedTimeNormalizer.java?view=auto&rev=491049 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/GeneralizedTimeNormalizer.java (added) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/GeneralizedTimeNormalizer.java Fri Dec 29 09:01:18 2006 @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.schema; + + +import java.io.IOException; + +import javax.naming.NamingException; + +import org.apache.directory.shared.ldap.util.StringTools; + + +/** + * Normalizer which normalize a time following those rules : + * - if minutes are ommited, then they are replaced by 00 + * - if seconds are ommited, then they are replaced by 00 + * - if fraction is 0, it is removed + * - the time is supposed to be expressed in Zulu (GMT), so + * increment is applied to hours/days/yeah, and a Z is added at the end. + * + * @author Apache Directory Project + * @version $Rev: 491034 $ + */ +public class GeneralizedTimeNormalizer implements Normalizer +{ + static final long serialVersionUID = 1L; + + public Object normalize( Object value ) throws NamingException + { + try + { + if ( value instanceof byte[] ) + { + return PrepareString.normalize( StringTools.utf8ToString( ( byte[] ) value ), + PrepareString.StringType.DIRECTORY_STRING ); + } + else + { + return PrepareString.normalize( ( String ) value, + PrepareString.StringType.DIRECTORY_STRING ); + } + } + catch ( IOException ioe ) + { + throw new NamingException( "Invalid value : " + value ); + } + } +} \ No newline at end of file