org.openxri.xri3.impl
Class IRIUtils

java.lang.Object
  extended by org.openxri.xri3.impl.IRIUtils

public class IRIUtils
extends java.lang.Object

Utility class that provides XRI-IRI-URI transformations

Author:
wtan

Constructor Summary
IRIUtils()
           
 
Method Summary
static int decodeHex(java.lang.String s, int index)
          Attempts to decode a 3-character percent-encoded sequence to the numeric value.
static java.lang.String IRItoURI(java.lang.String iri)
          Transforms the given IRI to URI.
static java.lang.String IRItoXRI(java.lang.String iri)
           
protected static boolean isIPrivate(int cp)
           
protected static boolean isUCSChar(int cp)
           
protected static boolean isUCSCharOrIPrivate(int cp)
           
protected static java.lang.String toUTF8PercentEncoded(int cp)
           
static java.lang.String URItoIRI(java.lang.String uri)
          Transform the given URI to IRI according to the rules in RFC3987 section 3.2
static java.lang.String XRItoIRI(java.lang.String s, boolean inXref)
          Transforms the given XRI part to IRI-normal form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IRIUtils

public IRIUtils()
Method Detail

IRItoXRI

public static java.lang.String IRItoXRI(java.lang.String iri)

URItoIRI

public static java.lang.String URItoIRI(java.lang.String uri)
                                 throws java.io.UnsupportedEncodingException
Transform the given URI to IRI according to the rules in RFC3987 section 3.2

Parameters:
uri - - this MUST be a valid URI string. Use the java.net.URI class to check before using this method.
Returns:
Throws:
java.io.UnsupportedEncodingException

IRItoURI

public static java.lang.String IRItoURI(java.lang.String iri)
Transforms the given IRI to URI.

Parameters:
iri -
Returns:

toUTF8PercentEncoded

protected static java.lang.String toUTF8PercentEncoded(int cp)

isUCSCharOrIPrivate

protected static boolean isUCSCharOrIPrivate(int cp)

isUCSChar

protected static boolean isUCSChar(int cp)

isIPrivate

protected static boolean isIPrivate(int cp)

XRItoIRI

public static java.lang.String XRItoIRI(java.lang.String s,
                                        boolean inXref)
Transforms the given XRI part to IRI-normal form. This method does not parse the given String; it simply converts all '%' to '%25', and if inXref is true, also percent encodes '#', '?' and '/'.

Parameters:
s -
inXref -
Returns:

decodeHex

public static int decodeHex(java.lang.String s,
                            int index)
Attempts to decode a 3-character percent-encoded sequence to the numeric value.

Parameters:
s -
index -
Returns:
the numeric value of the %XX sequence, or -1 if the sequence is invalid.


Copyright © 2005-2012. All Rights Reserved.