added some java doc
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Factory.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Factory.java
index 2762476..ea4eca8 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Factory.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Factory.java
@@ -23,8 +23,16 @@
import org.apache.kerby.asn1.type.Asn1Simple;
import org.apache.kerby.asn1.type.Asn1Type;
+/**
+ * ASN1 type factory
+ */
public class Asn1Factory {
+ /**
+ * Create an ASN1 type with specified tag number
+ * @param tagNo
+ * @return ASN1 type
+ */
public static Asn1Type create(int tagNo) {
UniversalTag tagNoEnum = UniversalTag.fromValue(tagNo);
if (tagNoEnum != UniversalTag.UNKNOWN) {
@@ -33,6 +41,11 @@
throw new IllegalArgumentException("Unexpected tag " + tagNo);
}
+ /**
+ * Create an ASN1 type with specified tag
+ * @param tagNo
+ * @return ASN1 type
+ */
public static Asn1Type create(UniversalTag tagNo) {
if (Asn1Simple.isSimple(tagNo)) {
return Asn1Simple.createSimple(tagNo);
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1InputBuffer.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1InputBuffer.java
index 934b0c1..985bd7e 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1InputBuffer.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1InputBuffer.java
@@ -27,23 +27,43 @@
import java.nio.ByteBuffer;
/**
- * Asn1 decoder
+ * Asn1 decoder. Given an input stream, it validates and parses
+ * according to ASN1 spec, and the resultant object can be read
+ * and read until exhausted.
*/
public class Asn1InputBuffer {
private final LimitedByteBuffer limitedBuffer;
+ /**
+ * Constructor with bytes.
+ * @param bytes
+ */
public Asn1InputBuffer(byte[] bytes) {
this(new LimitedByteBuffer(bytes));
}
+ /**
+ * Constructor with a ByteBuffer.
+ * @param byteBuffer
+ */
public Asn1InputBuffer(ByteBuffer byteBuffer) {
this(new LimitedByteBuffer(byteBuffer));
}
+ /**
+ * Constructor with LimitedByteBuffer.
+ * @param limitedByteBuffer
+ */
public Asn1InputBuffer(LimitedByteBuffer limitedByteBuffer) {
this.limitedBuffer = limitedByteBuffer;
}
+ /**
+ * Parse and read ASN1 object from the stream. If it's already
+ * exhausted then null will be returned to indicate the end.
+ * @return an ASN1 object if available otherwise null
+ * @throws IOException
+ */
public Asn1Type read() throws IOException {
if (! limitedBuffer.available()) {
return null;
@@ -60,6 +80,11 @@
return one;
}
+ /**
+ *
+ * @param bytes
+ * @throws IOException
+ */
public void readBytes(byte[] bytes) throws IOException {
limitedBuffer.readBytes(bytes);
}