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

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

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

Namespace.getNamespaces介绍

暂无

代码示例

代码示例来源: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

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="namespaces")
@Column(name="namespace_value")
@CollectionTable(name="namespace_map", joinColumns=@JoinColumn(name="pk"))

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

代码示例来源: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-model

/**
 * @param name the QName to convert to string
 * @param child argument used just for the purpose of debugging when throwing an exception
 * @return a string representation of the QualifiedName
 */
public String qualifiedNameToString(QName name, Namespace child) {
 if ((getDefaultNamespace()!=null) 
   && (getDefaultNamespace().equals(name.getNamespaceURI()))) {
   return name.getLocalPart();
 } else {
   String pref=getNamespaces().get(name.getNamespaceURI());
   if (pref!=null)  {
   return pref + ":" + name.getLocalPart();
   } else {
   if (parent!=null) {
     return parent.qualifiedNameToString(name,this);
   }
   else 
     throw new QualifiedNameException("unknown qualified name " + name 
                     + " with namespace " + toString()
                     + ((child==null)? "" : (" and " + child)));
   }
 }
 }

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

/**
 * @param name the QName to convert to string
 * @param child argument used just for the purpose of debugging when throwing an exception
 * @return a string representation of the QualifiedName
 */
public String qualifiedNameToString(QName name, Namespace child) {
 if ((getDefaultNamespace()!=null) 
   && (getDefaultNamespace().equals(name.getNamespaceURI()))) {
   return name.getLocalPart();
 } else {
   String pref=getNamespaces().get(name.getNamespaceURI());
   if (pref!=null)  {
   return pref + ":" + name.getLocalPart();
   } else {
   if (parent!=null) {
     return parent.qualifiedNameToString(name,this);
   }
   else 
     throw new QualifiedNameException("unknown qualified name " + name 
                     + " with namespace " + toString()
                     + ((child==null)? "" : (" and " + child)));
   }
 }
 }

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

protected QualifiedName convertURIToQualifiedName(URI uri) {
QualifiedName qualifiedName;
String uriNamespace = uri.getNamespace();
String prefix=namespace.getNamespaces().get(uriNamespace);
String uriLocalName = qnU.escapeProvLocalName(uri.getLocalName());
if (prefix!=null) {
  qualifiedName = pFactory.newQualifiedName(uriNamespace, uriLocalName, prefix);
} else {
  String defaultNS=namespace.getDefaultNamespace();
  if ((defaultNS!=null) && (defaultNS.equals(uriNamespace))) {
  qualifiedName = pFactory.newQualifiedName(uriNamespace, uriLocalName,null);
  } else {
  namespace.newPrefix(uriNamespace);
  String pref=namespace.getNamespaces().get(uriNamespace);
  qualifiedName = pFactory.newQualifiedName(uriNamespace, uriLocalName, pref);
  }
}    
return qualifiedName;
}

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

protected QualifiedName convertURIToQualifiedName(URI uri) {
QualifiedName qualifiedName;
String uriNamespace = uri.getNamespace();
String prefix=namespace.getNamespaces().get(uriNamespace);
String uriLocalName = qnU.escapeProvLocalName(uri.getLocalName());
if (prefix!=null) {
  qualifiedName = pFactory.newQualifiedName(uriNamespace, uriLocalName, prefix);
} else {
  String defaultNS=namespace.getDefaultNamespace();
  if ((defaultNS!=null) && (defaultNS.equals(uriNamespace))) {
  qualifiedName = pFactory.newQualifiedName(uriNamespace, uriLocalName,null);
  } else {
  namespace.newPrefix(uriNamespace);
  String pref=namespace.getNamespaces().get(uriNamespace);
  qualifiedName = pFactory.newQualifiedName(uriNamespace, uriLocalName, pref);
  }
}    
return qualifiedName;
}

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

/**
 * @param name the QualifiedName to convert to string
 * @param child argument used just for the purpose of debugging when throwing an exception
 * @return a string representation of the QualifiedName
 */
public String qualifiedNameToString(QualifiedName name, Namespace child) {
 if ((getDefaultNamespace()!=null) 
   && (getDefaultNamespace().equals(name.getNamespaceURI()))) {
   return name.getLocalPart();
 } else {
   String pref=getNamespaces().get(name.getNamespaceURI());
   if (pref!=null)  {
   return pref + ":" + name.getLocalPart();
   } else {
   if (parent!=null) {
     return parent.qualifiedNameToString(name,this);
   }
   else 
     throw new QualifiedNameException("unknown qualified name " + name 
                     + " with namespace " + toString()
                     + ((child==null)? "" : (" and " + child)));
   }
 }
 }
/**

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

/**
 * @param name the QualifiedName to convert to string
 * @param child argument used just for the purpose of debugging when throwing an exception
 * @return a string representation of the QualifiedName
 */
public String qualifiedNameToString(QualifiedName name, Namespace child) {
 if ((getDefaultNamespace()!=null) 
   && (getDefaultNamespace().equals(name.getNamespaceURI()))) {
   return name.getLocalPart();
 } else {
   String pref=getNamespaces().get(name.getNamespaceURI());
   if (pref!=null)  {
   return pref + ":" + name.getLocalPart();
   } else {
   if (parent!=null) {
     return parent.qualifiedNameToString(name,this);
   }
   else 
     throw new QualifiedNameException("unknown qualified name " + name 
                     + " with namespace " + toString()
                     + ((child==null)? "" : (" and " + child)));
   }
 }
 }
/**

代码示例来源: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 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"));
  
}

相关文章