Skip to content

Commit

Permalink
Add CAM
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvoronov committed Mar 20, 2015
1 parent 1279c45 commit 984fcf6
Show file tree
Hide file tree
Showing 27 changed files with 2,651 additions and 11 deletions.
9 changes: 9 additions & 0 deletions src/main/java/net/gcdc/camdenm/Asn1AnonymousType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.gcdc.camdenm;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@Target({ElementType.TYPE})
public @interface Asn1AnonymousType {

}
19 changes: 19 additions & 0 deletions src/main/java/net/gcdc/camdenm/Asn1Integer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.gcdc.camdenm;

public abstract class Asn1Integer {
@Override public String toString() {
return "" + value;
}

public long value;

public long value() { return value; }

public Asn1Integer() {}

public Asn1Integer(long value) {
this.value = value;
}


}
20 changes: 20 additions & 0 deletions src/main/java/net/gcdc/camdenm/Asn1Optional.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.gcdc.camdenm;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Indicates that the field is OPTIONAL in ASN.1. Implemented as null. Equivalent to @Nullable.
*
* Using Optional<T> would require Manifests to capture generics (like in Gson).
*
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Asn1Optional {

}
27 changes: 27 additions & 0 deletions src/main/java/net/gcdc/camdenm/Asn1SequenceOf.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.gcdc.camdenm;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class Asn1SequenceOf<T> extends AbstractList<T> {

private final List<T> bakingList;

@Override public T get(int index) {
return bakingList.get(index);
}

@Override public int size() {
return bakingList.size();
}

public Asn1SequenceOf() {
bakingList = new ArrayList<>();
}

public Asn1SequenceOf(Collection<T> coll) {
bakingList = new ArrayList<>(coll);
}
}
36 changes: 36 additions & 0 deletions src/main/java/net/gcdc/camdenm/Asn1VarSizeBitstring.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.gcdc.camdenm;

import java.util.AbstractList;
import java.util.BitSet;
import java.util.Collection;

public class Asn1VarSizeBitstring extends AbstractList<Boolean> {

private final BitSet backing;

@Override public Boolean get(int index) {
return backing.get(index);
}

@Override public int size() {
return backing.length();
}

public Asn1VarSizeBitstring(Collection<Boolean> coll) {
backing = new BitSet();
int bitIndex = 0;
for (Boolean b : coll) {
backing.set(bitIndex, b);
bitIndex++;
}
}

protected void setBit(int bitIndex, boolean value) {
backing.set(bitIndex, value);
}

public boolean getBit(int bitIndex) {
return backing.get(bitIndex);
}

}
12 changes: 12 additions & 0 deletions src/main/java/net/gcdc/camdenm/Bitstring.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.gcdc.camdenm;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Bitstring {

}
12 changes: 12 additions & 0 deletions src/main/java/net/gcdc/camdenm/Choice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.gcdc.camdenm;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Choice {

}
Loading

0 comments on commit 984fcf6

Please sign in to comment.