public static boolean equalResources(Resource t, Resource that) throws ModelException { return t.getURI().equals(that.getURI()); /* boolean b = false; String tns = t.getNamespace(); String tn = t.getLocalName(); String thatns = that.getNamespace(); String thatn = that.getLocalName(); // System.err.print("Comparing " + t + " vs " + that + ": "); if(thatns == null) { if(tns == null) { // (null, null) // System.err.println("true"); return thatn.equals(tn); } else // (null, not null) maybe "that" did not detect names b = thatn.equals(t.getURI()); } else { if(tns != null) // (not null, not null) b = thatn.equals(tn) && thatns.equals(tns); else // (not null, null) maybe "this" did not detect names b = that.getURI().equals(tn); } if(b) return true; // else we need to check whether different namespace splitting is used if((tns != null ? tns.length() : 0) + (tn != null ? tn.length() : 0) == (thatns != null ? thatns.length() : 0) + (thatn != null ? thatn.length() : 0)) { b = t.getURI().equals(that.getURI()); } // System.err.println("" + b); return b; */ }
/** Extracts the namespace prefix out of a URI. */ public static String getNamespace(Resource r) throws ModelException { String ns = r.getNamespace(); return ns != null ? ns : guessNamespace(r.getURI()); }
/** Tests if the resource belongs to the RDF syntax/model namespace. */ public static boolean isRDF(Resource r) throws ModelException { return isRDF(r.getURI()); }
/** Delivers the name out of the URI (without the namespace prefix). */ public static String getLocalName(Resource r) throws ModelException { if (r.getNamespace() == null) return guessName(r.getURI()); else return r.getLocalName(); }