use of org.apache.jena.sparql.util.PrefixMapping2 in project jena by apache.
the class Prologue method sub.
public Prologue sub(PrefixMapping newMappings, String base) {
// New prefix mappings
PrefixMapping ext = getPrefixMapping();
if (newMappings != null)
ext = new PrefixMapping2(ext, newMappings);
// New base.
IRIResolver r = resolver;
if (base != null)
r = IRIResolver.create(base);
return new Prologue(ext, r);
}
use of org.apache.jena.sparql.util.PrefixMapping2 in project jena by apache.
the class PrologueSerializer method printPrefixes.
public static void printPrefixes(Prologue prologue, IndentedWriter out) {
if (prologue.getPrefixMapping() == null)
return;
Map<String, String> pmap = null;
if (prologue.getPrefixMapping() instanceof PrefixMapping2) {
PrefixMapping2 pm2 = (PrefixMapping2) prologue.getPrefixMapping();
pmap = pm2.getNsPrefixMap(false);
} else {
Map<String, String> _pmap = prologue.getPrefixMapping().getNsPrefixMap();
pmap = _pmap;
}
if (pmap.size() > 0) {
//boolean first = true ;
for (String k : pmap.keySet()) {
String v = pmap.get(k);
out.print("PREFIX ");
out.print(k);
out.print(':');
out.print(' ', 4 - k.length());
// Include at least one space
out.print(' ');
out.print(FmtUtils.stringForURI(v));
out.newline();
}
}
}
use of org.apache.jena.sparql.util.PrefixMapping2 in project jena by apache.
the class Prologue method usePrologueFrom.
// Reverse of sub()
public void usePrologueFrom(Prologue other) {
prefixMap = new PrefixMapping2(other.prefixMap);
seenBaseURI = false;
if (other.resolver != null)
resolver = IRIResolver.create(getBaseURI());
}
Aggregations