@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 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; }
/** Expand a prefixed URI. There's an assumption that any URI of the form Head:Tail is subject to mapping if Head is in the prefix mapping. So, if someone takes it into their heads to define eg "http" or "ftp" we have problems. */ @Override public String expandPrefix( String prefixed ) { String s = getBaseMapping().expandPrefix( prefixed ); if (s.equals( prefixed )) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().expandPrefix( prefixed ); if ( !ss.equals( prefixed ) ) { return ss; } } } return s; }
/** Compress the URI using the prefix mapping. This version of the code looks through all the maplets and checks each candidate prefix URI for being a leading substring of the argument URI. There's probably a much more efficient algorithm available, preprocessing the prefix strings into some kind of search table, but for the moment we don't need it. */ @Override public String shortForm( String uri ) { String s = getBaseMapping().shortForm( uri ); if (s.equals( uri )) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().shortForm( uri ); if ( !ss.equals( uri ) ) { return ss; } } } return s; }
/** Expand a prefixed URI. There's an assumption that any URI of the form Head:Tail is subject to mapping if Head is in the prefix mapping. So, if someone takes it into their heads to define eg "http" or "ftp" we have problems. */ @Override public String expandPrefix( String prefixed ) { String s = getBaseMapping().expandPrefix( prefixed ); if (s.equals( prefixed )) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().expandPrefix( prefixed ); if ( !ss.equals( prefixed ) ) { return ss; } } } return s; }
@Override public String getNsURIPrefix( String uri ) { String s = getBaseMapping().getNsURIPrefix( uri ); if (s == null) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().getNsURIPrefix( uri ); if ( ss != null && ss.length() > 0 ) { return ss; } } } return s; }
/** Compress the URI using the prefix mapping. This version of the code looks through all the maplets and checks each candidate prefix URI for being a leading substring of the argument URI. There's probably a much more efficient algorithm available, preprocessing the prefix strings into some kind of search table, but for the moment we don't need it. */ @Override public String shortForm( String uri ) { String s = getBaseMapping().shortForm( uri ); if (s.equals( uri )) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().shortForm( uri ); if ( !ss.equals( uri ) ) { return ss; } } } return s; }
@Override public String getNsURIPrefix( String uri ) { String s = getBaseMapping().getNsURIPrefix( uri ); if (s == null) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().getNsURIPrefix( uri ); if ( ss != null && ss.length() > 0 ) { return ss; } } } return s; }
@Override public String getNsPrefixURI( String prefix ) { PrefixMapping bm = getBaseMapping(); String s = bm.getNsPrefixURI( prefix ); if (s == null && prefix.length() > 0) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().getNsPrefixURI( prefix ); if ( ss != null ) { return ss; } } } return s; }
@Override public String getNsPrefixURI( String prefix ) { PrefixMapping bm = getBaseMapping(); String s = bm.getNsPrefixURI( prefix ); if (s == null && prefix.length() > 0) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().getNsPrefixURI( prefix ); if ( ss != null ) { return ss; } } } return s; }
@Override public String qnameFor( String uri ) { String result = getBaseMapping().qnameFor( uri ); if (result == null) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().qnameFor( uri ); if ( ss != null ) { return ss; } } } return result; } }
@Override public String qnameFor( String uri ) { String result = getBaseMapping().qnameFor( uri ); if (result == null) { List<Graph> graphs = poly.getSubGraphs(); for ( Graph graph : graphs ) { String ss = graph.getPrefixMapping().qnameFor( uri ); if ( ss != null ) { return ss; } } } return result; } }
private static String polyadicGraphToString(Polyadic poly) { Graph baseGraph = poly.getBaseGraph(); List<Graph> subGraphs = poly.getSubGraphs(); return simpleName(poly) + "[" + hashHex(poly) + ", base=" + graphToString(baseGraph) + ", subgraphs=" + subGraphsToString(subGraphs, baseGraph) + "]"; }
private void collectLeafGraphs(final Graph graph, final Set<Graph> prevLeaves) { if (graph instanceof Polyadic) { final Polyadic union = (Polyadic) graph; if (union.getBaseGraph() != null) collectLeafGraphs(union.getBaseGraph(), prevLeaves); for (final Graph graph2 : union.getSubGraphs()) collectLeafGraphs(graph2, prevLeaves); } else if (graph instanceof Dyadic) { final Dyadic dyadic = (Dyadic) graph; if (dyadic.getL() instanceof Graph) collectLeafGraphs((Graph) dyadic.getL(), prevLeaves); if (dyadic.getR() instanceof Graph) collectLeafGraphs((Graph) dyadic.getR(), prevLeaves); } else if (graph instanceof InfGraph) collectLeafGraphs(((InfGraph) graph).getRawGraph(), prevLeaves); else if (_leafGraphs.add(graph) && !prevLeaves.contains(graph)) { _changedGraphs.add(graph); graph.getEventManager().register(this); } }
private void collectLeafGraphs(final Graph graph, final Set<Graph> prevLeaves) { if (graph instanceof Polyadic) { final Polyadic union = (Polyadic) graph; if (union.getBaseGraph() != null) collectLeafGraphs(union.getBaseGraph(), prevLeaves); for (final Graph graph2 : union.getSubGraphs()) collectLeafGraphs(graph2, prevLeaves); } else if (graph instanceof Dyadic) { final Dyadic dyadic = (Dyadic) graph; if (dyadic.getL() instanceof Graph) collectLeafGraphs((Graph) dyadic.getL(), prevLeaves); if (dyadic.getR() instanceof Graph) collectLeafGraphs((Graph) dyadic.getR(), prevLeaves); } else if (graph instanceof InfGraph) collectLeafGraphs(((InfGraph) graph).getRawGraph(), prevLeaves); else if (_leafGraphs.add(graph) && !prevLeaves.contains(graph)) { _changedGraphs.add(graph); graph.getEventManager().register(this); } }
private void collectLeafGraphs(final Graph graph, final Set<Graph> prevLeaves) { if (graph instanceof Polyadic) { final Polyadic union = (Polyadic) graph; if (union.getBaseGraph() != null) collectLeafGraphs(union.getBaseGraph(), prevLeaves); for (final Graph graph2 : union.getSubGraphs()) collectLeafGraphs(graph2, prevLeaves); } else if (graph instanceof Dyadic) { final Dyadic dyadic = (Dyadic) graph; if (dyadic.getL() instanceof Graph) collectLeafGraphs((Graph) dyadic.getL(), prevLeaves); if (dyadic.getR() instanceof Graph) collectLeafGraphs((Graph) dyadic.getR(), prevLeaves); } else if (graph instanceof InfGraph) collectLeafGraphs(((InfGraph) graph).getRawGraph(), prevLeaves); else if (_leafGraphs.add(graph) && !prevLeaves.contains(graph)) { _changedGraphs.add(graph); graph.getEventManager().register(this); } }