org.openprovenance.prov.model.Namespace.getPrefixes()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(13.7k)|赞(0)|评价(0)|浏览(119)

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

Namespace.getPrefixes介绍

暂无

代码示例

代码示例来源:origin: lucmoreau/ProvToolbox

public NamespaceGatherer(Hashtable<String, String> prefixes,
             String defaultNamespace) {
ns.getPrefixes().putAll(prefixes);
//TODO create inverse map!
ns.setDefaultNamespace(defaultNamespace);
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void addKnownNamespaces() {
getPrefixes().put("prov",NamespacePrefixMapper.PROV_NS);
getNamespaces().put(NamespacePrefixMapper.PROV_NS,"prov");
getPrefixes().put("xsd",NamespacePrefixMapper.XSD_NS);
getNamespaces().put(NamespacePrefixMapper.XSD_NS,"xsd");
}

代码示例来源:origin: org.openprovenance.prov/prov-model

public NamespaceGatherer(Hashtable<String, String> prefixes,
             String defaultNamespace) {
ns.getPrefixes().putAll(prefixes);
//TODO create inverse map!
ns.setDefaultNamespace(defaultNamespace);
}

代码示例来源:origin: org.openprovenance.prov/prov-model

public void addKnownNamespaces() {
getPrefixes().put("prov",NamespacePrefixMapper.PROV_NS);
getNamespaces().put(NamespacePrefixMapper.PROV_NS,"prov");
getPrefixes().put("xsd",NamespacePrefixMapper.XSD_NS);
getNamespaces().put(NamespacePrefixMapper.XSD_NS,"xsd");
}

代码示例来源:origin: lucmoreau/ProvToolbox

@ElementCollection
@MapKeyColumn(name="prefix")
@Column(name="prefix_value")
@CollectionTable(name="prefix_map", joinColumns=@JoinColumn(name="pk"))

public Map<String, String> getPrefixes() {
  return super.getPrefixes();
}

代码示例来源:origin: lucmoreau/ProvToolbox

public NamespacePrefixMapper(Namespace nss) {
  if (nss!=null) {
    this.defaultNamespace=nss.getDefaultNamespace();
  }
  String xsd_prefix=nss.getNamespaces().get(XSD_NS);
  this.nss=new HashMap<String, String>(nss.getPrefixes()); // don't modify the received map
  this.nss.put(xsd_prefix, DOMProcessing.XSD_NS_FOR_XML);
  
  //System.out.println("PREFIXES IS " + nss);
  //System.out.println("DEFAULT " + defaultNamespace);
}

代码示例来源:origin: org.openprovenance.prov/prov-n

public String processNamespaces(Namespace namespace) {
  String s = "";
  Map<String, String> nss = namespace.getPrefixes();
  String def;
  if ((def = namespace.getDefaultNamespace()) != null) {
    s = s + convertDefaultNamespace("<" + def + ">") + breakline();
  }
  for (String key : nss.keySet()) {
    String uri = nss.get(key);
    if ((key.equals("_") 
      || (key.equals("prov"))
      || (key.equals("xsd") && NamespacePrefixMapper.XSD_NS.equals(uri)))) {
      // IGNORE, we have just handled it
    } else {
      s = s + convertNamespace(key, "<" + uri + ">") + breakline();
    }
  }
  return s;
}

代码示例来源:origin: lucmoreau/ProvToolbox

public String processNamespaces(Namespace namespace) {
  String s = "";
  Map<String, String> nss = namespace.getPrefixes();
  String def;
  if ((def = namespace.getDefaultNamespace()) != null) {
    s = s + convertDefaultNamespace("<" + def + ">") + breakline();
  }
  for (String key : nss.keySet()) {
    String uri = nss.get(key);
    if ((key.equals("_") 
      || (key.equals("prov"))
      || (key.equals("xsd") && NamespacePrefixMapper.XSD_NS.equals(uri)))) {
      // IGNORE, we have just handled it
    } else {
      s = s + convertNamespace(key, "<" + uri + ">") + breakline();
    }
  }
  return s;
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces11 ()  {
    
  List<org.openprovenance.prov.model.Entry> ll = new LinkedList<org.openprovenance.prov.model.Entry>();
     
  

  org.openprovenance.prov.model.Entry p1 = pFactory.newEntry(pFactory.newKey(pFactory.newQualifiedName("http://example4.org/", "zabcd", "other"),
                                        name.PROV_QUALIFIED_NAME),
                                q("e0"));
  ll.add(p1);
  org.openprovenance.prov.model.DerivedByInsertionFrom a = pFactory.newDerivedByInsertionFrom(q("dinsert"), 
                                 q("d2"), 
                                 q("d1"), 
                                 ll, null);
  

  Document doc=pFactory.newDocument();
    doc.getStatementOrBundle().add(a);
    Namespace nss=Namespace.gatherNamespaces(doc);
    
    assertTrue(nss.getPrefixes().size()==4);
   }
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces8 () 
{
  Activity a1=pFactory.newActivity(q("a1"));
  a1.getOther().add(pFactory.newOther(pFactory.newQualifiedName (EXAMPLE2_NS,"tag1", "ex"),
                     pFactory.newQualifiedName("http://www.w3.org/ns/prov#", "emptyCollection", "prov"), 
                     name.PROV_QUALIFIED_NAME));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All prefixes: " + nss.getPrefixes());
  //System.out.println("All ns: " + nss.getNamespaces());
  assertNull(nss.getDefaultNamespace());
  assertTrue(nss.getPrefixes().size()==4);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  assertTrue(nss.check("xsd", XSD_NS));
  assertTrue(nss.check(Namespace.xmlns+"0", EXAMPLE2_NS));
  
  assertTrue(nss.getNamespaces().size()==4);
  assertTrue(nss.getNamespaces().get(NamespacePrefixMapper.PROV_NS).equals("prov"));
  assertTrue(nss.getNamespaces().get(EXAMPLE_NS).equals("ex"));
  assertTrue(nss.getNamespaces().get(XSD_NS).equals("xsd"));
  assertTrue(nss.getNamespaces().get(EXAMPLE2_NS).equals(Namespace.xmlns+"0"));
  
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces2 () 
{
  Activity a1=pFactory.newActivity(q("a1"));
  a1.getType().add(pFactory.newType(pFactory.newQualifiedName(EXAMPLE_NS, "Amazing", "ex2"), 
                   name.PROV_QUALIFIED_NAME));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All prefixes: " + nss.getPrefixes());
  //System.out.println("All ns: " + nss.getNamespaces());
  assertNull(nss.getDefaultNamespace());
  assertTrue(nss.getPrefixes().size()==4);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  assertTrue(nss.check("ex2", EXAMPLE_NS));
  assertTrue(nss.check("xsd", XSD_NS));
  
  
  assertTrue(nss.getNamespaces().size()==3);
  assertTrue(nss.getNamespaces().get(NamespacePrefixMapper.PROV_NS).equals("prov"));
  assertTrue(nss.getNamespaces().get(EXAMPLE_NS).equals("ex"));
  assertTrue(nss.getNamespaces().get(XSD_NS).equals("xsd"));
  
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces4 () 
{
  Activity a1=pFactory.newActivity(q("a1"));
  a1.getLocation().add(pFactory.newLocation(pFactory.newQualifiedName(EXAMPLE_NS, "Amazing",null), 
                       name.PROV_QUALIFIED_NAME));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All ns: " + nss.getPrefixes());
  assertTrue(nss.getDefaultNamespace().equals(EXAMPLE_NS));
  assertTrue(nss.getPrefixes().size()==3);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  assertTrue(nss.check("xsd", XSD_NS));
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces9 () 
{
  Activity a1=pFactory.newActivity(q("a1"));
  a1.getOther().add(pFactory.newOther(pFactory.newQualifiedName(EXAMPLE2_NS,"tag1", "ex"),
                     pFactory.newQualifiedName(EXAMPLE3_NS,"tag1", "ex"), 
                     name.PROV_QUALIFIED_NAME));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All prefixes: " + nss.getPrefixes());
  //System.out.println("All ns: " + nss.getNamespaces());
  assertNull(nss.getDefaultNamespace());
  assertTrue(nss.getPrefixes().size()==5);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  assertTrue(nss.check("xsd", XSD_NS));
  assertTrue(nss.check(Namespace.xmlns+"0", EXAMPLE2_NS));
  assertTrue(nss.check(Namespace.xmlns+"1", EXAMPLE3_NS));
  
  assertTrue(nss.getNamespaces().size()==5);
  assertTrue(nss.getNamespaces().get(NamespacePrefixMapper.PROV_NS).equals("prov"));
  assertTrue(nss.getNamespaces().get(EXAMPLE_NS).equals("ex"));
  assertTrue(nss.getNamespaces().get(XSD_NS).equals("xsd"));
  assertTrue(nss.getNamespaces().get(EXAMPLE2_NS).equals(Namespace.xmlns+"0"));
  assertTrue(nss.getNamespaces().get(EXAMPLE3_NS).equals(Namespace.xmlns+"1"));
  
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces1 () 
{
  Activity a1=pFactory.newActivity(q("a1"));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All ns: " + nss.getPrefixes());
  assertNull(nss.getDefaultNamespace());
  assertTrue(nss.getPrefixes().size()==3);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  
  assertTrue(nss.check("xsd", NamespacePrefixMapper.XSD_NS));
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces5 () 
{
  Activity a1=pFactory.newActivity(q("a1"));
  a1.getType().add(pFactory.newType(pFactory.newQualifiedName("http://www.w3.org/ns/prov#", "emptyCollection", "prov"), 
                   name.PROV_QUALIFIED_NAME));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All ns: " + nss.getPrefixes());
  assertNull(nss.getDefaultNamespace());
  assertTrue(nss.getPrefixes().size()==3);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  assertTrue(nss.check("xsd", XSD_NS));
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces3 () 
{
  Activity a1=pFactory.newActivity(q("a1"));
  a1.getType().add(pFactory.newType(pFactory.newQualifiedName(EXAMPLE_NS, "Amazing", "ex"), 
                   name.PROV_QUALIFIED_NAME));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All ns: " + nss.getPrefixes());
  assertNull(nss.getDefaultNamespace());
  assertTrue(nss.getPrefixes().size()==3);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  assertTrue(nss.check("xsd", XSD_NS));
}

代码示例来源:origin: org.openprovenance.prov/prov-rdf

RDFFormat format,
             Namespace namespace) {    
Map<String,String> prefixes=namespace.getPrefixes();
if (namespace.getDefaultNamespace()!=null) {

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces10 () 
{
  Activity a1=pFactory.newActivity(q("a10"));
  a1.getType().add(pFactory.newType(pFactory.newQualifiedName(EXAMPLE_NS, "Amazing","other"), 
                       name.PROV_QUALIFIED_NAME));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All prefixes: " + nss.getPrefixes());
  //System.out.println("All ns: " + nss.getNamespaces());
  assertNull(nss.getDefaultNamespace());
  assertTrue(nss.getPrefixes().size()==4);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  assertTrue(nss.check("other", EXAMPLE_NS));
  assertTrue(nss.check("xsd", XSD_NS));
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces6 () 
{
  Activity a1=pFactory.newActivity(q("a1"));
  a1.getOther().add(pFactory.newOther(pFactory.newQualifiedName(EXAMPLE_NS,"tag1", "ex"),
                     pFactory.newQualifiedName("http://www.w3.org/ns/prov#", "emptyCollection", "prov"), 
                     name.PROV_QUALIFIED_NAME));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All ns: " + nss.getPrefixes());
  assertNull(nss.getDefaultNamespace());
  assertTrue(nss.getPrefixes().size()==3);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  assertTrue(nss.check("xsd", XSD_NS));
}

代码示例来源:origin: lucmoreau/ProvToolbox

public void testNamespaces7 () 
{
  Activity a1=pFactory.newActivity(q("a1"));
  a1.getOther().add(pFactory.newOther(pFactory.newQualifiedName (EXAMPLE2_NS,"tag1", "ex2"),
                     pFactory.newQualifiedName("http://www.w3.org/ns/prov#", "emptyCollection", "prov"), 
                     name.PROV_QUALIFIED_NAME));
  Document doc=pFactory.newDocument();
  doc.getStatementOrBundle().add(a1);
  Namespace nss=Namespace.gatherNamespaces(doc);
  //System.out.println("Default ns is: " + nss.getDefaultNamespace());
  //System.out.println("All ns: " + nss.getPrefixes());
  assertNull(nss.getDefaultNamespace());
  assertTrue(nss.getPrefixes().size()==4);
  assertTrue(nss.check("prov", NamespacePrefixMapper.PROV_NS));
  assertTrue(nss.check("ex", EXAMPLE_NS));
  assertTrue(nss.check("xsd", XSD_NS));
  assertTrue(nss.check("ex2", EXAMPLE2_NS));
}

相关文章