|
From: <lh...@us...> - 2008-05-27 13:16:40
|
Revision: 70
http://tinytim.svn.sourceforge.net/tinytim/?rev=70&view=rev
Author: lheuer
Date: 2008-05-27 06:16:44 -0700 (Tue, 27 May 2008)
Log Message:
-----------
IRI normalization
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/IRI.java
Modified: tinytim/trunk/src/main/java/org/tinytim/IRI.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/IRI.java 2008-05-24 15:29:21 UTC (rev 69)
+++ tinytim/trunk/src/main/java/org/tinytim/IRI.java 2008-05-27 13:16:44 UTC (rev 70)
@@ -20,9 +20,12 @@
*/
package org.tinytim;
+import java.io.UnsupportedEncodingException;
import java.net.URI;
+import java.net.URLDecoder;
import org.tmapi.core.Locator;
+import org.tmapi.core.TMAPIRuntimeException;
/**
* Immutable representation of an IRI.
@@ -33,15 +36,18 @@
public final class IRI implements Locator {
private final URI _uri;
+ private final String _reference;
public IRI(String reference) {
- this(URI.create(reference));
+ try {
+ _reference = URLDecoder.decode(reference, "utf-8");
+ }
+ catch (UnsupportedEncodingException ex) {
+ throw new TMAPIRuntimeException(ex);
+ }
+ _uri = URI.create(_reference.replace(" ", "%20"));
}
- private IRI(URI uri) {
- _uri = uri;
- }
-
/* (non-Javadoc)
* @see org.tmapi.core.Locator#getNotation()
*/
@@ -53,14 +59,14 @@
* @see org.tmapi.core.Locator#getReference()
*/
public String getReference() {
- return _uri.toString();
+ return _reference;
}
/* (non-Javadoc)
* @see org.tmapi.core.Locator#resolveRelative(java.lang.String)
*/
public Locator resolveRelative(String reference) {
- return new IRI(_uri.resolve(reference));
+ return new IRI(_uri.resolve(reference).toString());
}
/* (non-Javadoc)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|