org.openrdf.model.Namespace.getPrefix()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中org.openrdf.model.Namespace.getPrefix()方法的一些代码示例,展示了Namespace.getPrefix()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace.getPrefix()方法的具体详情如下:
包路径:org.openrdf.model.Namespace
类名称:Namespace
方法名:getPrefix

Namespace.getPrefix介绍

[英]Gets the prefix of the current namespace. The default namespace is represented by an empty prefix string.
[中]获取当前命名空间的前缀。默认名称空间由空前缀字符串表示。

代码示例

代码示例来源:origin: io.konig/konig-schemagen

@Override
  public int compare(Namespace a, Namespace b) {
    return a.getPrefix().compareTo(b.getPrefix());
  }
});

代码示例来源:origin: org.openrdf.sesame/sesame-model

@Override
public boolean containsKey(Object nextKey) {
  if (nextKey instanceof String) {
    for (Namespace nextNamespace : namespaces) {
      if (nextNamespace.getPrefix().equals(nextKey)) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

@Override
public Set<String> keySet() {
  Set<String> result = new LinkedHashSet<String>();
  for (Namespace nextNamespace : namespaces) {
    result.add(nextNamespace.getPrefix());
  }
  return result;
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

@Override
public Optional<Namespace> getNamespace(String prefix) {
  for (Namespace nextNamespace : namespaces) {
    if (prefix.equals(nextNamespace.getPrefix())) {
      return Optional.of(nextNamespace);
    }
  }
  return Optional.empty();
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

@Override
public Optional<Namespace> getNamespace(String prefix) {
  for (Namespace nextNamespace : namespaces) {
    if (prefix.equals(nextNamespace.getPrefix())) {
      return Optional.of(nextNamespace);
    }
  }
  return Optional.empty();
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

@Override
public void setNamespace(Namespace namespace) {
  removeNamespace(namespace.getPrefix());
  namespaces.add(namespace);
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

@Override
public String remove(Object nextKey) {
  String result = null;
  for (Namespace nextNamespace : new LinkedHashSet<Namespace>(namespaces)) {
    if (nextNamespace.getPrefix().equals(nextKey)) {
      result = nextNamespace.getName();
      namespaces.remove(nextNamespace);
    }
  }
  return result;
}

代码示例来源:origin: org.apache.rya/mongodb.rya

@Override
public int compareTo(final Namespace o) {
  if (!namespace.equalsIgnoreCase(o.getName())) {
    return namespace.compareTo(o.getName());
  }
  if (!prefix.equalsIgnoreCase(o.getPrefix())) {
    return prefix.compareTo(o.getPrefix());
  }
  return 0;
}

代码示例来源:origin: com.github.jsonld-java/jsonld-java-sesame

private static void addPrefixes(Map<String, Object> ctx, Set<Namespace> namespaces) {
    for (final Namespace ns : namespaces) {
      ctx.put(ns.getPrefix(), ns.getName());
    }

  }
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

@Override
public void setNamespace(Namespace namespace) {
  removeNamespace(namespace.getPrefix());
  namespaces.add(namespace);
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

@Override
public String get(Object nextKey) {
  if (nextKey instanceof String) {
    for (Namespace nextNamespace : namespaces) {
      if (nextNamespace.getPrefix().equals(nextKey)) {
        return nextNamespace.getName();
      }
    }
  }
  return null;
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

/**
 * Gets the namespace that is associated with the specified prefix, if any.
 * 
 * @param prefix
 *        A namespace prefix.
 * @return The namespace name that is associated with the specified prefix,
 *         or {@link Optional#empty()} if there is no such namespace.
 */
public default Optional<Namespace> getNamespace(String prefix) {
  return getNamespaces().stream().filter(t -> t.getPrefix().equals(prefix)).findAny();
}

代码示例来源:origin: org.openrdf.sesame/sesame-model

@Override
public String put(String nextKey, String nextValue) {
  String result = null;
  for (Namespace nextNamespace : new LinkedHashSet<Namespace>(namespaces)) {
    if (nextNamespace.getPrefix().equals(nextKey)) {
      result = nextNamespace.getName();
      namespaces.remove(nextNamespace);
    }
  }
  namespaces.add(new SimpleNamespace(nextKey, nextValue));
  return result;
}

代码示例来源:origin: io.konig/konig-schemagen

@Override
public String jsonSchemaFileName(Shape shape) {
  URI shapeId = (URI) shape.getId();
  StringBuilder builder = new StringBuilder();
  builder.append(namespace(shapeId).getPrefix());
  builder.append('.');
  builder.append(shapeId.getLocalName());
  builder.append(".json");
  
  return builder.toString();
}

代码示例来源:origin: org.openrdf.sesame/sesame-store

public Map<String, String> asMap()
    throws StoreException
  {
    Map<String, String> map = new HashMap<String, String>();
    Namespace ns;
    while ((ns = next()) != null) {
      map.put(ns.getPrefix(), ns.getName());
    }
    return map;
  }
}

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-optimistic

public boolean hasNext() throws SailException {
  if (addedIter != null && addedIter.hasNext())
    return true;
  while (next == null && namespaces.hasNext()) {
    next = namespaces.next();
    if (removedSet != null && removedSet.contains(next.getPrefix())) {
      next = null;
    }
  }
  return next != null;
}

代码示例来源:origin: io.konig/konig-schemagen

@Override
public File getFile(URI ontologyId) {
  
  Namespace namespace = nsManager.findByName(ontologyId.stringValue());
  if (namespace == null) {
    throw new KonigException("Prefix not found for namespace: " + ontologyId.stringValue());
  }
  String prefix = namespace.getPrefix();
  StringBuilder builder = new StringBuilder();
  builder.append(prefix);
  builder.append(".ttl");
  return new File(baseDir, builder.toString());
}

代码示例来源:origin: io.konig/konig-schemagen

private void writeNamespaces(NamespaceManager nsManager, RDFWriter turtle) throws RDFHandlerException {
  
  List<Namespace> list = new ArrayList<>(nsManager.listNamespaces());
  
  Collections.sort(list, new Comparator<Namespace>(){
    @Override
    public int compare(Namespace a, Namespace b) {
      return a.getPrefix().compareTo(b.getPrefix());
    }});
  
  for (Namespace ns : list) {
    turtle.handleNamespace(ns.getPrefix(), ns.getName());
  }
  
     
}

代码示例来源:origin: org.openrdf.sesame/sesame-rio-api

protected void initializeNamespaceTableFromConfiguration() {
  for (Namespace aNS : getParserConfig().get(BasicParserSettings.NAMESPACES)) {
    namespaceTable.put(aNS.getPrefix(), aNS.getName());
  }
}

代码示例来源:origin: org.apache.marmotta/kiwi-triplestore

@Override
protected void clearNamespacesInternal() throws SailException {
  for(Namespace ns : Iterations.asList(getNamespacesInternal())) {
    removeNamespaceInternal(ns.getPrefix());
  }
}

相关文章