From df426d8775737476ca79980ddc5a1b197f53207e Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 06 Feb 2009 11:45:32 +0000
Subject: [PATCH] Add readStartSet and readEndSet methods to ASN1Reader for consistency with ASNWriter APIs. Also add writeStartSet(byte) method to ASN1Writer for consistency with sequence related methods.
---
opends/src/server/org/opends/server/protocols/asn1/ASN1Reader.java | 24 +++++++++++
opends/src/server/org/opends/server/protocols/asn1/ASN1Writer.java | 17 ++++++++
opends/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReader.java | 20 ++++++++++
opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelWriter.java | 8 ++++
opends/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReader.java | 20 ++++++++++
opends/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriter.java | 12 +++++
opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java | 16 +++++++
7 files changed, 113 insertions(+), 4 deletions(-)
diff --git a/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java b/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java
index 93a55fe..2a3fd34 100644
--- a/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java
+++ b/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelReader.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.protocols.asn1;
@@ -392,6 +392,13 @@
/**
* {@inheritDoc}
*/
+ public void readEndSet() throws ASN1Exception {
+ reader.readEndSet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public long readInteger() throws ASN1Exception {
return reader.readInteger();
}
@@ -441,6 +448,13 @@
/**
* {@inheritDoc}
*/
+ public void readStartSet() throws ASN1Exception {
+ reader.readStartSet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void close() throws IOException {
reader.close();
byteChannel.close();
diff --git a/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelWriter.java b/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelWriter.java
index 9dfe189..b6f7f9d 100644
--- a/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelWriter.java
+++ b/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteChannelWriter.java
@@ -289,6 +289,14 @@
}
/**
+ * {@inheritDoc}
+ */
+ public ASN1Writer writeStartSet(byte type) throws IOException {
+ writer.writeStartSet(type);
+ return this;
+ }
+
+ /**
* Flush the entire contents of the NIO ByteBuffer out to the
* channel.
*
diff --git a/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReader.java b/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReader.java
index 13d72df..c05f092 100644
--- a/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReader.java
+++ b/opends/src/server/org/opends/server/protocols/asn1/ASN1ByteSequenceReader.java
@@ -436,6 +436,16 @@
/**
* {@inheritDoc}
*/
+ public void readStartSet() throws ASN1Exception
+ {
+ // From an implementation point of view, a set is equivalent to a
+ // sequence.
+ readStartSequence();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void readEndSequence() throws ASN1Exception
{
if(readerStack.isEmpty())
@@ -460,6 +470,16 @@
/**
* {@inheritDoc}
*/
+ public void readEndSet() throws ASN1Exception
+ {
+ // From an implementation point of view, a set is equivalent to a
+ // sequence.
+ readEndSequence();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void skipElement() throws ASN1Exception
{
// Read the header if haven't done so already
diff --git a/opends/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReader.java b/opends/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReader.java
index 7124abb..94a6f9e 100644
--- a/opends/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReader.java
+++ b/opends/src/server/org/opends/server/protocols/asn1/ASN1InputStreamReader.java
@@ -728,6 +728,16 @@
/**
* {@inheritDoc}
*/
+ public void readStartSet() throws ASN1Exception
+ {
+ // From an implementation point of view, a set is equivalent to a
+ // sequence.
+ readStartSequence();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void readEndSequence() throws ASN1Exception
{
if(streamStack.isEmpty())
@@ -755,6 +765,16 @@
/**
* {@inheritDoc}
*/
+ public void readEndSet() throws ASN1Exception
+ {
+ // From an implementation point of view, a set is equivalent to a
+ // sequence.
+ readEndSequence();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void skipElement() throws ASN1Exception
{
// Read the header if haven't done so already
diff --git a/opends/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriter.java b/opends/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriter.java
index 1466696..b85166e 100644
--- a/opends/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriter.java
+++ b/opends/src/server/org/opends/server/protocols/asn1/ASN1OutputStreamWriter.java
@@ -435,7 +435,17 @@
*/
public ASN1Writer writeStartSet() throws IOException
{
- return writeStartSequence(UNIVERSAL_SET_TYPE);
+ return writeStartSet(UNIVERSAL_SET_TYPE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ASN1Writer writeStartSet(byte type) throws IOException
+ {
+ // From an implementation point of view, a set is equivalent to a
+ // sequence.
+ return writeStartSequence(type);
}
/**
diff --git a/opends/src/server/org/opends/server/protocols/asn1/ASN1Reader.java b/opends/src/server/org/opends/server/protocols/asn1/ASN1Reader.java
index b67a5f5..95ddae8 100644
--- a/opends/src/server/org/opends/server/protocols/asn1/ASN1Reader.java
+++ b/opends/src/server/org/opends/server/protocols/asn1/ASN1Reader.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.protocols.asn1;
@@ -128,6 +128,17 @@
/**
+ * Finishes reading a set. Any elements not read in the set will be
+ * discarded.
+ *
+ * @throws ASN1Exception
+ * If an error occurs while advancing to the end of the set.
+ */
+ void readEndSet() throws ASN1Exception;
+
+
+
+ /**
* Reads the next ASN.1 element as an integer and advances the
* cursor.
*
@@ -223,6 +234,17 @@
/**
+ * Reads the next ASN.1 element as a set. All further reads will read
+ * the elements in the sequence until {@link #readEndSet()} is called.
+ *
+ * @throws ASN1Exception
+ * If the next element is not a set.
+ */
+ void readStartSet() throws ASN1Exception;
+
+
+
+ /**
* Advances this ASN.1 reader beyond the next ASN.1 element without
* decoding it.
*
diff --git a/opends/src/server/org/opends/server/protocols/asn1/ASN1Writer.java b/opends/src/server/org/opends/server/protocols/asn1/ASN1Writer.java
index 2e54c39..e038f56 100644
--- a/opends/src/server/org/opends/server/protocols/asn1/ASN1Writer.java
+++ b/opends/src/server/org/opends/server/protocols/asn1/ASN1Writer.java
@@ -335,7 +335,7 @@
/**
* Writes a sequence element using the provided type tag. All
- * further writes will be part of this set until
+ * further writes will be part of this sequence until
* {@link #writeEndSequence()} is called.
*
* @param type
@@ -358,4 +358,19 @@
* If an error occurs while writing.
*/
ASN1Writer writeStartSet() throws IOException;
+
+
+
+ /**
+ * Writes a set element using the provided type tag. All further
+ * writes will be part of this set until {@link #writeEndSet()} is
+ * called.
+ *
+ * @param type
+ * The type tag to use.
+ * @return a reference to this object.
+ * @throws IOException
+ * If an error occurs while writing.
+ */
+ ASN1Writer writeStartSet(byte type) throws IOException;
}
--
Gitblit v1.10.0