String (String fullName, String elementStringValue) { QualifiedName fullQName = QualifiedName.fromDottedString(fullName); QualifiedName stringQName = QualifiedName.fromDottedString(elementStringValue); String[] s1 = stringQName.getComponents().toArray(new String[stringQName.getComponentCount()]); String[] s2 = fullQName.getComponents().toArray(new String[fullQName.getComponentCount()]); for (int i = s1.length - 1; i >= 0; i--) { boolean flag = true; if (i > s2.length - 1) { continue; } for (int j = 0; j <= i; j++) { if (!s1[i - j].equals(s2[s2.length - j - 1])) { flag = false; break; } } if (flag) { StringBuilder res = new StringBuilder(); for (int j = 0; j <= i; j++) { if (j > 0) { res.append("."); } res.append(s1[j]); } return res.toString(); } } return null; }