ISBNValidator.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.apache.commons.validator;

  18. /**
  19.  * A class for validating 10 digit ISBN codes.
  20.  * Based on this
  21.  * <a href="http://www.isbn.org/standards/home/isbn/international/html/usm4.htm">
  22.  * algorithm</a>
  23.  *
  24.  * <b>NOTE:</b> This has been replaced by the new
  25.  *  {@link org.apache.commons.validator.routines.ISBNValidator}.
  26.  *
  27.  * @since 1.2.0
  28.  * @deprecated Use the new ISBNValidator in the routines package
  29.  */
  30. @Deprecated
  31. public class ISBNValidator {

  32.     /**
  33.      * Default Constructor.
  34.      */
  35.     public ISBNValidator() {
  36.     }

  37.     /**
  38.      * If the ISBN is formatted with space or dash separators its format is
  39.      * validated.  Then the digits in the number are weighted, summed, and
  40.      * divided by 11 according to the ISBN algorithm.  If the result is zero,
  41.      * the ISBN is valid.  This method accepts formatted or raw ISBN codes.
  42.      *
  43.      * @param isbn Candidate ISBN number to be validated. {@code null} is
  44.      * considered invalid.
  45.      * @return true if the string is a valid ISBN code.
  46.      */
  47.     public boolean isValid(final String isbn) {
  48.         return org.apache.commons.validator.routines.ISBNValidator.getInstance().isValidISBN10(isbn);
  49.     }

  50. }