You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/12/29 16:49:22 UTC
svn commit: r491033 - in
/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema:
NumericNormalizer.java TelephoneNumberNormalizer.java
Author: elecharny
Date: Fri Dec 29 07:49:21 2006
New Revision: 491033
URL: http://svn.apache.org/viewvc?view=rev&rev=491033
Log:
Added those two normalizers
Added:
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NumericNormalizer.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/TelephoneNumberNormalizer.java
Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NumericNormalizer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NumericNormalizer.java?view=auto&rev=491033
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NumericNormalizer.java (added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NumericNormalizer.java Fri Dec 29 07:49:21 2006
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+
+/**
+ * Normalize Numeric Strings
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class NumericNormalizer 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.NUMERIC_STRING );
+ }
+ else
+ {
+ return PrepareString.normalize( ( String ) value,
+ PrepareString.StringType.NUMERIC_STRING );
+ }
+ }
+ catch ( IOException ioe )
+ {
+ throw new NamingException( "Invalid value : " + value );
+ }
+ }
+}
\ No newline at end of file
Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/TelephoneNumberNormalizer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/TelephoneNumberNormalizer.java?view=auto&rev=491033
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/TelephoneNumberNormalizer.java (added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/TelephoneNumberNormalizer.java Fri Dec 29 07:49:21 2006
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+
+/**
+ * Normalize Telephone Number Strings
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class TelephoneNumberNormalizer 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.TELEPHONE_NUMBER );
+ }
+ else
+ {
+ return PrepareString.normalize( ( String ) value,
+ PrepareString.StringType.TELEPHONE_NUMBER );
+ }
+ }
+ catch ( IOException ioe )
+ {
+ throw new NamingException( "Invalid value : " + value );
+ }
+ }
+}
\ No newline at end of file