@Test public void testExtractIds() { AttributeMap attributeMap = new AttributeMap(); Map<String, String> details = attributeMap.extractIds(AttributeMap.EVENT_ALL, "/event/@all"); assertTrue("Wrong eventId detected for /event/@all", details.get(AttributeMap.EVENT_ID) == null); assertTrue("Wrong userId detected for /event/@all", details.get(AttributeMap.USER_ID) == null); details = attributeMap.extractIds(AttributeMap.EVENT_DETAILS, "/event/@me/123"); assertTrue("Wrong eventId detected for /event/@me/123", details.get(AttributeMap.EVENT_ID).equals("123")); assertTrue("Wrong userId detected for /event/@me/123", details.get(AttributeMap.USER_ID) == null); details = attributeMap.extractIds(AttributeMap.EVENT_ATTENDEEDETAILS, "/event/@me/123/456"); assertTrue("Wrong eventId detected for /event/@me/123/456", details.get(AttributeMap.EVENT_ID).equals("123")); assertTrue("Wrong userId detected for /event/@me/123/456", details.get(AttributeMap.USER_ID).equals("456")); }
public Map<String, String> extractIds (String attribute, String input) { HashMap<String, String> idMap = new HashMap<String, String>(); Iterator<String> iterator = this.idnames.iterator(); while (iterator.hasNext()) { String candidate = iterator.next(); String attr = attribute.replaceAll("\\{"+candidate+"\\}", "([^/]+)").replaceAll("\\{\\w+\\}", "[^/]+"); Pattern pattern = Pattern.compile(attr); Matcher matcher = pattern.matcher(input); if (matcher.find() && matcher.groupCount() >= 1) { idMap.put(candidate, matcher.group(1)); } } return idMap; }
AttributeMap { public Map<String, String> extractIds (String attribute, String input) { HashMap<String, String> idMap = new HashMap<String, String>(); Iterator<String> iterator = this.idnames.iterator(); while (iterator.hasNext()) { String candidate = iterator.next(); String attr = attribute.replaceAll("\\{"+candidate+"\\}", "([^/]+)").replaceAll("\\{\\w+\\}", "[^/]+"); Pattern pattern = Pattern.compile(attr); Matcher matcher = pattern.matcher(input); if (matcher.find() && matcher.groupCount() >= 1) { idMap.put(candidate, matcher.group(1)); } } return idMap; } }
AttributeMap { public Map<String, String> extractIds (String attribute, String input) { HashMap<String, String> idMap = new HashMap<String, String>(); Iterator<String> iterator = this.idnames.iterator(); while (iterator.hasNext()) { String candidate = iterator.next(); String attr = attribute.replaceAll("\\{"+candidate+"\\}", "([^/]+)").replaceAll("\\{\\w+\\}", "[^/]+"); Pattern pattern = Pattern.compile(attr); Matcher matcher = pattern.matcher(input); if (matcher.find() && matcher.groupCount() >= 1) { idMap.put(candidate, matcher.group(1)); } } return idMap; } AttributeMap(); }
AttributeMap { public Map<String, String> extractIds (String attribute, String input) { HashMap<String, String> idMap = new HashMap<String, String>(); Iterator<String> iterator = this.idnames.iterator(); while (iterator.hasNext()) { String candidate = iterator.next(); String attr = attribute.replaceAll("\\{"+candidate+"\\}", "([^/]+)").replaceAll("\\{\\w+\\}", "[^/]+"); Pattern pattern = Pattern.compile(attr); Matcher matcher = pattern.matcher(input); if (matcher.find() && matcher.groupCount() >= 1) { idMap.put(candidate, matcher.group(1)); } } return idMap; } AttributeMap(); String getAttribute(String input); Map<String, String> extractIds(String attribute, String input); }
AttributeMap { public Map<String, String> extractIds (String attribute, String input) { HashMap<String, String> idMap = new HashMap<String, String>(); Iterator<String> iterator = this.idnames.iterator(); while (iterator.hasNext()) { String candidate = iterator.next(); String attr = attribute.replaceAll("\\{"+candidate+"\\}", "([^/]+)").replaceAll("\\{\\w+\\}", "[^/]+"); Pattern pattern = Pattern.compile(attr); Matcher matcher = pattern.matcher(input); if (matcher.find() && matcher.groupCount() >= 1) { idMap.put(candidate, matcher.group(1)); } } return idMap; } AttributeMap(); String getAttribute(String input); Map<String, String> extractIds(String attribute, String input); static final String EVENT_ID; static final String USER_ID; static final String EVENT_ALL; static final String EVENT_ALLMINE; static final String EVENT_DETAILS; static final String EVENT_ATTENDEES; static final String EVENT_ATTENDEEDETAILS; static final String PROFILE_ME; static final String PROFILE_MYDETAILS; static final String PROFILE_DETAILS; static final String PROFILEATTRIBUTE_MYDETAILS; static final String PROFILEATTRIBUTE_DETAILS; static final String FRIEND_ALL; static final String FRIEND_DETAILS; static final String GROUP_ALL; static final String LIVEPOST_ALL; static final String LIVEPOST_ALLMINE; static final String LIVEPOST_ALLUSER; static final String NOTIFICATION; static final String PLACE_ALL; static final String ACTIVITY_ALL; static final String ACTIVITY_DETAILS; }