Search in sources :

Example 1 with PrefixMapping2

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);
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMapping2(org.apache.jena.sparql.util.PrefixMapping2) IRIResolver(org.apache.jena.riot.system.IRIResolver)

Example 2 with PrefixMapping2

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();
        }
    }
}
Also used : PrefixMapping2(org.apache.jena.sparql.util.PrefixMapping2)

Example 3 with PrefixMapping2

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());
}
Also used : PrefixMapping2(org.apache.jena.sparql.util.PrefixMapping2)

Aggregations

PrefixMapping2 (org.apache.jena.sparql.util.PrefixMapping2)3 IRIResolver (org.apache.jena.riot.system.IRIResolver)1 PrefixMapping (org.apache.jena.shared.PrefixMapping)1