List of usage examples for org.apache.commons.lang StringUtils startsWith
public static boolean startsWith(String str, String prefix)
Check if a String starts with a specified prefix.
From source file:com.prowidesoftware.swift.model.SwiftTagListBlock.java
/** * Get the index of the given tag in the list. * * @param startTagNumber the number of the tag, without any letter option * @param letterOptions list of letter options to search, an empty string is accepted to search no letter option * @return the index inside the internal list of the given tag, <code>null</code> if the tag is not found * @since 6.5//from w w w . j a v a 2 s .com */ public Integer getTagIndex(final String startTagNumber, final String[] letterOptions) { for (int i = 0; i < this.tags.size(); i++) { final Tag t = (Tag) this.tags.get(i); if (StringUtils.startsWith(t.getName(), startTagNumber)) { // check letter options if (letterOptions == null || letterOptions.length < 1) { return i; } else { for (final String l : letterOptions) { if (StringUtils.equals(t.getName(), startTagNumber + l)) { return i; } } } } } return null; }
From source file:eu.europeana.corelib.edm.utils.EdmUtils.java
private static boolean isUri(String str) { return StringUtils.startsWith(str, "http://") || StringUtils.startsWith(str, "https://") || StringUtils.startsWith(str, "urn:") || StringUtils.startsWith(str, "#"); }
From source file:autoInsurance.BeiJPiccImpl.java
public String queryBaseData(String in, Map<String, String> map) { // TODO Auto-generated method stub JSONObject jsonObject = JSONObject.fromObject(in); String chepNu = jsonObject.getString("chepNu"); String chejh = jsonObject.getString("chejh"); String fadjh = jsonObject.getString("fadjh"); String enrollDate1, enrollDate2; Map<String, Object> outMap = new HashMap<String, Object>(); outMap.put("uuid", map.get("uuid")); if (chepNu != null && !chepNu.equals("")) chepNu = chepNu.toUpperCase();/*w w w .j a v a 2 s . c o m*/ else return queryBaseData2(chejh, fadjh, map); map2map(templateData, map); map.put("prpCitemCar.licenseNo", chepNu); outMap.put("licenseNo", chepNu); String url = "http://10.134.136.48:8000/prpall/carInf/getDataFromCiCarInfo.do"; String respStr = httpClientUtil.doPost(url, map, "gbk"); System.out.println(respStr); Map carMap = JackJson.fromJsonToObject(respStr, Map.class); if (((List) carMap.get("data")).size() > 0) { Map data = (Map) ((List) carMap.get("data")).get(0); map.put("prpCitemCar.frameNo", (String) data.get("rackNo")); outMap.put("frameNo", data.get("rackNo")); map.put("prpCitemCar.vinNo", (String) data.get("rackNo")); outMap.put("vinNo", data.get("rackNo")); map.put("prpCitemCar.engineNo", (String) data.get("engineNo")); outMap.put("engineNo", data.get("engineNo")); map.put("prpCitemCar.enrollDate", timeStamp2Date("" + (Long) ((Map) data.get("enrollDate")).get("time"), "yyyy-M-d")); outMap.put("enrollDate", map.get("prpCitemCar.enrollDate")); // enrollDate1 = map.get("prpCitemCar.enrollDate"); int eny = 0; try { eny = new SimpleDateFormat("yyyy-M-d").parse(map.get("prpCitemCar.enrollDate")).getYear(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } map.put("prpCitemCar.useYears", "" + (new Date().getYear() - eny)); outMap.put("useYears", map.get("prpCitemCar.useYears")); map.put("prpCcarShipTax.prePayTaxYear", "" + (Calendar.getInstance().get(Calendar.YEAR) - 1)); map.put("prpCitemCar.carKindCode", "A01"); //map.put("prpCitemCar.carKindCode", (String)data.get("carKindCode")); map.put("CarKindCodeDes", carTypeMap.get((String) data.get("carKindCode"))); if (StringUtils.startsWith(((String) data.get("carKindCode")), "K")) { map.put("prpCitemCar.licenseType", "80"); } else if (StringUtils.startsWith(((String) data.get("carKindCode")), "M")) { map.put("prpCitemCar.licenseType", "81"); } else { map.put("prpCitemCar.licenseType", (String) ((Map) data.get("id")).get("licenseType")); } outMap.put("licenseType", map.get("prpCitemCar.licenseType")); String carOwner = (String) data.get("carOwner"); if (null != carOwner) { map.put("insuredCarOwner", carOwner); outMap.put("insuredCarOwner", map.get("insuredCarOwner")); map.put("prpCinsureds[0].insuredName", carOwner); outMap.put("insuredName", map.get("prpCinsureds[0].insuredName")); map.put("owner", carOwner); outMap.put("owner", map.get("owner")); map.put("prpCcarShipTax.taxPayerName", carOwner); } String tonCount = data.get("tonCount") == null ? "0" : data.get("tonCount") + ""; map.put("prpCitemCar.tonCount", tonCount); // outMap.put("tonCount", map.get("prpCitemCar.tonCount")); String seatCount = "" + (Integer) data.get("seatCount"); if (StringUtils.isNotBlank(seatCount)) { map.put("prpCitemCar.seatCount", seatCount); outMap.put("seatCount", map.get("prpCitemCar.seatCount")); } } else return "{\"success\": flase, \"msg\": \"" + chepNu + "\"}"; ; url = "http://10.134.136.48:8000/prpall/carInf/getCarModelInfo.do"; respStr = httpClientUtil.doPost(url, map, "gbk"); System.out.println(respStr); Map car2Map = JackJson.fromJsonToObject(respStr, Map.class); List<Map> dataList = (List<Map>) car2Map.get("data"); if (dataList.size() > 0) { Map itemMap = dataList.get(0); if (itemMap.get("refCode2") != null && !itemMap.get("refCode2").equals("")) return "{\"success\": flase, \"msg\": \"" + itemMap.get("refCode2") + "\"}"; map.put("prpCitemCar.brandName", (String) itemMap.get("modelName")); outMap.put("brandName", map.get("prpCitemCar.brandName")); map.put("prpCitemCar.countryNature", (String) itemMap.get("vehicleType")); map.put("prpCitemCar.modelCode", (String) itemMap.get("modelCode")); outMap.put("modelCode", map.get("prpCitemCar.modelCode")); map.put("CarActualValueTrue", "" + itemMap.get("replaceMentValue")); map.put("prpCitemCar.purchasePrice", "" + itemMap.get("replaceMentValue")); map.put("purchasePriceOld", "" + itemMap.get("replaceMentValue")); if (itemMap.get("disPlaceMent") != null) { map.put("prpCitemCar.exhaustScale", "" + Integer.parseInt(itemMap.get("disPlaceMent") + "") / 1000.00); } else { map.put("prpCitemCar.exhaustScale", ""); } outMap.put("exhaustScale", map.get("prpCitemCar.exhaustScale")); if (!map.get("comCode").startsWith("11")) { System.out.println("comCode 11"); return null; } else { String seatCount = map.get("prpCitemCar.seatCount"); String l = "" + itemMap.get("rateDPassengercapacity"); String w = map.get("riskCode"); if (seatCount.equals("0") || seatCount.equals("") && l != null) { map.put("prpCitemCar.seatCount", l); } if ("DAV".equals(w) && Integer.parseInt(seatCount) >= 9) { map.put("prpCitemCar.brandName", ""); map.put("prpCitemCar.modelCode", ""); } String F = itemMap.get("tonnage") == null ? "0" : itemMap.get("tonnage") + ""; if (F != null && (map.get("prpCitemCar.tonCount").equals("0") || map.get("prpCitemCar.tonCount").equals(""))) { map.put("prpCitemCar.tonCount", F); } map.put("prpCitemCar.modelDemandNo", (String) itemMap.get("modelCode")); map.put("prpCitemCar.modelDemandNo", (String) ((Map) itemMap.get("id")).get("pmQueryNo")); map.put("isQueryCarModelFlag", "1"); } map.put("_insuredName", (String) itemMap.get("owner")); url = "http://10.134.136.48:8000/prpall/business/calActualValue.do"; respStr = httpClientUtil.doPost(url, map, "gbk"); System.out.println(respStr); map.put("prpCitemCar.actualValue", respStr); outMap.put("actualValue", respStr); map.put("premiumChangeFlag", "1"); } else { System.out.println("getCarModelInfo "); return null; } // url = "http://10.134.136.48:8000/prpall/business/selectRenewal.do"; Map<String, String> map4xub = null; try { map4xub = parse2Map("prpCrenewalVo.licenseNo=" + chepNu + "&prpCrenewalVo.licenseType=02"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } respStr = httpClientUtil.doPost(url, map4xub, "GBK"); String lastPolicyNo = ""; JSONObject jObj = JSONObject.fromObject(respStr); JSONArray jdatas = jObj.getJSONArray("data"); Iterator<Object> it = jdatas.iterator(); while (it.hasNext()) { JSONObject obj = (JSONObject) it.next(); lastPolicyNo = obj.getString("policyNo"); } //outMap.put("lastPolicyNo", lastPolicyNo); System.out.println("lastPolicyNo: " + lastPolicyNo); Map<String, Object> xubCopyMap = new HashMap<String, Object>(); List<Map<String, String>> list = new ArrayList<Map<String, String>>(); if (!lastPolicyNo.equals("")) { url = "http://10.134.136.48:8000/prpall/business/quickProposalEditRenewalCopy.do?bizNo=" + lastPolicyNo; System.out.println(": " + url); respStr = httpClientUtil.doPost(url, new HashMap<String, String>(), "GBK"); // PrintWriter out; // try { // out = new PrintWriter("d:\\1.html"); // out.write(respStr); // respStr2 = readFile2Strng("d:\\1.html"); // // } catch (Exception e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // write2Html(respStr); Document doc = Jsoup.parse(respStr); //if(doc.getElementById("prpCitemCar.licenseNo") != null) { //return "{\"success\": flase, \"msg\": \"\"}"; if (doc.getElementById("prpCmainHeadInput") != null) { String lastYearBaoQi = ""; Elements elements = doc.select("#prpCmainHeadInput strong"); for (Element element : elements) { if (element.toString().contains("")) { lastYearBaoQi = element.text(); break; } } System.out.println(": " + lastYearBaoQi); xubCopyMap.put("lastYearBaoQi", lastYearBaoQi); } if (doc.getElementById("prpCitemCar.licenseNo") != null) { String licenseNo = doc.getElementById("prpCitemCar.licenseNo").attr("value"); System.out.println(": " + licenseNo); xubCopyMap.put("licenseNo", licenseNo); } if (doc.getElementById("prpCitemCar.modelCodeAlias") != null) { String modelCodeAlias = doc.getElementById("prpCitemCar.modelCodeAlias").attr("value"); System.out.println(": " + modelCodeAlias); xubCopyMap.put("modelCodeAlias", modelCodeAlias); } String new_engineNo = ""; if (doc.getElementById("prpCitemCar.engineNo") != null) { String engineNo = doc.getElementById("prpCitemCar.engineNo").attr("value"); System.out.println(": " + engineNo); xubCopyMap.put("engineNo", engineNo); new_engineNo = engineNo; } String new_frameNo = ""; if (doc.getElementById("prpCitemCar.frameNo") != null) { String frameNo = doc.getElementById("prpCitemCar.frameNo").attr("value"); System.out.println(": " + frameNo); xubCopyMap.put("frameNo", frameNo); new_frameNo = frameNo; } if (doc.getElementById("prpCitemCar.useNatureCode") != null) { String useNatureCode = doc.getElementById("prpCitemCar.useNatureCode").attr("title"); System.out.println(": " + useNatureCode); xubCopyMap.put("useNatureCode", useNatureCode); } if (doc.getElementById("prpCitemCar.enrollDate") != null) { String enrollDate = doc.getElementById("prpCitemCar.enrollDate").attr("value"); System.out.println(": " + enrollDate); xubCopyMap.put("enrollDate", enrollDate); // enrollDate2 = enrollDate; try { Date date1 = new SimpleDateFormat("yyyy-MM-dd").parse(enrollDate1); Date date2 = new SimpleDateFormat("yyyy-MM-dd").parse(enrollDate2); if (!date1.equals(date2)) { System.out.println(""); System.out.println(": " + new_frameNo + "\t: " + new_engineNo); return queryBaseData2(new_frameNo, new_engineNo, map); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (doc.getElementById("prpCitemCar.modelCode") != null) { String modelCode = doc.getElementById("prpCitemCar.modelCode").attr("value"); System.out.println(": " + modelCode); xubCopyMap.put("modelCode", modelCode); } if (doc.getElementById("prpCitemCar.purchasePrice") != null) { String purchasePrice = doc.getElementById("prpCitemCar.purchasePrice").attr("value"); System.out.println(": " + purchasePrice); xubCopyMap.put("purchasePrice", purchasePrice); } if (doc.getElementById("prpCitemCar.seatCount") != null) { String seatCount = doc.getElementById("prpCitemCar.seatCount").attr("value"); System.out.println("(): " + seatCount); xubCopyMap.put("seatCount", seatCount); } if (doc.getElementById("prpCitemCar.exhaustScale") != null) { String exhaustScale = doc.getElementById("prpCitemCar.exhaustScale").attr("value"); System.out.println("/(): " + exhaustScale); xubCopyMap.put("exhaustScale", exhaustScale); } if (doc.getElementById("prpCinsureds[0].insuredName") != null) { String insuredName = doc.getElementById("prpCinsureds[0].insuredName").attr("value"); System.out.println(": " + insuredName); xubCopyMap.put("insuredName", insuredName); } if (doc.getElementById("prpCinsureds[0].identifyNumber") != null) { String identifyNumber = doc.getElementById("prpCinsureds[0].identifyNumber").attr("value"); System.out.println(": " + identifyNumber); xubCopyMap.put("identifyNumber", identifyNumber); } if (doc.getElementById("prpCinsureds[0].insuredAddress") != null) { String insuredAddress = doc.getElementById("prpCinsureds[0].insuredAddress").attr("value"); System.out.println(": " + insuredAddress); xubCopyMap.put("insuredAddress", insuredAddress); } if (doc.getElementById("prpCinsureds[0].mobile") != null) { String mobile = doc.getElementById("prpCinsureds[0].mobile").attr("value"); System.out.println(": " + mobile); xubCopyMap.put("mobile", mobile); } System.out.println(); Element element = null; for (int i = 0; i < 11; i++) { Map<String, String> xianzMap = new HashMap<String, String>(); element = doc.getElementById("prpCitemKindsTemp[" + i + "].chooseFlag"); // System.out.println(element.toString()); String xianz = ""; if (element != null) xianz = element.attr("checked"); // if(xianz.equals("")) // continue; if (i == 0) xianzMap.put("A", xianz); if (i == 1) xianzMap.put("G", xianz); if (i == 2) xianzMap.put("B", xianz); if (i == 3) xianzMap.put("D11", xianz); if (i == 4) xianzMap.put("D12", xianz); if (i == 5) xianzMap.put("L", xianz); if (i == 6) xianzMap.put("F", xianz); if (i == 8) xianzMap.put("Z", xianz); if (i == 9) xianzMap.put("X1", xianz); element = doc.getElementById("prpCitemKindsTemp[" + i + "].specialFlag"); String bujmp = ""; if (element != null) bujmp = element.attr("checked"); xianzMap.put("bujmp", bujmp); element = doc.getElementById("prpCitemKindsTemp[" + i + "].amount"); String amount = ""; if (element != null) amount = element.attr("value"); xianzMap.put("amount", amount); element = doc.getElementById("prpCitemKindsTemp[" + i + "].modeCode"); String modeCode = ""; if (element != null) { Elements tmp = element.select("option"); for (Element et : tmp) { System.out.println(et.toString()); if (et.hasAttr("selected")) { modeCode = tmp.get(0).attr("value"); break; } } } xianzMap.put("modeCode", modeCode); System.out.print(i + ": " + xianz); System.out.print("\t\tbujmp: " + bujmp); System.out.println("\t\tamount: " + amount); System.out.println("\t\tmodeCode: " + modeCode); list.add(xianzMap); } } xubCopyMap.put("xianZDetail", list); outMap.put("xubCopy", xubCopyMap); // map2mapEx(map, outMap); return JSONObject.fromObject(outMap) + ""; }
From source file:autoInsurance.BeiJPiccImpl.java
String queryBaseData2(String new_frameNo, String new_engineNo, Map<String, String> map) { Map<String, Object> outMap = new HashMap<String, Object>(); outMap.put("uuid", map.get("uuid")); map2map(templateData, map);// w w w .j av a 2 s .c o m String chepNu = ""; //String url = "http://10.134.136.48:8000/prpall/carInf/getDataFromCiCarInfo.do"; String url2 = "http://10.134.136.48:8000/prpall/carInf/getCarInfoList.do" + "?pageSize=10&pageNo=1&comCode=11026871&prpCitemCar.licenseNo=%BE%A9&prpCitemCar.engineNo=" + new_engineNo + "&prpCitemCar.frameNo=" + new_frameNo + "&queryType=1"; String respStr = httpClientUtil.doPost(url2, new HashMap<String, String>(), "gbk"); System.out.println(respStr); Map carMap = JackJson.fromJsonToObject(respStr, Map.class); if (((List) carMap.get("data")).size() > 0) { Map data = (Map) ((List) carMap.get("data")).get(0); outMap.put("licenseNo", data.get("id.licenseNo")); chepNu = data.get("id.licenseNo") + ""; map.put("prpCitemCar.licenseNo", chepNu); map.put("prpCitemCar.frameNo", (String) data.get("rackNo")); outMap.put("frameNo", data.get("rackNo")); map.put("prpCitemCar.vinNo", (String) data.get("rackNo")); outMap.put("vinNo", data.get("rackNo")); map.put("prpCitemCar.engineNo", (String) data.get("engineNo")); outMap.put("engineNo", data.get("engineNo")); map.put("prpCitemCar.enrollDate", timeStamp2Date("" + (Long) ((Map) data.get("enrollDate")).get("time"), "yyyy-M-d")); outMap.put("enrollDate", map.get("prpCitemCar.enrollDate")); int eny = 0; try { eny = new SimpleDateFormat("yyyy-M-d").parse(map.get("prpCitemCar.enrollDate")).getYear(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } map.put("prpCitemCar.useYears", "" + (new Date().getYear() - eny)); outMap.put("useYears", map.get("prpCitemCar.useYears")); map.put("prpCcarShipTax.prePayTaxYear", "" + (Calendar.getInstance().get(Calendar.YEAR) - 1)); map.put("prpCitemCar.carKindCode", "A01"); //map.put("prpCitemCar.carKindCode", (String)data.get("carKindCode")); map.put("CarKindCodeDes", carTypeMap.get((String) data.get("carKindCode"))); if (StringUtils.startsWith(((String) data.get("carKindCode")), "K")) { map.put("prpCitemCar.licenseType", "80"); } else if (StringUtils.startsWith(((String) data.get("carKindCode")), "M")) { map.put("prpCitemCar.licenseType", "81"); } else { map.put("prpCitemCar.licenseType", data.get("id.licenseType") + ""); } outMap.put("licenseType", map.get("prpCitemCar.licenseType")); String carOwner = (String) data.get("carOwner"); if (null != carOwner) { map.put("insuredCarOwner", carOwner); outMap.put("insuredCarOwner", map.get("insuredCarOwner")); map.put("prpCinsureds[0].insuredName", carOwner); outMap.put("insuredName", map.get("prpCinsureds[0].insuredName")); map.put("owner", carOwner); outMap.put("owner", map.get("owner")); map.put("prpCcarShipTax.taxPayerName", carOwner); } String tonCount = data.get("tonCount") == null ? "0" : data.get("tonCount") + ""; map.put("prpCitemCar.tonCount", tonCount); // outMap.put("tonCount", map.get("prpCitemCar.tonCount")); String seatCount = "" + (Integer) data.get("seatCount"); if (StringUtils.isNotBlank(seatCount)) { map.put("prpCitemCar.seatCount", seatCount); outMap.put("seatCount", map.get("prpCitemCar.seatCount")); } } else return "{\"success\": flase, \"msg\": \"" + new_frameNo + ", " + new_engineNo + "\"}"; ; String url = "http://10.134.136.48:8000/prpall/carInf/getCarModelInfo.do"; respStr = httpClientUtil.doPost(url, map, "gbk"); System.out.println(respStr); Map car2Map = JackJson.fromJsonToObject(respStr, Map.class); List<Map> dataList = (List<Map>) car2Map.get("data"); if (dataList.size() > 0) { Map itemMap = dataList.get(0); if (itemMap.get("refCode2") != null && !itemMap.get("refCode2").equals("")) return "{\"success\": flase, \"msg\": \"" + itemMap.get("refCode2") + "\"}"; map.put("prpCitemCar.brandName", (String) itemMap.get("modelName")); outMap.put("brandName", map.get("prpCitemCar.brandName")); map.put("prpCitemCar.countryNature", (String) itemMap.get("vehicleType")); map.put("prpCitemCar.modelCode", (String) itemMap.get("modelCode")); outMap.put("modelCode", map.get("prpCitemCar.modelCode")); map.put("CarActualValueTrue", "" + itemMap.get("replaceMentValue")); map.put("prpCitemCar.purchasePrice", "" + itemMap.get("replaceMentValue")); map.put("purchasePriceOld", "" + itemMap.get("replaceMentValue")); if (itemMap.get("disPlaceMent") != null) { map.put("prpCitemCar.exhaustScale", "" + Integer.parseInt(itemMap.get("disPlaceMent") + "") / 1000.00); } else { map.put("prpCitemCar.exhaustScale", ""); } outMap.put("exhaustScale", map.get("prpCitemCar.exhaustScale")); if (!map.get("comCode").startsWith("11")) { System.out.println("comCode 11"); return null; } else { String seatCount = map.get("prpCitemCar.seatCount"); String l = "" + itemMap.get("rateDPassengercapacity"); String w = map.get("riskCode"); if (seatCount.equals("0") || seatCount.equals("") && l != null) { map.put("prpCitemCar.seatCount", l); } if ("DAV".equals(w) && Integer.parseInt(seatCount) >= 9) { map.put("prpCitemCar.brandName", ""); map.put("prpCitemCar.modelCode", ""); } String F = itemMap.get("tonnage") == null ? "0" : itemMap.get("tonnage") + ""; if (F != null && (map.get("prpCitemCar.tonCount").equals("0") || map.get("prpCitemCar.tonCount").equals(""))) { map.put("prpCitemCar.tonCount", F); } map.put("prpCitemCar.modelDemandNo", (String) itemMap.get("modelCode")); map.put("prpCitemCar.modelDemandNo", (String) ((Map) itemMap.get("id")).get("pmQueryNo")); map.put("isQueryCarModelFlag", "1"); } map.put("_insuredName", (String) itemMap.get("owner")); url = "http://10.134.136.48:8000/prpall/business/calActualValue.do"; respStr = httpClientUtil.doPost(url, map, "gbk"); System.out.println(respStr); map.put("prpCitemCar.actualValue", respStr); outMap.put("actualValue", respStr); map.put("premiumChangeFlag", "1"); } else { System.out.println("getCarModelInfo "); return null; } // url = "http://10.134.136.48:8000/prpall/business/selectRenewal.do"; Map<String, String> map4xub = null; try { map4xub = parse2Map("prpCrenewalVo.licenseNo=" + chepNu + "&prpCrenewalVo.licenseType=02"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } respStr = httpClientUtil.doPost(url, map4xub, "GBK"); String lastPolicyNo = ""; JSONObject jObj = JSONObject.fromObject(respStr); JSONArray jdatas = jObj.getJSONArray("data"); Iterator<Object> it = jdatas.iterator(); while (it.hasNext()) { JSONObject obj = (JSONObject) it.next(); lastPolicyNo = obj.getString("policyNo"); } //outMap.put("lastPolicyNo", lastPolicyNo); System.out.println("lastPolicyNo: " + lastPolicyNo); Map<String, Object> xubCopyMap = new HashMap<String, Object>(); List<Map<String, String>> list = new ArrayList<Map<String, String>>(); if (!lastPolicyNo.equals("")) { url = "http://10.134.136.48:8000/prpall/business/quickProposalEditRenewalCopy.do?bizNo=" + lastPolicyNo; System.out.println(": " + url); respStr = httpClientUtil.doPost(url, new HashMap<String, String>(), "GBK"); // PrintWriter out; // try { // out = new PrintWriter("d:\\1.html"); // out.write(respStr); // respStr2 = readFile2Strng("d:\\1.html"); // // } catch (Exception e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // write2Html(respStr); Document doc = Jsoup.parse(respStr); //if(doc.getElementById("prpCitemCar.licenseNo") != null) { //return "{\"success\": flase, \"msg\": \"\"}"; if (doc.getElementById("prpCmainHeadInput") != null) { String lastYearBaoQi = ""; Elements elements = doc.select("#prpCmainHeadInput strong"); for (Element element : elements) { if (element.toString().contains("")) { lastYearBaoQi = element.text(); break; } } System.out.println(": " + lastYearBaoQi); xubCopyMap.put("lastYearBaoQi", lastYearBaoQi); } if (doc.getElementById("prpCitemCar.licenseNo") != null) { String licenseNo = doc.getElementById("prpCitemCar.licenseNo").attr("value"); System.out.println(": " + licenseNo); xubCopyMap.put("licenseNo", licenseNo); } if (doc.getElementById("prpCitemCar.modelCodeAlias") != null) { String modelCodeAlias = doc.getElementById("prpCitemCar.modelCodeAlias").attr("value"); System.out.println(": " + modelCodeAlias); xubCopyMap.put("modelCodeAlias", modelCodeAlias); } if (doc.getElementById("prpCitemCar.engineNo") != null) { String engineNo = doc.getElementById("prpCitemCar.engineNo").attr("value"); System.out.println(": " + engineNo); xubCopyMap.put("engineNo", engineNo); new_engineNo = engineNo; } if (doc.getElementById("prpCitemCar.frameNo") != null) { String frameNo = doc.getElementById("prpCitemCar.frameNo").attr("value"); System.out.println(": " + frameNo); xubCopyMap.put("frameNo", frameNo); new_frameNo = frameNo; } if (doc.getElementById("prpCitemCar.useNatureCode") != null) { String useNatureCode = doc.getElementById("prpCitemCar.useNatureCode").attr("title"); System.out.println(": " + useNatureCode); xubCopyMap.put("useNatureCode", useNatureCode); } if (doc.getElementById("prpCitemCar.enrollDate") != null) { String enrollDate = doc.getElementById("prpCitemCar.enrollDate").attr("value"); System.out.println(": " + enrollDate); xubCopyMap.put("enrollDate", enrollDate); } if (doc.getElementById("prpCitemCar.modelCode") != null) { String modelCode = doc.getElementById("prpCitemCar.modelCode").attr("value"); System.out.println(": " + modelCode); xubCopyMap.put("modelCode", modelCode); } if (doc.getElementById("prpCitemCar.purchasePrice") != null) { String purchasePrice = doc.getElementById("prpCitemCar.purchasePrice").attr("value"); System.out.println(": " + purchasePrice); xubCopyMap.put("purchasePrice", purchasePrice); } if (doc.getElementById("prpCitemCar.seatCount") != null) { String seatCount = doc.getElementById("prpCitemCar.seatCount").attr("value"); System.out.println("(): " + seatCount); xubCopyMap.put("seatCount", seatCount); } if (doc.getElementById("prpCitemCar.exhaustScale") != null) { String exhaustScale = doc.getElementById("prpCitemCar.exhaustScale").attr("value"); System.out.println("/(): " + exhaustScale); xubCopyMap.put("exhaustScale", exhaustScale); } if (doc.getElementById("prpCinsureds[0].insuredName") != null) { String insuredName = doc.getElementById("prpCinsureds[0].insuredName").attr("value"); System.out.println(": " + insuredName); xubCopyMap.put("insuredName", insuredName); } if (doc.getElementById("prpCinsureds[0].identifyNumber") != null) { String identifyNumber = doc.getElementById("prpCinsureds[0].identifyNumber").attr("value"); System.out.println(": " + identifyNumber); xubCopyMap.put("identifyNumber", identifyNumber); } if (doc.getElementById("prpCinsureds[0].insuredAddress") != null) { String insuredAddress = doc.getElementById("prpCinsureds[0].insuredAddress").attr("value"); System.out.println(": " + insuredAddress); xubCopyMap.put("insuredAddress", insuredAddress); } if (doc.getElementById("prpCinsureds[0].mobile") != null) { String mobile = doc.getElementById("prpCinsureds[0].mobile").attr("value"); System.out.println(": " + mobile); xubCopyMap.put("mobile", mobile); } System.out.println(); Element element = null; for (int i = 0; i < 11; i++) { Map<String, String> xianzMap = new HashMap<String, String>(); element = doc.getElementById("prpCitemKindsTemp[" + i + "].chooseFlag"); // System.out.println(element.toString()); String xianz = ""; if (element != null) xianz = element.attr("checked"); // if(xianz.equals("")) // continue; if (i == 0) xianzMap.put("A", xianz); if (i == 1) xianzMap.put("G", xianz); if (i == 2) xianzMap.put("B", xianz); if (i == 3) xianzMap.put("D11", xianz); if (i == 4) xianzMap.put("D12", xianz); if (i == 5) xianzMap.put("L", xianz); if (i == 6) xianzMap.put("F", xianz); if (i == 8) xianzMap.put("Z", xianz); if (i == 9) xianzMap.put("X1", xianz); element = doc.getElementById("prpCitemKindsTemp[" + i + "].specialFlag"); String bujmp = ""; if (element != null) bujmp = element.attr("checked"); xianzMap.put("bujmp", bujmp); element = doc.getElementById("prpCitemKindsTemp[" + i + "].amount"); String amount = ""; if (element != null) amount = element.attr("value"); xianzMap.put("amount", amount); element = doc.getElementById("prpCitemKindsTemp[" + i + "].modeCode"); String modeCode = ""; if (element != null) { Elements tmp = element.select("option"); for (Element et : tmp) { System.out.println(et.toString()); if (et.hasAttr("selected")) { modeCode = tmp.get(0).attr("value"); break; } } } xianzMap.put("modeCode", modeCode); System.out.print(i + ": " + xianz); System.out.print("\t\tbujmp: " + bujmp); System.out.println("\t\tamount: " + amount); System.out.println("\t\tmodeCode: " + modeCode); list.add(xianzMap); } } xubCopyMap.put("xianZDetail", list); outMap.put("xubCopy", xubCopyMap); return JSONObject.fromObject(outMap) + ""; }
From source file:net.sourceforge.openutils.mgnlcriteria.jcr.query.lucene.AclSearchIndexTest.java
/** * Tests that the execution of a query on all pets returns dogs only, because of an ACL rule. * @throws Exception//ww w .ja va 2 s . c o m */ @Test public void testDogsOnly() throws Exception { Context ctx = MgnlContext.getInstance(); final AccessManager wrappedAM = ctx.getAccessManager(RepositoryConstants.WEBSITE); Assert.assertNotNull(wrappedAM, "AccessManager is null"); final AccessManager wrapperAM = new AccessManager() { public boolean isGranted(String path, long permissions) { // ACL rule: deny permission on pets subtree if (StringUtils.startsWith(path, "/pets/")) { // ACL rule: read permission on dogs subtree return StringUtils.startsWith(path, "/pets/dogs/"); } return wrappedAM.isGranted(path, permissions); } public void setPermissionList(List<Permission> permissions) { wrappedAM.setPermissionList(permissions); } public List<Permission> getPermissionList() { return wrappedAM.getPermissionList(); } public long getPermissions(String path) { return wrappedAM.getPermissions(path); } }; MgnlContext.setInstance(new ContextDecorator(MgnlContext.getInstance()) { /** * {@inheritDoc} */ @Override public AccessManager getAccessManager(String name) { if (RepositoryConstants.WEBSITE.equals(name)) { return wrapperAM; } return super.getAccessManager(name); } }); try { Calendar begin = Calendar.getInstance(); begin.set(1999, Calendar.JANUARY, 1); Calendar end = Calendar.getInstance(); end.set(2001, Calendar.DECEMBER, 31); Criteria criteria = JCRCriteriaFactory.createCriteria().setWorkspace(RepositoryConstants.WEBSITE) .setBasePath("/pets").add(Restrictions.between("@birthDate", begin, end)) .addOrder(Order.asc("@birthDate")); // Query results: // --- 9 (title=Lucky, petType=bird, birthDate=1999-08-06) // --- 6 (title=George, petType=snake, birthDate=2000-01-20) // --- 4 (title=Jewel, petType=dog, birthDate=2000-03-07) // --- 11 (title=Freddy, petType=bird, birthDate=2000-03-09) // --- 12 (title=Lucky, petType=dog, birthDate=2000-06-24) // --- 1 (title=Leo, petType=cat, birthDate=2000-09-07) // --- 5 (title=Iggy, petType=lizard, birthDate=2000-11-30) // --- 3 (title=Rosy, petType=dog, birthDate=2001-04-17) AdvancedResult result = criteria.execute(); // Accessible results (dogs only): // --- 4 (title=Jewel, petType=dog, birthDate=2000-03-07) // --- 12 (title=Lucky, petType=dog, birthDate=2000-06-24) // --- 3 (title=Rosy, petType=dog, birthDate=2001-04-17) ResultIterator<? extends Node> iterator = result.getItems(); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "4"); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "12"); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "3"); Assert.assertFalse(iterator.hasNext()); } finally { MgnlContext.setInstance(((ContextDecorator) MgnlContext.getInstance()).getWrappedContext()); } }
From source file:net.sourceforge.openutils.mgnlcriteria.jcr.query.lucene.AclSearchIndexTest.java
/** * Tests that the execution of a query on all pets does not return any dog, because of an ACL rule. * @throws Exception/*from w w w. j a v a2s .co m*/ */ @Test public void testDogsExcluded() throws Exception { final AccessManager wrappedAM = MgnlContext.getAccessManager(RepositoryConstants.WEBSITE); Assert.assertNotNull(wrappedAM, "AccessManager is null"); final AccessManager wrapperAM = new AccessManager() { public boolean isGranted(String path, long permissions) { // ACL rule: read permission on pets subtree if (StringUtils.startsWith(path, "/pets/")) { // ACL rule: deny permission on dogs subtree return !StringUtils.startsWith(path, "/pets/dogs/"); } return wrappedAM.isGranted(path, permissions); } public void setPermissionList(List<Permission> permissions) { wrappedAM.setPermissionList(permissions); } public List<Permission> getPermissionList() { return wrappedAM.getPermissionList(); } public long getPermissions(String path) { return wrappedAM.getPermissions(path); } }; MgnlContext.setInstance(new ContextDecorator(MgnlContext.getInstance()) { /** * {@inheritDoc} */ @Override public AccessManager getAccessManager(String name) { if (RepositoryConstants.WEBSITE.equals(name)) { return wrapperAM; } return super.getAccessManager(name); } }); try { Calendar begin = Calendar.getInstance(); begin.set(1999, Calendar.JANUARY, 1); Calendar end = Calendar.getInstance(); end.set(2001, Calendar.DECEMBER, 31); Criteria criteria = JCRCriteriaFactory.createCriteria().setWorkspace(RepositoryConstants.WEBSITE) .setBasePath("/pets").add(Restrictions.between("@birthDate", begin, end)) .addOrder(Order.asc("@birthDate")); AdvancedResult result = criteria.execute(); // Accessible results (dogs excluded): // --- 9 (title=Lucky, petType=bird, birthDate=1999-08-06) // --- 6 (title=George, petType=snake, birthDate=2000-01-20) // --- 11 (title=Freddy, petType=bird, birthDate=2000-03-09) // --- 1 (title=Leo, petType=cat, birthDate=2000-09-07) // --- 5 (title=Iggy, petType=lizard, birthDate=2000-11-30) ResultIterator<? extends Node> iterator = result.getItems(); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "9"); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "6"); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "11"); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "1"); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "5"); Assert.assertFalse(iterator.hasNext()); } finally { MgnlContext.setInstance(((ContextDecorator) MgnlContext.getInstance()).getWrappedContext()); } }
From source file:net.teamfruit.usefulbuilderswand.lib.de.tr7zw.itemnbtapi.MinecraftVersion.java
public static MinecraftVersion getVersion() { if (version != null) return version; final String NBTAPI_PREF = "[UsefulBuildersWand-NBTAPI] "; final String ver = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; System.out.println(NBTAPI_PREF + "Found Spigot: " + ver + "! Trying to find NMS support"); try {//from w w w . j a v a2s . com version = MinecraftVersion.valueOf(ver.replace("v", "MC")); } catch (final IllegalArgumentException ex) { for (final MinecraftVersion mcver : values()) if (StringUtils.startsWith(ver, mcver.name)) { System.out.println(NBTAPI_PREF + "NMS '" + ver + "' is not found but '" + mcver.name().replace("MC", "v") + "' found."); version = mcver; break; } version = MinecraftVersion.Unknown; } if (version != Unknown) System.out.println(NBTAPI_PREF + "NMS support '" + version.name() + "' loaded!"); else System.out.println(NBTAPI_PREF + "Wasn't able to find NMS Support! Some functions will not work!"); return version; }
From source file:net.triptech.metahive.web.model.BackingForm.java
/** * Trim the supplied value./* w w w.j ava 2 s. co m*/ * * @param value the value * @return the string */ public static final String trim(final String value) { StringBuilder sb = new StringBuilder(); if (StringUtils.isNotBlank(value)) { sb.append(StringUtils.strip(value)); while (StringUtils.startsWith(sb.toString(), "\u00A0")) { sb.delete(0, 1); } while (StringUtils.startsWith(sb.toString(), " ")) { sb.delete(0, 6); } while (StringUtils.startsWith(sb.toString(), " ")) { sb.delete(0, 6); } } return sb.toString(); }
From source file:net.triptech.metahive.web.model.RecordFilter.java
/** * Process the parameters from the search form. * * @param request the request/* w ww . j a v a2s .c o m*/ */ public void processSearchForm(final HttpServletRequest request) { FilterVector filterVector = new FilterVector(); for (Object objParam : request.getParameterMap().keySet()) { String param = (String) objParam; if (StringUtils.startsWith(param, "d_")) { // This is a search term - put the param and its value into the map Object objValue = request.getParameterMap().get(param); if (objValue != null && objValue instanceof String[]) { String[] value = (String[]) objValue; if (StringUtils.isNotBlank(value[0]) && !StringUtils.equalsIgnoreCase(value[0], "*")) { filterVector.addVariable(param, value[0]); } } } } this.filterVectors.add(filterVector); }
From source file:net.ymate.framework.core.util.WebUtils.java
/** * @param url URL?//from w w w .j a va 2 s . c om * @param needStartWith ?'/' * @param needEndwith ?'/'? * @return ?URL? */ public static String fixURL(String url, boolean needStartWith, boolean needEndwith) { url = StringUtils.trimToNull(url); if (url != null) { if (needStartWith && !StringUtils.startsWith(url, "/")) { url = '/' + url; } else if (!needStartWith && StringUtils.startsWith(url, "/")) { url = StringUtils.substringAfter(url, "/"); } if (needEndwith && !StringUtils.endsWith(url, "/")) { url = url + '/'; } else if (!needEndwith && StringUtils.endsWith(url, "/")) { url = StringUtils.substringBeforeLast(url, "/"); } return url; } return ""; }