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

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

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

Namespace.getDefaultNamespace介绍

暂无

代码示例

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

/**
 * Extends this Namespace with all the prefix/namespace registration of the Namespace received as argument. 
 * @param ns the {@link Namespace} whose prefix/namespace registration are added to this {@link Namespace}.
 */
public void extendWith(Namespace ns) {
if (ns==null) return;
if (ns.getDefaultNamespace()!=null) {
  registerDefault(ns.getDefaultNamespace());
}
for (String prefix: ns.prefixes.keySet()) {
  register(prefix, ns.prefixes.get(prefix));
}
}

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

public void unregisterDeafult(String namespace) {
String val=getDefaultNamespace();
if (val!=null){
  if (val.equals(namespace)) {
  setDefaultNamespace(null);
  }
}
}

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

@Override
@Basic
public String getDefaultNamespace () {
  return super.getDefaultNamespace();
}

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

public void unregisterDeafult(String namespace) {
String val=getDefaultNamespace();
if (val!=null){
  if (val.equals(namespace)) {
  setDefaultNamespace(null);
  }
}
}

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

/**
 * Extends this Namespace with all the prefix/namespace registration of the Namespace received as argument. 
 * @param ns the {@link Namespace} whose prefix/namespace registration are added to this {@link Namespace}.
 */
public void extendWith(Namespace ns) {
if (ns==null) return;
if (ns.getDefaultNamespace()!=null) {
  registerDefault(ns.getDefaultNamespace());
}
for (String prefix: ns.prefixes.keySet()) {
  register(prefix, ns.prefixes.get(prefix));
}
}

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

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: 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 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: 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 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 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));
}

相关文章