Makefile.am: Added URLDecoder and URLEncoder.
authorWarren Levy <warrenl@cygnus.com>
Fri, 23 Apr 1999 16:36:22 +0000 (16:36 +0000)
committerWarren Levy <warrenl@gcc.gnu.org>
Fri, 23 Apr 1999 16:36:22 +0000 (16:36 +0000)
* Makefile.am: Added URLDecoder and URLEncoder.
* Makefile.in: Rebuilt.
* java/net/ServerSocket.java (setSocketFactory): Renamed from
setSocketImplFactory to match spec.
* java/net/Socket.java (getSoLinger): Changed return type to
match spec.
* java/net/URLDecoder.java: New file.
* java/net/URLEncoder.java: New file.

From-SVN: r26605

libjava/ChangeLog
libjava/Makefile.am
libjava/Makefile.in
libjava/java/net/ServerSocket.java
libjava/java/net/Socket.java
libjava/java/net/URLDecoder.java [new file with mode: 0644]
libjava/java/net/URLEncoder.java [new file with mode: 0644]
libjava/testsuite/Makefile.in

index da93b9cc83141e574cc71973d42ab6565c778f55..5f4e85b84d37ff315cb60f66d76ecfe6739a1277 100644 (file)
@@ -1,3 +1,16 @@
+1999-04-23  Warren Levy  <warrenl@cygnus.com>
+
+       * Makefile.am: Added URLDecoder and URLEncoder.
+       * Makefile.in: Rebuilt.
+
+       * java/net/ServerSocket.java (setSocketFactory): Renamed from
+       setSocketImplFactory to match spec.
+       * java/net/Socket.java (getSoLinger): Changed return type to
+       match spec.
+
+       * java/net/URLDecoder.java: New file.
+       * java/net/URLEncoder.java: New file.
+
 1999-04-21  Tom Tromey  <tromey@cygnus.com>
 
        * java/lang/natString.cc (getBytes): Reverted earlier change and
index 7ac4d524d7ddbe13401fcbf7fc4e3965cef8e63f..1d28807a037b51ac71e33f15564b3bf2a959f447 100644 (file)
@@ -513,6 +513,8 @@ java/net/SocketImpl.java \
 java/net/SocketImplFactory.java        \
 java/net/URL.java \
 java/net/URLConnection.java \
+java/net/URLDecoder.java \
+java/net/URLEncoder.java \
 java/net/URLStreamHandler.java \
 java/net/URLStreamHandlerFactory.java \
 java/net/UnknownHostException.java \
index d5fd10365fb58a4db48a080a995e3120e7fff32c..5a7fe608b6c8fb93f82946073d2940f9e2313527 100644 (file)
@@ -374,6 +374,8 @@ java/net/SocketImpl.java \
 java/net/SocketImplFactory.java        \
 java/net/URL.java \
 java/net/URLConnection.java \
+java/net/URLDecoder.java \
+java/net/URLEncoder.java \
 java/net/URLStreamHandler.java \
 java/net/URLStreamHandlerFactory.java \
 java/net/UnknownHostException.java \
@@ -691,7 +693,8 @@ DEP_FILES =  .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
 .deps/java/net/ServerSocket.P .deps/java/net/Socket.P \
 .deps/java/net/SocketException.P .deps/java/net/SocketImpl.P \
 .deps/java/net/SocketImplFactory.P .deps/java/net/URL.P \
-.deps/java/net/URLConnection.P .deps/java/net/URLStreamHandler.P \
+.deps/java/net/URLConnection.P .deps/java/net/URLDecoder.P \
+.deps/java/net/URLEncoder.P .deps/java/net/URLStreamHandler.P \
 .deps/java/net/URLStreamHandlerFactory.P \
 .deps/java/net/UnknownHostException.P \
 .deps/java/net/UnknownServiceException.P \
index e4b50693e750745a252ef4ab0a8691e37545cabf..4dcd9d60346fd9737068bde9b97fd49721816c64 100644 (file)
@@ -96,7 +96,7 @@ public class ServerSocket
     return impl.toString();
   }
 
-  public static void setSocketImplFactory (SocketImplFactory fac)
+  public static void setSocketFactory (SocketImplFactory fac)
     throws IOException
   {
     factory = fac;
index 8c027d9f88fe3cdf44c5d4534a5705d078714afb..8446b22989e1f17b7f805ab79155cb38e1c2f083 100644 (file)
@@ -156,7 +156,7 @@ public class Socket
     throw new InternalError("Socket.setSoLinger not implemented");
   }
 
-  public boolean getSoLinger() throws SocketException
+  public int getSoLinger() throws SocketException
   {
     throw new InternalError("Socket.getSoLinger not implemented");
   }
diff --git a/libjava/java/net/URLDecoder.java b/libjava/java/net/URLDecoder.java
new file mode 100644 (file)
index 0000000..40d47b7
--- /dev/null
@@ -0,0 +1,48 @@
+// URLDecoder.java - Provides a method for decoding strings according to
+//                  application/x-www-form-urlencoded MIME type.
+
+/* Copyright (C) 1999  Cygnus Solutions
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+package java.net;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date April 22, 1999.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification.
+ * Status:  Believed complete and correct.
+ */
+
+// JDK1.2
+public class URLDecoder
+{
+  // This method, per the JCL, is conservative in that it encodes
+  // some "allowable" characters as % triplets.
+  public static String decode(String s) throws Exception
+  {
+    String str = s.replace('+', ' ');
+    String result = "";
+    int i;
+    int start = 0;
+    while ((i = str.indexOf('%', start)) >= 0)
+      {
+       result = result + str.substring(start, i) +
+                (char) Integer.parseInt(str.substring(i + 1, i + 3), 16);
+       start = i + 3;
+      }
+
+    if (start < str.length())
+      result = result + str.substring(start);
+
+    return result;
+  }
+}
diff --git a/libjava/java/net/URLEncoder.java b/libjava/java/net/URLEncoder.java
new file mode 100644 (file)
index 0000000..83295ea
--- /dev/null
@@ -0,0 +1,71 @@
+// URLEncoder.java - Provides a method for encoding strings according to
+//                  application/x-www-form-urlencoded MIME type.
+
+/* Copyright (C) 1999  Cygnus Solutions
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+package java.net;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @author Warren Levy <warrenl@cygnus.com>
+ * @date April 22, 1999.
+ */
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status:  Believed complete and correct.
+ */
+
+public class URLEncoder
+{
+  // This method, per the JCL, is conservative in that it encodes
+  // some "allowable" characters as % triplets.
+  public static String encode(String s)
+  {
+    // Get the bytes in ISO-Latin-1 (i.e. 8859_1) per the JCL.
+    // Even though it is the default in most cases, it's specified here
+    // just in case System.getProperty("file.encoding") is not "8859_1".
+    String result = "";
+    try
+      {
+       byte[] buf = s.getBytes("8859_1");
+       int start = 0;
+       for (int i = 0; i < buf.length; i++)
+         // For efficiency, check the byte in order of most likely
+         // possibility so as to minimize the number of comparisons.
+         // Hence, exclude all the alphanumeric & allowed special chars first.
+         if ((buf[i] >= 'a' && buf[i] <= 'z') ||
+             (buf[i] >= 'A' && buf[i] <= 'Z') ||
+             (buf[i] >= '0' && buf[i] <= '9') ||
+             buf[i] == '-' || buf[i] == '_' || buf[i] == '.' || buf[i] == '*')
+           ; // This is the most likely case so exclude first for efficiency.
+         else if (buf[i] == ' ')
+           buf[i] = (byte) '+';  // Replace space char with plus symbol.
+         else
+           {
+             result = result + new String(buf, start, i - start, "8859_1") +
+                       "%" + Integer.toHexString(((int) buf[i]) & 0xFF);
+             start = i + 1;
+           }
+
+       // Append remainder of allowable chars from the string, if any.
+       if (start < buf.length)
+         result = result +
+                  new String(buf, start, buf.length - start, "8859_1");
+      }
+    catch (UnsupportedEncodingException ex)
+      {
+       // This should never happen as "8859_1" is the default encoding.
+       return s;
+      }
+
+    return result;
+  }
+}
index 15dfa297e6a008590f36d524e9701eb188e0e8a3..764c148a3cad4ad558a63d10dc34211600b962c2 100644 (file)
@@ -96,10 +96,14 @@ libgcj_basedir = @libgcj_basedir@
 AUTOMAKE_OPTIONS = foreign dejagnu no-installinfo
 
 # Setup the testing framework, if you have one
-EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then             echo $(top_builddir)/../expect/expect ;           else echo expect ; fi`
+EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then \
+            echo $(top_builddir)/../expect/expect ; \
+          else echo expect ; fi`
 
 
-RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then          echo $(top_srcdir)/../dejagnu/runtest ;      else echo runtest; fi`
+RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
+              echo $(top_srcdir)/../dejagnu/runtest ; \
+           else echo runtest; fi`
 
 
 RUNTESTFLAGS = @AM_RUNTESTFLAGS@