protected ElementsPath(String thePath) { StringTokenizer tok = new StringTokenizer(thePath, "."); boolean first = true; while (tok.hasMoreTokens()) { String next = tok.nextToken(); if (first && next.equals("*")) { getPath().add(new EncodeContextPathElement("*", true)); } else if (isNotBlank(next)) { getPath().add(new EncodeContextPathElement(next, Character.isUpperCase(next.charAt(0)))); } first = false; } }
@Override public void setEncodeElements(Set<String> theEncodeElements) { if (theEncodeElements == null || theEncodeElements.isEmpty()) { myEncodeElements = null; myEncodeElementsAppliesToResourceTypes = null; } else { myEncodeElements = theEncodeElements .stream() .map(ElementsPath::new) .collect(Collectors.toList()); myEncodeElementsAppliesToResourceTypes = new HashSet<>(); for (String next : myEncodeElements.stream().map(t -> t.getPath().get(0).getName()).collect(Collectors.toList())) { if (next.startsWith("*")) { myEncodeElementsAppliesToResourceTypes = null; break; } int dotIdx = next.indexOf('.'); if (dotIdx == -1) { myEncodeElementsAppliesToResourceTypes.add(next); } else { myEncodeElementsAppliesToResourceTypes.add(next.substring(0, dotIdx)); } } } }
public boolean startsWith(EncodeContextPath theCurrentResourcePath) { for (int i = 0; i < getPath().size(); i++) { if (theCurrentResourcePath.getPath().size() == i) { return true; } EncodeContextPathElement expected = getPath().get(i); EncodeContextPathElement actual = theCurrentResourcePath.getPath().get(i); if (!expected.matches(actual)) { return false; } } return true; }
if (theCheckingForEncodeElements || next.getPath().size() == currentResourcePath.getPath().size()) { retVal = true; break; if (next.getPath().get(next.getPath().size() - 1).getName().equals("(mandatory)")) { if (myDef.getMin() > 0) { retVal = true; break; if (currentResourcePath.getPath().size() > next.getPath().size()) { retVal = true; break;