/** * Decode a name based on the runtime namespace map. * * @param name the encoded name * @return the decoded qualified name * @throws DecoderException of decoding the local part of the name fails */ public static QName decode(String name) throws DecoderException { int pos = name.indexOf('_'); // find first underscore String local; String ns = XMLConstants.NULL_NS_URI; if (pos < 0) { local = ONameUtil.decodeName(name); } else { ns = IDS.getObject(name.substring(0, pos)); local = ONameUtil.decodeName(name.substring(pos + 1)); } return new QName(ns, local); }
/** * Encode a {@link QName} for runtime use with OrientDB. * * @param org the qualified name * @return the encoded name */ public static String encode(QName org) { String ns = org.getNamespaceURI(); if (!XMLConstants.NULL_NS_URI.equals(ns)) { ns = IDS.getId(org.getNamespaceURI()); } return ns + "_" + ONameUtil.encodeName(org.getLocalPart()); }