private void applyStateRules() throws JSONException {
		pageTypeName = DEFAULT_PAGE_TYPE_NAME;
		userActionName = DEFAULT_USER_ACTION_NAME;
		if (!stateRules.isNull(currentPage))// ҵҳ
		{
			JSONObject jsonPage = stateRules.getJSONObject(currentPage);
			if(!jsonPage.isNull("similarPage") && !stateRules.isNull(jsonPage.getString("similarPage")) )
			{
				jsonPage=stateRules.getJSONObject(jsonPage.getString("similarPage"));
			}
			if (!jsonPage.isNull("pageTypeRules")) {
				JSONObject jsonTypeRules = jsonPage
						.getJSONObject("pageTypeRules");
				if (!jsonTypeRules.isNull("defaultTypeName")) {
					pageTypeName = jsonTypeRules.getString("defaultTypeName");
				}

				if (currentHmParameters.size() == 0)// Ϊ0
				{
					if (!jsonTypeRules.isNull("hasNoParams")) {
						pageTypeName = jsonTypeRules.getString("hasNoParams");
					}
				} else if (!jsonTypeRules.isNull("withParams")) {
					JSONArray jsonTypeRulesWithParams = jsonTypeRules
							.getJSONArray("withParams");
					for (int i = 0; i < jsonTypeRulesWithParams.length(); i++) {
						JSONObject jsonTypeRule = (JSONObject) jsonTypeRulesWithParams
								.get(i);
						if (canApplyTypeRule(jsonTypeRule
								.getJSONObject("typeCondition"))) {
							pageTypeName = (String) jsonTypeRule
									.getString("typeName");
							break;
						}
					}
				}
			}
			if (!jsonPage.isNull("userActionRules")) {
				JSONObject jsonActionRules = jsonPage
						.getJSONObject("userActionRules");
				if (!jsonActionRules.isNull("defaultActionName")) {
					userActionName = jsonActionRules
							.getString("defaultActionName");
				}
				// жpreviousҳǷΪ
				if (previousPage.equals("")) {
					if (!jsonActionRules.isNull("invalidPreUrl")) {
						userActionName = jsonActionRules
								.getString("invalidPreUrl");
					}
				}
				// ҳ治ͬ
				else if (!diffPreAndCur) {
					if (!jsonActionRules.isNull("diffWithPrePage")) {
						if (!jsonActionRules.getJSONObject("diffWithPrePage")
								.isNull(previousPage)) {
							userActionName = jsonActionRules.getJSONObject(
									"diffWithPrePage").getString(previousPage);
						} else if (!jsonActionRules.getJSONObject(
								"diffWithPrePage").isNull("defaultPage")) {
							userActionName = jsonActionRules.getJSONObject(
									"diffWithPrePage").getString("defaultPage");
						}
					}
				}
				// ҳͬ
				else {
					if(!jsonActionRules.isNull("sameWithPrePage"))
					{
						for (int i = 0; i < jsonActionRules
								.getJSONArray("sameWithPrePage").length(); i++) {
							JSONObject jsonActionRule = (JSONObject) jsonActionRules
									.getJSONArray("sameWithPrePage").get(i);
							if (canApplyActionRule(jsonActionRule)) {
								userActionName = (String) jsonActionRule
										.getString("actionName");
								break;
							}
						}
					}
				}
			}
		} else {
			// TODO Auto-generated catch block
			// Ҳҳ
			if (!getJsoupDocFromDb("info_urls","url_md5",currentUrl_md5))// ȡҳjsoupĵ, ûлȡjsoupĵ
			{
				//System.out.println("urlmd5ȡĵʧܣ");
				if(!getJsoupDocFromWeb(currentUrl))
				{
					//System.out.println("urlȡĵʧܣ");
				}
			}
			JSONArray jsonUrlRules;
			try {
				jsonUrlRules = stateRules.getJSONObject("beyondListPages")
						.getJSONArray("urlRules");
				for (int i = 0; i < jsonUrlRules.length(); i++) {
					JSONObject jsonUrlRule = (JSONObject) jsonUrlRules.get(i);
					if (canApplyBeyondListPageRule(jsonUrlRule
							.getJSONObject("urlCondition"))) {
						pageTypeName = (String) jsonUrlRule
								.getString("typeName");
						userActionName=(String) jsonUrlRule
								.getString("defaultActionName");
						break;
					}
				}
				// e.printStackTrace();
			} catch (JSONException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
	}