/** * Expand qnames to URIs. If the given URI appears * to start with one of the registered prefixes then * expand the prefix, otherwise return the original URI */ public static String expandQname(String uri) { return prefixMapping.expandPrefix( uri ); }
@Override public String expandPrefix(String prefixed) { return this.prefixes.expandPrefix(prefixed); }
/** Expand prefixed name * * @param qname The prefixed name to be expanded * @return URI, or null if not expanded. */ public String expandPrefixedName(String qname) { String s = prefixMap.expandPrefix(qname) ; if ( s.equals(qname) ) return null ; return s ; }
/** Expand prefixed name * * @param qname The prefixed name to be expanded * @return URI, or null if not expanded. */ public String expandPrefixedName(String qname) { String s = prefixMap.expandPrefix(qname) ; if ( s.equals(qname) ) return null ; return s ; }
/** @see com.hp.hpl.jena.shared.PrefixMapping#expandPrefix(java.lang.String) */ public String expandPrefix(String prefixed) { // Returns the unchanged prefixed name if no transformation // Helps cope with unusual URIs schemes. String s = pmapLocal.expandPrefix(prefixed) ; if ( pmapGlobal == null ) return s ; if ( s == null || s.equals(prefixed) ) { if ( pmapGlobal != null ) s = pmapGlobal.expandPrefix(prefixed) ; } return s ; }
/** @see com.hp.hpl.jena.shared.PrefixMapping#expandPrefix(java.lang.String) */ @Override public String expandPrefix(String prefixed) { // Returns the unchanged prefixed name if no transformation // Helps cope with unusual URIs schemes. String s = pmapLocal.expandPrefix(prefixed) ; if ( pmapGlobal == null ) return s ; if ( s == null || s.equals(prefixed) ) { if ( pmapGlobal != null ) s = pmapGlobal.expandPrefix(prefixed) ; } return s ; }
@Override public String expandPrefix( String prefixed ) { return getPrefixMapping().expandPrefix( prefixed ); }
private static String myExpandPrefix(PrefixMapping prefixMapping, String qname) { String s = prefixMapping.expandPrefix(qname) ; if ( s == null ) return null ; if ( s.equals(qname) ) { // The contract of expandPrefix is to return the original name if // there is no prefix but what s the expanded and original form are // actually the same character string ? int colon = qname.indexOf( ':' ); if (colon < 0) return null ; String prefix = qname.substring( 0, colon ) ; if ( prefixMapping.getNsPrefixURI(prefix) != null ) // The original and resolved forms are the same. return s ; return null ; } 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 (int i = 0; i < graphs.size(); i += 1) { String ss = graphs.get(i).getPrefixMapping().expandPrefix( prefixed ); if (!ss.equals( prefixed )) return ss; } } return s; }
public void processArgs(CmdArgModule cmdLine) { if ( cmdLine.getValues(setDecl) == null || cmdLine.getValues(setDecl).size() == 0 ) return ; for ( Iterator<String> iter = cmdLine.getValues(setDecl).iterator() ; iter.hasNext(); ) { String arg = iter.next(); String[] frags = arg.split("=", 2) ; if ( frags.length != 2) throw new RuntimeException("Can't split '"+arg+"' -- looking for '=' to separate name and value") ; String symbolName = frags[0] ; String value = frags[1] ; // Make it a long name. symbolName = symbolPrefixMapping.expandPrefix(symbolName) ; Symbol symbol = Symbol.create(symbolName) ; context.set(symbol, value) ; } ARQ.getContext().putAll(context) ; }
@Override protected String resolvePrefixedName(String pname, int line, int column) { if ( prologue.getPrefixMapping() == null ) throwException("No prefix mapping for prefixed name: "+pname, line, column) ; if ( ! StrUtils.contains(pname, ":") ) throwException("Prefixed name does not have a ':': "+pname, line, column) ; String uri = prologue.getPrefixMapping().expandPrefix(pname) ; if ( uri == null || uri.equals(pname) ) throwException("Can't resolve prefixed name: "+pname, line, column) ; return uri ; }
@Override protected String resolvePrefixedName(String pname, int line, int column) { if ( prologue.getPrefixMapping() == null ) throwException("No prefix mapping for prefixed name: "+pname, line, column) ; if ( ! StrUtils.contains(pname, ":") ) throwException("Prefixed name does not have a ':': "+pname, line, column) ; String uri = prologue.getPrefixMapping().expandPrefix(pname) ; if ( uri == null || uri.equals(pname) ) throwException("Can't resolve prefixed name: "+pname, line, column) ; return uri ; }
return NodeFactory.createAnon( new AnonId( token.substring( 1 ) ) ); } else if (token.indexOf(':') != -1) { String exp = prefixMapping.expandPrefix(token); // Local map first if (dtURI.indexOf(':') != -1) { String exp = prefixMapping.expandPrefix(dtURI); // Local map first
@Test public void prefix5() { String uri = "http://example/" ; PrefixMapping pmap = new PrefixMappingSDB(defaultPrefixURI, sdb) ; pmap.setNsPrefix("ex", uri) ; assertEquals(uri+"foo", pmap.expandPrefix("ex:foo")) ; }