/** Use the prefix map to turn a URI into a qname, or return the original URI */ public String shortForm(String uri) { return prefixMap.shortForm(uri) ; }
/** Answer a String representing the node, taking into account the PrefixMapping. The horrible test against null is a stopgap to avoid a circularity issue. TODO fix the circularity issue */ @Override public String toString( PrefixMapping pm, boolean quoting ) { return pm == null ? (String) label : pm.shortForm( (String) label ); }
/** Answer a String representing the node, taking into account the PrefixMapping. The horrible test against null is a stopgap to avoid a circularity issue. TODO fix the circularity issue */ @Override public String toString( PrefixMapping pm, boolean quoting ) { return pm == null ? (String) label : pm.shortForm( (String) label ); }
@Override public String shortForm(String uri) { return this.prefixes.shortForm(uri); }
@Override public String shorten(String uri) { return prefixMapping.shortForm(uri); }
public static String strForURI(String uri, PrefixMapping pm) { if ( pm != null ) { String x = pm.shortForm(uri) ; if ( !x.equals(uri) ) return x ; } return "<" + uri + ">" ; } }
public static String strForURI(String uri, PrefixMapping pm) { if ( pm != null ) { String x = pm.shortForm(uri) ; if ( !x.equals(uri) ) return x ; } return "<" + uri + ">" ; } }
@Override public String shortForm( String uri ) { return getPrefixMapping().shortForm( uri ); }
@Override public String shortForm( String uri ) { return getPrefixMapping().shortForm( uri ); }
@Override public String shortForm(final String uri) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); return holder.getBaseItem().shortForm(uri); }
/** 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; }
/** 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; }
private void node(Node n) { if ( ! n.isURI() ) return ; String uri = n.getURI() ; if ( usedPMap.shortForm(uri) != uri ) return ; for ( Map.Entry<String, String> e : pmap.entrySet() ) { String k = e.getKey(); String v = e.getValue(); if ( uri.startsWith( v ) ) { usedPMap.setNsPrefix( k, v ); return; } } } }
/** @see org.apache.jena.shared.PrefixMapping#shortForm(java.lang.String) */ @Override public String shortForm(final String uri) { PrefixMapping pmapLocal = super.getLocalPrefixMapping(); PrefixMapping pmapGlobal = super.getGlobalPrefixMapping(); String s = pmapLocal.shortForm(uri); if (pmapGlobal == null) { return s; } if (s == null || s.equals(uri)) { s = pmapGlobal.shortForm(uri); if (s != null && !s.equals(uri)) { boolean b = false; try { b = (boolean) checkValidPrefixMethod.invoke(null, s); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (b) { String prefix = s.substring(0, s.indexOf(":")); pmapLocal.setNsPrefix(prefix, pmapGlobal.getNsPrefixURI(prefix)); } } } return s; }
private static String prefixFor(String uri, PrefixMapping mapping) { if ( mapping == null ) return null ; String pname = mapping.shortForm(uri) ; if ( pname != uri && checkValidPrefixName(pname) ) return pname ; pname = mapping.qnameFor(uri) ; if ( pname != null && checkValidPrefixName(pname) ) return pname ; return null ; }
public static void testShortForm( String title, PrefixMapping ns ) { ns.setNsPrefix( "crisp", crispURI ); ns.setNsPrefix( "butter", butterURI ); assertEquals( title, "", ns.shortForm( "" ) ); assertEquals( title, ropeURI, ns.shortForm( ropeURI ) ); assertEquals( title, "crisp:tail", ns.shortForm( crispURI + "tail" ) ); assertEquals( title, "butter:here:we:are", ns.shortForm( butterURI + "here:we:are" ) ); }
public static void testShortForm( String title, PrefixMapping ns ) { ns.setNsPrefix( "crisp", crispURI ); ns.setNsPrefix( "butter", butterURI ); assertEquals( title, "", ns.shortForm( "" ) ); assertEquals( title, ropeURI, ns.shortForm( ropeURI ) ); assertEquals( title, "crisp:tail", ns.shortForm( crispURI + "tail" ) ); assertEquals( title, "butter:here:we:are", ns.shortForm( butterURI + "here:we:are" ) ); }
/** * Return a simplified print string for a Node. */ public static String print(Node node) { if (node instanceof Node_URI) { String uri = ((Node_URI)node).getURI(); String suri = prefixMapping == null ? uri : prefixMapping.shortForm(uri); if (uri.equals(suri)) { return "<" + uri + ">"; } else { return suri; } } else if (node instanceof Node_Literal) { String lf = node.getLiteralLexicalForm(); // RDF 1.1 : Print xsd:string without ^^xsd:string return "'" + lf + "'" + (Util.isSimpleString(node) ? "" : "^^" + node.getLiteralDatatypeURI()); } else if (node instanceof Node_ANY) { return "*"; } if (node == null) { return "null"; } return node.toString(); }
/** * Return a simplified print string for a Node. */ public static String print(Node node) { if (node instanceof Node_URI) { String uri = ((Node_URI)node).getURI(); String suri = prefixMapping == null ? uri : prefixMapping.shortForm(uri); if (uri.equals(suri)) { return "<" + uri + ">"; } else { return suri; } } else if (node instanceof Node_Literal) { String lf = node.getLiteralLexicalForm(); // RDF 1.1 : Print xsd:string without ^^xsd:string return "'" + lf + "'" + (Util.isSimpleString(node) ? "" : "^^" + node.getLiteralDatatypeURI()); } else if (node instanceof Node_ANY) { return "*"; } if (node == null) { return "null"; } return node.toString(); }