public static boolean wordPattern(String pattern, String str) {
		if (str == null || pattern == null)
			return false;
		if (pattern.length() == 0 && str.length() == 0)
			return true;
		HashMap<Character, String> map = new HashMap<Character, String>();
		String[] strs = str.split(" ");
		if (strs.length != pattern.length())
			return false;
		for (int i = 0; i < pattern.length(); i++) {
			if (map.containsKey(pattern.charAt(i))) {
				if (!map.get(pattern.charAt(i)).equals(strs[i]))
					return false;
			} else {
				if (map.containsValue(strs[i]))
					return false;
				map.put(pattern.charAt(i), strs[i]);
			}
		}
		return true;
	}