/**
|
* This class file was automatically generated by jASN1 v1.9.0 (http://www.openmuc.org)
|
*/
|
|
package org.openmuc.openiec61850.internal.mms.asn1;
|
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.io.OutputStream;
|
import java.io.Serializable;
|
import java.util.ArrayList;
|
import java.util.Iterator;
|
import java.util.List;
|
|
import org.openmuc.jasn1.ber.BerLength;
|
import org.openmuc.jasn1.ber.BerTag;
|
import org.openmuc.jasn1.ber.ReverseByteArrayOutputStream;
|
import org.openmuc.jasn1.ber.types.BerBitString;
|
import org.openmuc.jasn1.ber.types.BerBoolean;
|
import org.openmuc.jasn1.ber.types.BerInteger;
|
import org.openmuc.jasn1.ber.types.BerOctetString;
|
import org.openmuc.jasn1.ber.types.string.BerVisibleString;
|
|
public class Data implements Serializable {
|
|
private static final long serialVersionUID = 1L;
|
|
public byte[] code = null;
|
|
public static class Array implements Serializable {
|
|
private static final long serialVersionUID = 1L;
|
|
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
|
public byte[] code = null;
|
private List<Data> seqOf = null;
|
|
public Array() {
|
seqOf = new ArrayList<>();
|
}
|
|
public Array(byte[] code) {
|
this.code = code;
|
}
|
|
public List<Data> getData() {
|
if (seqOf == null) {
|
seqOf = new ArrayList<>();
|
}
|
return seqOf;
|
}
|
|
public int encode(OutputStream os) throws IOException {
|
return encode(os, true);
|
}
|
|
public int encode(OutputStream os, boolean withTag) throws IOException {
|
|
if (code != null) {
|
for (int i = code.length - 1; i >= 0; i--) {
|
os.write(code[i]);
|
}
|
if (withTag) {
|
return tag.encode(os) + code.length;
|
}
|
return code.length;
|
}
|
|
int codeLength = 0;
|
for (int i = (seqOf.size() - 1); i >= 0; i--) {
|
codeLength += seqOf.get(i).encode(os);
|
}
|
|
codeLength += BerLength.encodeLength(os, codeLength);
|
|
if (withTag) {
|
codeLength += tag.encode(os);
|
}
|
|
return codeLength;
|
}
|
|
public int decode(InputStream is) throws IOException {
|
return decode(is, true);
|
}
|
|
public int decode(InputStream is, boolean withTag) throws IOException {
|
int codeLength = 0;
|
int subCodeLength = 0;
|
if (withTag) {
|
codeLength += tag.decodeAndCheck(is);
|
}
|
|
BerLength length = new BerLength();
|
codeLength += length.decode(is);
|
int totalLength = length.val;
|
|
while (subCodeLength < totalLength) {
|
Data element = new Data();
|
subCodeLength += element.decode(is, null);
|
seqOf.add(element);
|
}
|
if (subCodeLength != totalLength) {
|
throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength
|
+ " but has " + subCodeLength);
|
|
}
|
codeLength += subCodeLength;
|
|
return codeLength;
|
}
|
|
public void encodeAndSave(int encodingSizeGuess) throws IOException {
|
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(encodingSizeGuess);
|
encode(os, false);
|
code = os.getArray();
|
}
|
|
@Override
|
public String toString() {
|
StringBuilder sb = new StringBuilder();
|
appendAsString(sb, 0);
|
return sb.toString();
|
}
|
|
public void appendAsString(StringBuilder sb, int indentLevel) {
|
|
sb.append("{\n");
|
for (int i = 0; i < indentLevel + 1; i++) {
|
sb.append("\t");
|
}
|
if (seqOf == null) {
|
sb.append("null");
|
}
|
else {
|
Iterator<Data> it = seqOf.iterator();
|
if (it.hasNext()) {
|
it.next().appendAsString(sb, indentLevel + 1);
|
while (it.hasNext()) {
|
sb.append(",\n");
|
for (int i = 0; i < indentLevel + 1; i++) {
|
sb.append("\t");
|
}
|
it.next().appendAsString(sb, indentLevel + 1);
|
}
|
}
|
}
|
|
sb.append("\n");
|
for (int i = 0; i < indentLevel; i++) {
|
sb.append("\t");
|
}
|
sb.append("}");
|
}
|
|
}
|
|
public static class Structure implements Serializable {
|
|
private static final long serialVersionUID = 1L;
|
|
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
|
public byte[] code = null;
|
private List<Data> seqOf = null;
|
|
public Structure() {
|
seqOf = new ArrayList<>();
|
}
|
|
public Structure(byte[] code) {
|
this.code = code;
|
}
|
|
public List<Data> getData() {
|
if (seqOf == null) {
|
seqOf = new ArrayList<>();
|
}
|
return seqOf;
|
}
|
|
public int encode(OutputStream os) throws IOException {
|
return encode(os, true);
|
}
|
|
public int encode(OutputStream os, boolean withTag) throws IOException {
|
|
if (code != null) {
|
for (int i = code.length - 1; i >= 0; i--) {
|
os.write(code[i]);
|
}
|
if (withTag) {
|
return tag.encode(os) + code.length;
|
}
|
return code.length;
|
}
|
|
int codeLength = 0;
|
for (int i = (seqOf.size() - 1); i >= 0; i--) {
|
codeLength += seqOf.get(i).encode(os);
|
}
|
|
codeLength += BerLength.encodeLength(os, codeLength);
|
|
if (withTag) {
|
codeLength += tag.encode(os);
|
}
|
|
return codeLength;
|
}
|
|
public int decode(InputStream is) throws IOException {
|
return decode(is, true);
|
}
|
|
public int decode(InputStream is, boolean withTag) throws IOException {
|
int codeLength = 0;
|
int subCodeLength = 0;
|
if (withTag) {
|
codeLength += tag.decodeAndCheck(is);
|
}
|
|
BerLength length = new BerLength();
|
codeLength += length.decode(is);
|
int totalLength = length.val;
|
|
while (subCodeLength < totalLength) {
|
Data element = new Data();
|
subCodeLength += element.decode(is, null);
|
seqOf.add(element);
|
}
|
if (subCodeLength != totalLength) {
|
throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength
|
+ " but has " + subCodeLength);
|
|
}
|
codeLength += subCodeLength;
|
|
return codeLength;
|
}
|
|
public void encodeAndSave(int encodingSizeGuess) throws IOException {
|
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(encodingSizeGuess);
|
encode(os, false);
|
code = os.getArray();
|
}
|
|
@Override
|
public String toString() {
|
StringBuilder sb = new StringBuilder();
|
appendAsString(sb, 0);
|
return sb.toString();
|
}
|
|
public void appendAsString(StringBuilder sb, int indentLevel) {
|
|
sb.append("{\n");
|
for (int i = 0; i < indentLevel + 1; i++) {
|
sb.append("\t");
|
}
|
if (seqOf == null) {
|
sb.append("null");
|
}
|
else {
|
Iterator<Data> it = seqOf.iterator();
|
if (it.hasNext()) {
|
it.next().appendAsString(sb, indentLevel + 1);
|
while (it.hasNext()) {
|
sb.append(",\n");
|
for (int i = 0; i < indentLevel + 1; i++) {
|
sb.append("\t");
|
}
|
it.next().appendAsString(sb, indentLevel + 1);
|
}
|
}
|
}
|
|
sb.append("\n");
|
for (int i = 0; i < indentLevel; i++) {
|
sb.append("\t");
|
}
|
sb.append("}");
|
}
|
|
}
|
|
private Array array = null;
|
private Structure structure = null;
|
private BerBoolean bool = null;
|
private BerBitString bitString = null;
|
private BerInteger integer = null;
|
private BerInteger unsigned = null;
|
private FloatingPoint floatingPoint = null;
|
private BerOctetString octetString = null;
|
private BerVisibleString visibleString = null;
|
private TimeOfDay binaryTime = null;
|
private MMSString mMSString = null;
|
private UtcTime utcTime = null;
|
|
public Data() {
|
}
|
|
public Data(byte[] code) {
|
this.code = code;
|
}
|
|
public void setArray(Array array) {
|
this.array = array;
|
}
|
|
public Array getArray() {
|
return array;
|
}
|
|
public void setStructure(Structure structure) {
|
this.structure = structure;
|
}
|
|
public Structure getStructure() {
|
return structure;
|
}
|
|
public void setBool(BerBoolean bool) {
|
this.bool = bool;
|
}
|
|
public BerBoolean getBool() {
|
return bool;
|
}
|
|
public void setBitString(BerBitString bitString) {
|
this.bitString = bitString;
|
}
|
|
public BerBitString getBitString() {
|
return bitString;
|
}
|
|
public void setInteger(BerInteger integer) {
|
this.integer = integer;
|
}
|
|
public BerInteger getInteger() {
|
return integer;
|
}
|
|
public void setUnsigned(BerInteger unsigned) {
|
this.unsigned = unsigned;
|
}
|
|
public BerInteger getUnsigned() {
|
return unsigned;
|
}
|
|
public void setFloatingPoint(FloatingPoint floatingPoint) {
|
this.floatingPoint = floatingPoint;
|
}
|
|
public FloatingPoint getFloatingPoint() {
|
return floatingPoint;
|
}
|
|
public void setOctetString(BerOctetString octetString) {
|
this.octetString = octetString;
|
}
|
|
public BerOctetString getOctetString() {
|
return octetString;
|
}
|
|
public void setVisibleString(BerVisibleString visibleString) {
|
this.visibleString = visibleString;
|
}
|
|
public BerVisibleString getVisibleString() {
|
return visibleString;
|
}
|
|
public void setBinaryTime(TimeOfDay binaryTime) {
|
this.binaryTime = binaryTime;
|
}
|
|
public TimeOfDay getBinaryTime() {
|
return binaryTime;
|
}
|
|
public void setMMSString(MMSString mMSString) {
|
this.mMSString = mMSString;
|
}
|
|
public MMSString getMMSString() {
|
return mMSString;
|
}
|
|
public void setUtcTime(UtcTime utcTime) {
|
this.utcTime = utcTime;
|
}
|
|
public UtcTime getUtcTime() {
|
return utcTime;
|
}
|
|
public int encode(OutputStream os) throws IOException {
|
|
if (code != null) {
|
for (int i = code.length - 1; i >= 0; i--) {
|
os.write(code[i]);
|
}
|
return code.length;
|
}
|
|
int codeLength = 0;
|
if (utcTime != null) {
|
codeLength += utcTime.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 17
|
os.write(0x91);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (mMSString != null) {
|
codeLength += mMSString.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 16
|
os.write(0x90);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (binaryTime != null) {
|
codeLength += binaryTime.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 12
|
os.write(0x8C);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (visibleString != null) {
|
codeLength += visibleString.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 10
|
os.write(0x8A);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (octetString != null) {
|
codeLength += octetString.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 9
|
os.write(0x89);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (floatingPoint != null) {
|
codeLength += floatingPoint.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 7
|
os.write(0x87);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (unsigned != null) {
|
codeLength += unsigned.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 6
|
os.write(0x86);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (integer != null) {
|
codeLength += integer.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 5
|
os.write(0x85);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (bitString != null) {
|
codeLength += bitString.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 4
|
os.write(0x84);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (bool != null) {
|
codeLength += bool.encode(os, false);
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 3
|
os.write(0x83);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (structure != null) {
|
codeLength += structure.encode(os, false);
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
|
os.write(0xA2);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
if (array != null) {
|
codeLength += array.encode(os, false);
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
|
os.write(0xA1);
|
codeLength += 1;
|
return codeLength;
|
}
|
|
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
|
}
|
|
public int decode(InputStream is) throws IOException {
|
return decode(is, null);
|
}
|
|
public int decode(InputStream is, BerTag berTag) throws IOException {
|
|
int codeLength = 0;
|
BerTag passedTag = berTag;
|
|
if (berTag == null) {
|
berTag = new BerTag();
|
codeLength += berTag.decode(is);
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
|
array = new Array();
|
codeLength += array.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
|
structure = new Structure();
|
codeLength += structure.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
|
bool = new BerBoolean();
|
codeLength += bool.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
|
bitString = new BerBitString();
|
codeLength += bitString.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 5)) {
|
integer = new BerInteger();
|
codeLength += integer.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
|
unsigned = new BerInteger();
|
codeLength += unsigned.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
|
floatingPoint = new FloatingPoint();
|
codeLength += floatingPoint.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
|
octetString = new BerOctetString();
|
codeLength += octetString.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) {
|
visibleString = new BerVisibleString();
|
codeLength += visibleString.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 12)) {
|
binaryTime = new TimeOfDay();
|
codeLength += binaryTime.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 16)) {
|
mMSString = new MMSString();
|
codeLength += mMSString.decode(is, false);
|
return codeLength;
|
}
|
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 17)) {
|
utcTime = new UtcTime();
|
codeLength += utcTime.decode(is, false);
|
return codeLength;
|
}
|
|
if (passedTag != null) {
|
return 0;
|
}
|
|
throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item.");
|
}
|
|
public void encodeAndSave(int encodingSizeGuess) throws IOException {
|
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(encodingSizeGuess);
|
encode(os);
|
code = os.getArray();
|
}
|
|
@Override
|
public String toString() {
|
StringBuilder sb = new StringBuilder();
|
appendAsString(sb, 0);
|
return sb.toString();
|
}
|
|
public void appendAsString(StringBuilder sb, int indentLevel) {
|
|
if (array != null) {
|
sb.append("array: ");
|
array.appendAsString(sb, indentLevel + 1);
|
return;
|
}
|
|
if (structure != null) {
|
sb.append("structure: ");
|
structure.appendAsString(sb, indentLevel + 1);
|
return;
|
}
|
|
if (bool != null) {
|
sb.append("bool: ").append(bool);
|
return;
|
}
|
|
if (bitString != null) {
|
sb.append("bitString: ").append(bitString);
|
return;
|
}
|
|
if (integer != null) {
|
sb.append("integer: ").append(integer);
|
return;
|
}
|
|
if (unsigned != null) {
|
sb.append("unsigned: ").append(unsigned);
|
return;
|
}
|
|
if (floatingPoint != null) {
|
sb.append("floatingPoint: ").append(floatingPoint);
|
return;
|
}
|
|
if (octetString != null) {
|
sb.append("octetString: ").append(octetString);
|
return;
|
}
|
|
if (visibleString != null) {
|
sb.append("visibleString: ").append(visibleString);
|
return;
|
}
|
|
if (binaryTime != null) {
|
sb.append("binaryTime: ").append(binaryTime);
|
return;
|
}
|
|
if (mMSString != null) {
|
sb.append("mMSString: ").append(mMSString);
|
return;
|
}
|
|
if (utcTime != null) {
|
sb.append("utcTime: ").append(utcTime);
|
return;
|
}
|
|
sb.append("<none>");
|
}
|
|
}
|