@Test public void testFromStringDefault() { final String defaultNS = "http: final String[] strings = { "localname", "{}with-empty-namespace", "{http: }; final EName[] eNames = { new EName(defaultNS, "localname"), new EName("", "with-empty-namespace"), new EName("http: }; for (int i = 0; i < strings.length; i++) { assertEquals(eNames[i], EName.fromString(strings[i], defaultNS)); } }
public static EName fromString(String strEName, String defaultNameSpace) throws IllegalArgumentException { if (strEName == null) { throw new IllegalArgumentException("Cannot parse 'null' as EName"); } Matcher m = pattern.matcher(strEName); if (m.matches()) { if (StringUtils.isNotBlank(defaultNameSpace) && m.group("namespace") == null) return new EName(defaultNameSpace, m.group("localname")); else return new EName(StringUtils.trimToEmpty(m.group("namespace")), m.group("localname")); } throw new IllegalArgumentException(format("Cannot parse '%s' as EName", strEName)); }
EName implements Serializable, Comparable<EName> { public static EName fromString(String strEName, String defaultNameSpace) throws IllegalArgumentException { if (strEName == null) { throw new IllegalArgumentException("Cannot parse 'null' as EName"); } Matcher m = pattern.matcher(strEName); if (m.matches()) { if (StringUtils.isNotBlank(defaultNameSpace) && m.group("namespace") == null) return new EName(defaultNameSpace, m.group("localname")); else return new EName(StringUtils.trimToEmpty(m.group("namespace")), m.group("localname")); } throw new IllegalArgumentException(format("Cannot parse '%s' as EName", strEName)); } }
EName implements Serializable, Comparable<EName> { public static EName fromString(String strEName, String defaultNameSpace) throws IllegalArgumentException { if (strEName == null) { throw new IllegalArgumentException("Cannot parse 'null' as EName"); } Matcher m = pattern.matcher(strEName); if (m.matches()) { if (StringUtils.isNotBlank(defaultNameSpace) && m.group("namespace") == null) return new EName(defaultNameSpace, m.group("localname")); else return new EName(StringUtils.trimToEmpty(m.group("namespace")), m.group("localname")); } throw new IllegalArgumentException(format("Cannot parse '%s' as EName", strEName)); } EName(String namespaceURI, String localName); }
EName implements Serializable, Comparable<EName> { public static EName fromString(String strEName, String defaultNameSpace) throws IllegalArgumentException { if (strEName == null) { throw new IllegalArgumentException("Cannot parse 'null' as EName"); } Matcher m = pattern.matcher(strEName); if (m.matches()) { if (StringUtils.isNotBlank(defaultNameSpace) && m.group("namespace") == null) return new EName(defaultNameSpace, m.group("localname")); else return new EName(StringUtils.trimToEmpty(m.group("namespace")), m.group("localname")); } throw new IllegalArgumentException(format("Cannot parse '%s' as EName", strEName)); } EName(String namespaceURI, String localName); static EName mk(String namespaceURI, String localName); static EName mk(String localName); String getNamespaceURI(); String getLocalName(); boolean hasNamespace(); @Override int hashCode(); @Override boolean equals(Object that); @Override String toString(); @Override int compareTo(EName o); static EName fromString(String strEName, String defaultNameSpace); static EName fromString(String strEName); }
EName implements Serializable, Comparable<EName> { public static EName fromString(String strEName, String defaultNameSpace) throws IllegalArgumentException { if (strEName == null) { throw new IllegalArgumentException("Cannot parse 'null' as EName"); } Matcher m = pattern.matcher(strEName); if (m.matches()) { if (StringUtils.isNotBlank(defaultNameSpace) && m.group("namespace") == null) return new EName(defaultNameSpace, m.group("localname")); else return new EName(StringUtils.trimToEmpty(m.group("namespace")), m.group("localname")); } throw new IllegalArgumentException(format("Cannot parse '%s' as EName", strEName)); } EName(String namespaceURI, String localName); static EName mk(String namespaceURI, String localName); static EName mk(String localName); String getNamespaceURI(); String getLocalName(); boolean hasNamespace(); @Override int hashCode(); @Override boolean equals(Object that); @Override String toString(); @Override int compareTo(EName o); static EName fromString(String strEName, String defaultNameSpace); static EName fromString(String strEName);  }