/** * Updates the QName's prefix, if possible, and returns either the updated result, * or a newly created QName with the new prefix, if the QName could not be directly updated. * @param qName the QName to be updated. * @param prefix the new prefix. * @return a QName with the same namespace URI and local part as the argument, but with the new prefix. */ public static QName setPrefix(QName qName, String prefix) { if (qName instanceof org.eclipse.emf.ecore.xml.type.internal.QName) { org.eclipse.emf.ecore.xml.type.internal.QName result = (org.eclipse.emf.ecore.xml.type.internal.QName)qName; result.setPrefix(prefix); return result; } else { return new org.eclipse.emf.ecore.xml.type.internal.QName(qName.getNamespaceURI(), qName.getLocalPart(), prefix); } }
/** * Updates the QName's prefix, if possible, and returns either the updated result, * or a newly created QName with the new prefix, if the QName could not be directly updated. * @param qName the QName to be updated. * @param prefix the new prefix. * @return a QName with the same namespace URI and local part as the argument, but with the new prefix. */ public static QName setPrefix(QName qName, String prefix) { if (qName instanceof org.eclipse.emf.ecore.xml.type.internal.QName) { org.eclipse.emf.ecore.xml.type.internal.QName result = (org.eclipse.emf.ecore.xml.type.internal.QName)qName; result.setPrefix(prefix); return result; } else { return new org.eclipse.emf.ecore.xml.type.internal.QName(qName.getNamespaceURI(), qName.getLocalPart(), prefix); } }
/** * Constructs a QName. * @param qname a <a href="http://www.w3.org/TR/REC-xml-names/#dt-qname">qualified name</a> * Throws Exception if value is not legal qualified name */ public QName(String qname) { super(null, qname.indexOf(':') != -1 ? qname.substring(qname.indexOf(':') + 1) : qname, qname.indexOf(':') != -1 ? qname.substring(0, qname.indexOf(':')) : ""); setPrefix(super.getPrefix()); // both prefix (if any) a localpart must be valid NCName if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix)) throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+qname); if(!XMLChar.isValidNCName(getLocalPart())) throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+qname); }
/** * Sets the QName object values to the specified once * @param namespaceUri namespace uri value or null * @param localPart localPart (not null) * @param prefix prefix value or null */ @Deprecated public static void setQNameValues(Object qName, String namespaceUri, String localPart, String prefix) { if (!(qName instanceof org.eclipse.emf.ecore.xml.type.internal.QName)) { throw new UnsupportedOperationException("QNames are immutable, so this can't be supported"); } if (namespaceUri == null) { namespaceUri = ""; } org.eclipse.emf.ecore.xml.type.internal.QName qn = (org.eclipse.emf.ecore.xml.type.internal.QName)qName; if (!qn.getLocalPart().equals(localPart) || qn.getNamespaceURI().equals(namespaceUri)) { throw new UnsupportedOperationException("QNames are immutable, so this can't be supported"); } qn.setPrefix(prefix); }
/** * Constructs a QName. * @param qname a <a href="http://www.w3.org/TR/REC-xml-names/#dt-qname">qualified name</a> * Throws Exception if value is not legal qualified name */ public QName(String qname) { super(null, qname.indexOf(':') != -1 ? qname.substring(qname.indexOf(':') + 1) : qname, qname.indexOf(':') != -1 ? qname.substring(0, qname.indexOf(':')) : ""); setPrefix(super.getPrefix()); // both prefix (if any) a localpart must be valid NCName if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix)) throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+qname); if(!XMLChar.isValidNCName(getLocalPart())) throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+qname); }
/** * Sets the QName object values to the specified once * @param namespaceUri namespace uri value or null * @param localPart localPart (not null) * @param prefix prefix value or null */ @Deprecated public static void setQNameValues(Object qName, String namespaceUri, String localPart, String prefix) { if (!(qName instanceof org.eclipse.emf.ecore.xml.type.internal.QName)) { throw new UnsupportedOperationException("QNames are immutable, so this can't be supported"); } if (namespaceUri == null) { namespaceUri = ""; } org.eclipse.emf.ecore.xml.type.internal.QName qn = (org.eclipse.emf.ecore.xml.type.internal.QName)qName; if (!qn.getLocalPart().equals(localPart) || qn.getNamespaceURI().equals(namespaceUri)) { throw new UnsupportedOperationException("QNames are immutable, so this can't be supported"); } qn.setPrefix(prefix); }
/** * Constructs a QName with the specified values. */ public QName(String namespaceURI, String localPart, String prefix) { super(namespaceURI, localPart, prefix = prefix == null ? "" : prefix); setPrefix(prefix); if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix)) throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+prefix); if (!XMLChar.isValidNCName(localPart)) throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+localPart); }
/** * Constructs a QName with the specified values. */ public QName(String namespaceURI, String localPart, String prefix) { super(namespaceURI, localPart, prefix = prefix == null ? "" : prefix); setPrefix(prefix); if (prefix.length() > 0 && !XMLChar.isValidNCName(prefix)) throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+prefix); if (!XMLChar.isValidNCName(localPart)) throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1: invalid QName: "+localPart); }