/*
 *  IsJpPostalAddress
 *
 * Created: Mon Apr 22 17:32:50 2002
 * $Revision$
 * Modified: $Date$
 *
 * Author: Jun Inamori
 * E-mail: jun@oop-reserch.com
 *
 * Copyright (c) 1998-2001 Jun Inamori
 * 2-24-7 Shinsenri-Kitamachi, Toyonaka ,
 * Osaka 560-0081 , Japan.
 * All rights reserved.
 *
 */
package com.oopreserch.web;

/**
 * Implementation of {@link FormValueVerifier} interface.
 * Returns <i>true</i> for the char used for postal address.
 *
 * @author Jun Inamori
 */
public class IsJpPostalAddress extends AbstractVerifier{

/**
 * Returns <i>true</i> for the postal address in Japanase
 * characters. Otherwise <i>false</i>.
 * <br>
 * <br>
 * <font colors="#ff0000">This method works well only for
 * characters from the typical Japanese environment.</font>
 * This method returns <i>true</i> for:
 * <ul>
 * <li>Japanese Kanji</li>
 * <li>Japanese Hiragana</li>
 * <li>Japanese Katakana (half or full width)</li>
 * <li>Japanese Punctuation (half or full width)</li>
 * <li>Full width Ascii Symbols</li>
 * <li>Full width 0 to 9</li>
 * <li>Ascii space</li>
 * <li>Ascii line feed</li>
 * <li>Ascii cariage return</li>
 * <li>Ascii 0 to 9</li>
 * <li>Ascii - (hyphen)</li>
 * </ul>
 * because the postal address can be represented by these
 * characters in Japanese langauge.
 * <br>
 * <br>
 * @param ch <i>char</i> to be tested.
 * @return <i>true</i> for the char used for postal address.
 */
    public boolean isValid(char ch){
	if(Character.isWhitespace(ch)){
	    return true;
	}
	if(isDigit(ch)){
	    return true;
	}
	// True for ascii hyphen
	if(ch==((char)('\u002D'))){
	    return true;
	}
	// True for full width hyphen
	if(ch==((char)('\uFF0D'))){
	    return true;
	}
	if((isBasicLatin(ch))||(isFullWidthAlphabet(ch))||(isFullWidthAsciiSymbol(ch))){
	    return false;
	}
	// As for the typical Japanese environment,
	// we can safely assume the rest of the characters
	// are acceptable as the postal address.
	return true;
    }

} //End of : IsJpPostalAddress