Example usage for org.apache.commons.validator.routines ISBNValidator convertToISBN13

List of usage examples for org.apache.commons.validator.routines ISBNValidator convertToISBN13

Introduction

In this page you can find the example usage for org.apache.commons.validator.routines ISBNValidator convertToISBN13.

Prototype

public String convertToISBN13(String isbn10) 

Source Link

Document

Convert an ISBN-10 code to an ISBN-13 code.

Usage

From source file:com.github.bfour.fpliteraturecollector.domain.ISBN.java

public ISBN(String v10OrV13String) {

    ISBNValidator validator = ISBNValidator.getInstance();
    String normalizedString = getNormalizedString(v10OrV13String);

    if (validator.isValidISBN13(normalizedString))
        this.v13String = normalizedString;
    else if (validator.isValidISBN10(normalizedString))
        this.v13String = validator.convertToISBN13(normalizedString);
    else//from w w  w  .  j  av  a  2 s . c  o m
        throw new InvalidParameterException("String passed as ISBN is not a valid v10 or v13 ISBN");

}