Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
added serialization support
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Jan 17, 2009
1 parent 44aef0e commit e48e337
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion svnkit/src/org/tmatesoft/svn/core/SVNURL.java
Expand Up @@ -12,6 +12,12 @@
package org.tmatesoft.svn.core;

import java.io.File;
import java.io.Serializable;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamException;
import java.io.StreamCorruptedException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
Expand Down Expand Up @@ -43,7 +49,7 @@
* @author TMate Software Ltd.
* @see <a target="_top" href="http://svnkit.com/kb/examples/">Examples</a>
*/
public class SVNURL {
public class SVNURL implements Serializable {
/**
* Creates a new <b>SVNURL</b> representation from the given url
* components.
Expand Down Expand Up @@ -568,4 +574,24 @@ private static String getPath(URL url) {
return path;
}

private synchronized void writeObject(ObjectOutputStream s) throws IOException {
s.writeUTF(toDecodedString());
}

private synchronized void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
// use this field temporarily until readResolve is called
myEncodedPath = s.readUTF();
}

private Object readResolve() throws ObjectStreamException {
try {
return new SVNURL(myEncodedPath,false);
} catch (SVNException e) {
StreamCorruptedException x = new StreamCorruptedException("Failed to load SVNURL");
x.initCause(e);
throw x;
}
}

private static final long serialVersionUID = 1L;
}

0 comments on commit e48e337

Please sign in to comment.