Ejemplo n.º 1
0
  /**
   * Determine the original namespace of the given qualified name with a namespace previously mapped
   * with {@link #map(QName)} and return the original name.
   *
   * @param mapped the adapted qualified name
   * @return the original qualified name
   */
  public static QName unmap(QName mapped) {
    if (XMLConstants.NULL_NS_URI.equals(mapped.getNamespaceURI())) {
      return mapped;
    }

    return new QName(IDS.getObject(mapped.getNamespaceURI()), mapped.getLocalPart());
  }
Ejemplo n.º 2
0
  /**
   * Map the namespace of the given qualified name to a short identifier and return the adapted
   * name.
   *
   * @param org the original qualified name
   * @return the adapted qualified name
   */
  public static QName map(QName org) {
    if (XMLConstants.NULL_NS_URI.equals(org.getNamespaceURI())) {
      return org;
    }

    return new QName(IDS.getId(org.getNamespaceURI()), org.getLocalPart());
  }
Ejemplo n.º 3
0
  /**
   * 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());
  }
Ejemplo n.º 4
0
 /**
  * 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);
 }