public static Value decodeValue(final String s){
  if (s == null)   return null;
  final int slen=s.length();
  if (slen == 0)   throw new IllegalArgumentException("<Empty String>");
  final char ch=s.charAt(0);
  if (ch == '\"' || ch == '\'') {
    final int closeQuotePos=s.lastIndexOf(ch);
    if (closeQuotePos == 0)     throw new IllegalArgumentException(s);
    final String label=s.substring(1,closeQuotePos);
    if (slen == closeQuotePos + 1) {
      return new LiteralImpl(label);
    }
    final char ch2=s.charAt(closeQuotePos + 1);
    if (ch2 == '@') {
      final String languageCode=s.substring(closeQuotePos + 2);
      return new LiteralImpl(label,languageCode);
    }
 else     if (ch2 == '^') {
      if (slen <= closeQuotePos + 2)       throw new IllegalArgumentException(s);
      if (s.charAt(closeQuotePos + 2) != '^')       throw new IllegalArgumentException(s);
      final String datatypeStr=s.substring(closeQuotePos + 3);
      final URI datatypeURI=decodeURI(datatypeStr);
      return new LiteralImpl(label,datatypeURI);
    }
 else {
      throw new IllegalArgumentException(s);
    }
  }
 else   if (ch == '<') {
    if (s.charAt(slen - 1) != '>')     throw new IllegalArgumentException(s);
    final String uriStr=s.substring(1,slen - 1);
    return new URIImpl(uriStr);
  }
 else {
    throw new IllegalArgumentException(s);
  }
}

public static Value decodeValue ( final String s ) { if ( s == null ) return null ; final int slen = s . length ( ) ; if ( slen == 0 ) throw new IllegalArgumentException ( "<Empty String>" ) ; final char ch = s . charAt ( 0 ) ; if ( ch == '\"' || ch == '\'' ) { final int closeQuotePos = s . lastIndexOf ( ch ) ; if ( closeQuotePos == 0 ) throw new IllegalArgumentException ( s ) ; final String label = s . substring ( 1 , closeQuotePos ) ; if ( slen == closeQuotePos + 1 ) { return new LiteralImpl ( label ) ; } final char ch2 = s . charAt ( closeQuotePos + 1 ) ; if ( ch2 == '@' ) { final String languageCode = s . substring ( closeQuotePos + 2 ) ; return new LiteralImpl ( label , languageCode ) ; } else if ( ch2 == '^' ) { if ( slen <= closeQuotePos + 2 ) throw new IllegalArgumentException ( s ) ; if ( s . charAt ( closeQuotePos + 2 ) != '^' ) throw new IllegalArgumentException ( s ) ; final String datatypeStr = s . substring ( closeQuotePos + 3 ) ; final URI datatypeURI = decodeURI ( datatypeStr ) ; return new LiteralImpl ( label , datatypeURI ) ; } else { throw new IllegalArgumentException ( s ) ; } } else if ( ch == '<' ) { if ( s . charAt ( slen - 1 ) != '>' ) throw new IllegalArgumentException ( s ) ; final String uriStr = s . substring ( 1 , slen - 1 ) ; return new URIImpl ( uriStr ) ; } else { throw new IllegalArgumentException ( s ) ; } }
decode a uri or literal .
