Esempio n. 1
0
 /**
  * @param pm the prefix manager to copy
  * @param c comparator to sort prefixes
  */
 public DefaultPrefixManager(PrefixManager pm, Comparator<String> c) {
   this(c);
   for (String prefixName : pm.getPrefixNames()) {
     String prefix = pm.getPrefix(prefixName);
     if (prefix != null) {
       prefix2NamespaceMap.put(prefixName, prefix);
     }
   }
 }
  public String render(OWLEntity entity) {
    String shortForm = getProvider().getShortForm(entity);
    final String uriStr = entity.getIRI().toString();

    for (Map.Entry<String, String> prefixName2PrefixEntry :
        prefixManager.getPrefixName2PrefixMap().entrySet()) {
      String prefixName = prefixName2PrefixEntry.getKey();
      if (!shortForm.startsWith(prefixName)) {
        String prefix = prefixName2PrefixEntry.getValue();
        if (uriStr.startsWith(prefix)) {
          if (!prefixName.equals(":")) {
            return escape(prefixName + shortForm);
          } else {
            return escape(shortForm);
          }
        }
      } else {
        return escape(shortForm);
      }
    }
    return entity.getIRI().toQuotedString();
  }
 public void copyPrefixesFrom(PrefixManager prefixManager) {
   for (String prefixName : prefixManager.getPrefixNames()) {
     String prefix = prefixManager.getPrefix(prefixName);
     nsm.setPrefix(prefixName, prefix);
   }
 }