Class SplitIRI

java.lang.Object
org.apache.jena.util.SplitIRI

public class SplitIRI extends Object
Code to split an URI or IRI into prefix and local part. Historically, 'prefix' is referred to as 'namespace' reflecting RDF/XML history.

For display, use localname(java.lang.String) and namespace(java.lang.String). This follows Turtle, adds some pragmatic rulesm but does not escape any characters. A URI is split never split before the last / or last #, if present. See splitpoint(java.lang.String) for more details.

This code form the machinery behind Node.getLocalName() Node.getNameSpace() for URI Nodes.

localnameTTL(java.lang.String) is strict Turtle; it is the same local name as before, but escaped if necessary.

The functions namespaceXML(java.lang.String) and localnameXML(java.lang.String) apply the rules for XML qnames.

  • Constructor Details

    • SplitIRI

      public SplitIRI()
  • Method Details

    • namespace

      public static String namespace(String string)
      Return the 'namespace' (prefix) for a URI string. Use with localname(java.lang.String)
    • localname

      public static String localname(String string)
      Calculate a localname - do not escape PN_LOCAL_ESC. This is not guaranteed to be legal Turtle. Use with namespace(java.lang.String)
    • namespaceTTL

      public static String namespaceTTL(String string)
      Return the 'namespace' (prefix) for a URI string, legal for Turtle and goes with localnameTTL(java.lang.String)
    • localnameTTL

      public static String localnameTTL(String string)
      Calculate a localname - enforce legal Turtle escape PN_LOCAL_ESC, check for final '.' Use with namespaceTTL(java.lang.String)
    • splitpoint

      public static int splitpoint(String uri)
      Find the URI split point, return the index into the string that is the first character of a legal Turtle local name.

      This is a pragmatic choice, not just finding the maximal point. For example, with escaping '/' can be included but that means http://example/path/abc could split to give http://example/ and path/abc .

      Split URN's after ':'.

      Parameters:
      uri - URI string
      Returns:
      The split point, or -1 for "not found".
    • splitXML

      public static int splitXML(String string)
      Split point, according to XML qname rules. This is the longest NCName at the end of the uri. See Util.splitNamespaceXML(java.lang.String).
    • namespaceXML

      public static String namespaceXML(String string)
      Namespace, according to XML qname rules. Use with localnameXML(java.lang.String).
    • localnameXML

      public static String localnameXML(String string)
      Localname, according to XML qname rules.