/** * Parse the reference contained in the string and return a * {@link T2Reference} with the correct properties */ public T2Reference referenceFromString(String reference) { T2ReferenceImpl newRef = new T2ReferenceImpl(); Map<String, String> parseRef = parseRef(reference); newRef.setNamespacePart(parseRef.get("namespace")); newRef.setLocalPart(parseRef.get("localPart")); String type = parseRef.get("type"); if (type.equals("ref")) { newRef.setReferenceType(T2ReferenceType.ReferenceSet); } else if (type.equals("list")) { newRef.setReferenceType(T2ReferenceType.IdentifiedList); newRef.setContainsErrors(Boolean .parseBoolean(parseRef.get("error"))); newRef.setDepth(Integer.parseInt(parseRef.get("depth"))); } else if (type.equals("error")) { newRef.setContainsErrors(true); newRef.setReferenceType(T2ReferenceType.ErrorDocument); newRef.setDepth(Integer.parseInt(parseRef.get("depth"))); } else { return null; // should throw an error } return newRef; }