/** * Return a map of all the discovered prefixes */ public Map<String, String> getPrefixMap() { return prefixMapping.getNsPrefixMap(); }
public static int hash(Prologue prologue) { final int prime = 31 ; int x = 1 ; if ( prologue.seenBaseURI ) x = prime * x + prologue.getBaseURI().hashCode() ; else x = 1237 ; if ( prologue.prefixMap != null ) x = prime * x + prologue.prefixMap.getNsPrefixMap().hashCode() ; return x ; } }
@Override public PrefixMapping setNsPrefixes(PrefixMapping other) { setNsPrefixes(other.getNsPrefixMap()); return this; }
/** Add the bindings of other to our own. We defer to the general case because we have to ensure the URIs are checked. @param other the PrefixMapping whose bindings we are to add to this. */ @Override public PrefixMapping setNsPrefixes( PrefixMapping other ) { return setNsPrefixes( other.getNsPrefixMap() ); }
/** Add the bindings of other to our own. We defer to the general case because we have to ensure the URIs are checked. @param other the PrefixMapping whose bindings we are to add to this. */ @Override public PrefixMapping setNsPrefixes( PrefixMapping other ) { return setNsPrefixes( other.getNsPrefixMap() ); }
@Override public Map<String, String> getNsPrefixMap() { return prefixMapping().getNsPrefixMap(); } }
@Override public Map<String, String> getNsPrefixMap() { Map<String, String> result = CollectionFactory.createHashedMap(); List<Graph> graphs = poly.getSubGraphs(); for (int i = graphs.size(); i > 0;) result.putAll( graphs.get( --i ).getPrefixMapping().getNsPrefixMap() ); result.remove( "" ); result.putAll( getBaseMapping().getNsPrefixMap() ); return result; }
@Override public PrefixMapping withDefaultMappings(PrefixMapping other) { other.getNsPrefixMap().entrySet().forEach(entry->{ String prefix = entry.getKey(); String uri = entry.getValue(); if (getNsPrefixURI( prefix ) == null && getNsURIPrefix( uri ) == null) setNsPrefix( prefix, uri ); }); return this; }
@Override public Map<String, String> getNsPrefixMap() throws ReadDeniedException, AuthenticationRequiredException { checkRead(); return holder.getBaseItem().getNsPrefixMap(); }
private static void print(String label, PrefixMapping pmap) { System.out.println(label); pmap.getNsPrefixMap().forEach((p,u)->System.out.printf(" %s: -> <%s>\n", p,u)) ; } }
@Override public boolean samePrefixMappingAs(PrefixMapping other) { if ( numPrefixes() != other.numPrefixes() ) return false; return getNsPrefixMap().equals(other.getNsPrefixMap()); }
@Override public PrefixMapping setNsPrefixes(PrefixMapping pmap) { if ( pmap instanceof PrefixMappingBase ) { PrefixMappingBase pmap2 = (PrefixMappingBase)pmap; pmap2.apply((p,u)->setNsPrefix(p, u)); return this; } // Need to create as a map (a copy) and then add. setNsPrefixes(pmap.getNsPrefixMap()); return this; }
static public PrefixMapping used(Op op, PrefixMapping pmap) { PrefixMapping pmap2 = new PrefixMappingImpl() ; PrefixFinder finder = new PrefixFinder(pmap2, pmap.getNsPrefixMap()) ; OpWalker.walk(op, finder) ; return pmap2 ; }
/** test that we can extract a proper Map from a PrefixMapping */ public void testPrefixMappingMap() { PrefixMapping ns = getCrispyRope(); Map<String, String> map = ns.getNsPrefixMap(); assertEquals( "map should have two elements", 2, map.size() ); assertEquals( crispURI, map.get( "crisp" ) ); assertEquals( "scheme:rope/string#", map.get( "rope" ) ); }
/** test that we can extract a proper Map from a PrefixMapping */ public void testPrefixMappingMap() { PrefixMapping ns = getCrispyRope(); Map<String, String> map = ns.getNsPrefixMap(); assertEquals( "map should have two elements", 2, map.size() ); assertEquals( crispURI, map.get( "crisp" ) ); assertEquals( "scheme:rope/string#", map.get( "rope" ) ); }
protected static void stripNamespacesAndBase(Query q) { Map<String, String> prefixes = q.getPrefixMapping().getNsPrefixMap(); for (String prefix : prefixes.keySet()) { q.getPrefixMapping().removeNsPrefix(prefix); } q.setBaseURI((String)null); } }
public void testPolyMapOverridesFromTheLeft() { g1.getPrefixMapping().setNsPrefix( "a", "eh:/U1" ); g2.getPrefixMapping().setNsPrefix( "a", "eh:/U2" ); String a = poly.getPrefixMapping().getNsPrefixMap().get( "a" ); assertEquals( "eh:/U1", a ); }
public void testPolyMapOverridesFromTheLeft() { g1.getPrefixMapping().setNsPrefix( "a", "eh:/U1" ); g2.getPrefixMapping().setNsPrefix( "a", "eh:/U2" ); String a = poly.getPrefixMapping().getNsPrefixMap().get( "a" ); assertEquals( "eh:/U1", a ); }
public void testPolyMapHandlesBase() { g1.getPrefixMapping().setNsPrefix( "", "eh:/U1" ); g2.getPrefixMapping().setNsPrefix( "", "eh:/U2" ); String a = poly.getPrefixMapping().getNsPrefixMap().get( "" ); assertEquals( poly.getPrefixMapping().getNsPrefixURI( "" ), a ); } }
public void testPolyMapHandlesBase() { g1.getPrefixMapping().setNsPrefix( "", "eh:/U1" ); g2.getPrefixMapping().setNsPrefix( "", "eh:/U2" ); String a = poly.getPrefixMapping().getNsPrefixMap().get( "" ); assertEquals( poly.getPrefixMapping().getNsPrefixURI( "" ), a ); } }