summaryrefslogtreecommitdiff
path: root/gnu/javax/net/ssl/provider/CompressionMethod.java
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/javax/net/ssl/provider/CompressionMethod.java')
-rw-r--r--gnu/javax/net/ssl/provider/CompressionMethod.java51
1 files changed, 8 insertions, 43 deletions
diff --git a/gnu/javax/net/ssl/provider/CompressionMethod.java b/gnu/javax/net/ssl/provider/CompressionMethod.java
index c2fdf05f9..6c57e840c 100644
--- a/gnu/javax/net/ssl/provider/CompressionMethod.java
+++ b/gnu/javax/net/ssl/provider/CompressionMethod.java
@@ -1,4 +1,4 @@
-/* CompressionMethod.java -- the compression method enum.
+/* CompressionMethod.java -- The CompressionMethod enum.
Copyright (C) 2006 Free Software Foundation, Inc.
This file is a part of GNU Classpath.
@@ -38,67 +38,32 @@ exception statement from your version. */
package gnu.javax.net.ssl.provider;
-import java.io.EOFException;
-import java.io.InputStream;
-import java.io.IOException;
-
-final class CompressionMethod implements Enumerated
+public enum CompressionMethod
{
-
- // Constants and fields.
- // -------------------------------------------------------------------------
-
- static final CompressionMethod NULL = new CompressionMethod(0),
- ZLIB = new CompressionMethod(1);
+ NULL (0), ZLIB(1);
private final int value;
- // Constructor.
- // -------------------------------------------------------------------------
-
private CompressionMethod(int value)
{
this.value = value;
}
- // Class method.
- // -------------------------------------------------------------------------
-
- static CompressionMethod read(InputStream in) throws IOException
+ public static CompressionMethod getInstance (final int value)
{
- int value = in.read();
- if (value == -1)
- {
- throw new EOFException("unexpected end of input stream");
- }
switch (value & 0xFF)
{
case 0: return NULL;
case 1: return ZLIB;
- default: return new CompressionMethod(value);
+
+ // Note: we can't throw an exception here, because we get these values
+ // over the wire, and need to just ignore ones we don't recognize.
+ default: return null;
}
}
- // Instance methods.
- // -------------------------------------------------------------------------
-
- public byte[] getEncoded()
- {
- return new byte[] { (byte) value };
- }
-
public int getValue()
{
return value;
}
-
- public String toString()
- {
- switch (value)
- {
- case 0: return "null";
- case 1: return "zlib";
- default: return "unknown(" + value + ")";
- }
- }
}