⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tool.java

📁 这是一个学校老师和学生的管理系统,程序比较简单,但是几乎所有功能都可以实现,如果想要用,只要再添加一些东西就可以了.
💻 JAVA
字号:
/**
 *******************************************************************************
 * Tool.java
 *
 * (c) Copyright 2008 Hewlett-Packard Development Company, L.P.
 *
 *<Program Content>
 *  System Name : Students Management System
 *<Summarize>
 *  The file includes a tool class.
 *<Update Record>
 *  2009-4-18    1.00    zhangliy
 *******************************************************************************
 */
package com.hp.eds.zhangliyuan.stuMan.util;

/**
 * The class main functions:judge whether a string meets the demand.
 * 
 * @author zhangliy
 * @version 1.0
 */
public class Tool {
	/**
	 * judge whether a password is legal
	 * 
	 * @param password
	 *            -the string needs to judge
	 * @return boolean(true:the password is legal;false:the password is illegal)
	 */
	public static boolean isPasswordLegal(String password) {
		if(StringTool.isStringEmpty(password)){
			return true;
		}
		String reg = "\\w{4,8}";
		if (!password.matches(reg)) {
			// the password length is not between 4 and 8
			return false;
		}
		// the password's format is right
		return true;
	}

	/**
	 * judge whether telephone numbers is legal
	 * 
	 * @param phone
	 *            -the string needs to judge
	 * @return boolean(true:the phone numbers is legal;false:the phone numbers
	 *         is empty or it is made up by half angle)
	 */
	public static boolean isPhoneLegal(String phone) {
		if (StringTool.isStringEmpty(phone)) {
			// the phone numbers is empty
			return false;
		}
		String reg = "\\d{8,11}";
		if (phone.matches(reg)) {
			// the phone numbers are all digits,return true
			return true;
		} else {
			// the phone number is not right
			return false;
		}
	}

	/**
	 * judge whether email is legal
	 * 
	 * @param email
	 *            -the string needs to judge
	 * @return boolean(true:the email is legal;false:the email is illegal)
	 */
	public static boolean isEmailLegal(String email) {
		if (StringTool.isStringEmpty(email)) {
			// the email is not empty and made up by half angle characters
			return false;
		}
		String reg = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
		if (email.matches(reg)) {
			// the email's format is right
			return true;
		} else {
			// the email's format is wrong
			return false;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -