- started to implement client side get file directory service
parent
c9d8278029
commit
bdb5db7aa0
@ -0,0 +1,180 @@
|
|||||||
|
/**
|
||||||
|
* This class file was automatically generated by jASN1 v1.9.1-SNAPSHOT (http://www.openmuc.org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openmuc.openiec61850.internal.mms.asn1;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import org.openmuc.jasn1.ber.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.string.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class DirectoryEntry 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 FileName fileName = null;
|
||||||
|
private FileAttributes fileAttributes = null;
|
||||||
|
|
||||||
|
public DirectoryEntry() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DirectoryEntry(byte[] code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileName(FileName fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileName getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileAttributes(FileAttributes fileAttributes) {
|
||||||
|
this.fileAttributes = fileAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileAttributes getFileAttributes() {
|
||||||
|
return fileAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
codeLength += fileAttributes.encode(os, false);
|
||||||
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
|
||||||
|
os.write(0xA1);
|
||||||
|
codeLength += 1;
|
||||||
|
|
||||||
|
codeLength += fileName.encode(os, false);
|
||||||
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
|
||||||
|
os.write(0xA0);
|
||||||
|
codeLength += 1;
|
||||||
|
|
||||||
|
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;
|
||||||
|
BerTag berTag = new BerTag();
|
||||||
|
|
||||||
|
if (withTag) {
|
||||||
|
codeLength += tag.decodeAndCheck(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
BerLength length = new BerLength();
|
||||||
|
codeLength += length.decode(is);
|
||||||
|
|
||||||
|
int totalLength = length.val;
|
||||||
|
codeLength += totalLength;
|
||||||
|
|
||||||
|
subCodeLength += berTag.decode(is);
|
||||||
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
|
||||||
|
fileName = new FileName();
|
||||||
|
subCodeLength += fileName.decode(is, false);
|
||||||
|
subCodeLength += berTag.decode(is);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IOException("Tag does not match the mandatory sequence element tag.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
|
||||||
|
fileAttributes = new FileAttributes();
|
||||||
|
subCodeLength += fileAttributes.decode(is, false);
|
||||||
|
if (subCodeLength == totalLength) {
|
||||||
|
return codeLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void encodeAndSave(int encodingSizeGuess) throws IOException {
|
||||||
|
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(encodingSizeGuess);
|
||||||
|
encode(os, false);
|
||||||
|
code = os.getArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
appendAsString(sb, 0);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void appendAsString(StringBuilder sb, int indentLevel) {
|
||||||
|
|
||||||
|
sb.append("{");
|
||||||
|
sb.append("\n");
|
||||||
|
for (int i = 0; i < indentLevel + 1; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
if (fileName != null) {
|
||||||
|
sb.append("fileName: ");
|
||||||
|
fileName.appendAsString(sb, indentLevel + 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sb.append("fileName: <empty-required-field>");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append(",\n");
|
||||||
|
for (int i = 0; i < indentLevel + 1; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
if (fileAttributes != null) {
|
||||||
|
sb.append("fileAttributes: ");
|
||||||
|
fileAttributes.appendAsString(sb, indentLevel + 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sb.append("fileAttributes: <empty-required-field>");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("\n");
|
||||||
|
for (int i = 0; i < indentLevel; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append("}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,180 @@
|
|||||||
|
/**
|
||||||
|
* This class file was automatically generated by jASN1 v1.9.1-SNAPSHOT (http://www.openmuc.org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openmuc.openiec61850.internal.mms.asn1;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import org.openmuc.jasn1.ber.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.string.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class FileAttributes 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 Unsigned32 sizeOfFile = null;
|
||||||
|
private BerGeneralizedTime lastModified = null;
|
||||||
|
|
||||||
|
public FileAttributes() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileAttributes(byte[] code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSizeOfFile(Unsigned32 sizeOfFile) {
|
||||||
|
this.sizeOfFile = sizeOfFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Unsigned32 getSizeOfFile() {
|
||||||
|
return sizeOfFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastModified(BerGeneralizedTime lastModified) {
|
||||||
|
this.lastModified = lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BerGeneralizedTime getLastModified() {
|
||||||
|
return lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (lastModified != null) {
|
||||||
|
codeLength += lastModified.encode(os, false);
|
||||||
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 1
|
||||||
|
os.write(0x81);
|
||||||
|
codeLength += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
codeLength += sizeOfFile.encode(os, false);
|
||||||
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 0
|
||||||
|
os.write(0x80);
|
||||||
|
codeLength += 1;
|
||||||
|
|
||||||
|
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;
|
||||||
|
BerTag berTag = new BerTag();
|
||||||
|
|
||||||
|
if (withTag) {
|
||||||
|
codeLength += tag.decodeAndCheck(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
BerLength length = new BerLength();
|
||||||
|
codeLength += length.decode(is);
|
||||||
|
|
||||||
|
int totalLength = length.val;
|
||||||
|
codeLength += totalLength;
|
||||||
|
|
||||||
|
subCodeLength += berTag.decode(is);
|
||||||
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
|
||||||
|
sizeOfFile = new Unsigned32();
|
||||||
|
subCodeLength += sizeOfFile.decode(is, false);
|
||||||
|
if (subCodeLength == totalLength) {
|
||||||
|
return codeLength;
|
||||||
|
}
|
||||||
|
subCodeLength += berTag.decode(is);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IOException("Tag does not match the mandatory sequence element tag.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
|
||||||
|
lastModified = new BerGeneralizedTime();
|
||||||
|
subCodeLength += lastModified.decode(is, false);
|
||||||
|
if (subCodeLength == totalLength) {
|
||||||
|
return codeLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void encodeAndSave(int encodingSizeGuess) throws IOException {
|
||||||
|
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(encodingSizeGuess);
|
||||||
|
encode(os, false);
|
||||||
|
code = os.getArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
appendAsString(sb, 0);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void appendAsString(StringBuilder sb, int indentLevel) {
|
||||||
|
|
||||||
|
sb.append("{");
|
||||||
|
sb.append("\n");
|
||||||
|
for (int i = 0; i < indentLevel + 1; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
if (sizeOfFile != null) {
|
||||||
|
sb.append("sizeOfFile: ").append(sizeOfFile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sb.append("sizeOfFile: <empty-required-field>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastModified != null) {
|
||||||
|
sb.append(",\n");
|
||||||
|
for (int i = 0; i < indentLevel + 1; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append("lastModified: ").append(lastModified);
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("\n");
|
||||||
|
for (int i = 0; i < indentLevel; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append("}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,186 @@
|
|||||||
|
/**
|
||||||
|
* This class file was automatically generated by jASN1 v1.9.1-SNAPSHOT (http://www.openmuc.org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openmuc.openiec61850.internal.mms.asn1;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import org.openmuc.jasn1.ber.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.string.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class FileDirectoryRequest 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 FileName fileSpecification = null;
|
||||||
|
private FileName continueAfter = null;
|
||||||
|
|
||||||
|
public FileDirectoryRequest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileDirectoryRequest(byte[] code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileSpecification(FileName fileSpecification) {
|
||||||
|
this.fileSpecification = fileSpecification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileName getFileSpecification() {
|
||||||
|
return fileSpecification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContinueAfter(FileName continueAfter) {
|
||||||
|
this.continueAfter = continueAfter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileName getContinueAfter() {
|
||||||
|
return continueAfter;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (continueAfter != null) {
|
||||||
|
codeLength += continueAfter.encode(os, false);
|
||||||
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
|
||||||
|
os.write(0xA1);
|
||||||
|
codeLength += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileSpecification != null) {
|
||||||
|
codeLength += fileSpecification.encode(os, false);
|
||||||
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
|
||||||
|
os.write(0xA0);
|
||||||
|
codeLength += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
BerTag berTag = new BerTag();
|
||||||
|
|
||||||
|
if (withTag) {
|
||||||
|
codeLength += tag.decodeAndCheck(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
BerLength length = new BerLength();
|
||||||
|
codeLength += length.decode(is);
|
||||||
|
|
||||||
|
int totalLength = length.val;
|
||||||
|
codeLength += totalLength;
|
||||||
|
|
||||||
|
if (totalLength == 0) {
|
||||||
|
return codeLength;
|
||||||
|
}
|
||||||
|
subCodeLength += berTag.decode(is);
|
||||||
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
|
||||||
|
fileSpecification = new FileName();
|
||||||
|
subCodeLength += fileSpecification.decode(is, false);
|
||||||
|
if (subCodeLength == totalLength) {
|
||||||
|
return codeLength;
|
||||||
|
}
|
||||||
|
subCodeLength += berTag.decode(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
|
||||||
|
continueAfter = new FileName();
|
||||||
|
subCodeLength += continueAfter.decode(is, false);
|
||||||
|
if (subCodeLength == totalLength) {
|
||||||
|
return codeLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void encodeAndSave(int encodingSizeGuess) throws IOException {
|
||||||
|
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(encodingSizeGuess);
|
||||||
|
encode(os, false);
|
||||||
|
code = os.getArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
appendAsString(sb, 0);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void appendAsString(StringBuilder sb, int indentLevel) {
|
||||||
|
|
||||||
|
sb.append("{");
|
||||||
|
boolean firstSelectedElement = true;
|
||||||
|
if (fileSpecification != null) {
|
||||||
|
sb.append("\n");
|
||||||
|
for (int i = 0; i < indentLevel + 1; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append("fileSpecification: ");
|
||||||
|
fileSpecification.appendAsString(sb, indentLevel + 1);
|
||||||
|
firstSelectedElement = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (continueAfter != null) {
|
||||||
|
if (!firstSelectedElement) {
|
||||||
|
sb.append(",\n");
|
||||||
|
}
|
||||||
|
for (int i = 0; i < indentLevel + 1; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append("continueAfter: ");
|
||||||
|
continueAfter.appendAsString(sb, indentLevel + 1);
|
||||||
|
firstSelectedElement = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("\n");
|
||||||
|
for (int i = 0; i < indentLevel; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append("}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,312 @@
|
|||||||
|
/**
|
||||||
|
* This class file was automatically generated by jASN1 v1.9.1-SNAPSHOT (http://www.openmuc.org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openmuc.openiec61850.internal.mms.asn1;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import org.openmuc.jasn1.ber.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.string.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class FileDirectoryResponse implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static class ListOfDirectoryEntry 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<DirectoryEntry> seqOf = null;
|
||||||
|
|
||||||
|
public ListOfDirectoryEntry() {
|
||||||
|
seqOf = new ArrayList<DirectoryEntry>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListOfDirectoryEntry(byte[] code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DirectoryEntry> getDirectoryEntry() {
|
||||||
|
if (seqOf == null) {
|
||||||
|
seqOf = new ArrayList<DirectoryEntry>();
|
||||||
|
}
|
||||||
|
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, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
DirectoryEntry element = new DirectoryEntry();
|
||||||
|
subCodeLength += element.decode(is, true);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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<DirectoryEntry> 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 final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
|
||||||
|
|
||||||
|
public byte[] code = null;
|
||||||
|
private ListOfDirectoryEntry listOfDirectoryEntry = null;
|
||||||
|
private BerBoolean moreFollows = null;
|
||||||
|
|
||||||
|
public FileDirectoryResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileDirectoryResponse(byte[] code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListOfDirectoryEntry(ListOfDirectoryEntry listOfDirectoryEntry) {
|
||||||
|
this.listOfDirectoryEntry = listOfDirectoryEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListOfDirectoryEntry getListOfDirectoryEntry() {
|
||||||
|
return listOfDirectoryEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoreFollows(BerBoolean moreFollows) {
|
||||||
|
this.moreFollows = moreFollows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BerBoolean getMoreFollows() {
|
||||||
|
return moreFollows;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
int sublength;
|
||||||
|
|
||||||
|
if (moreFollows != null) {
|
||||||
|
codeLength += moreFollows.encode(os, false);
|
||||||
|
// write tag: CONTEXT_CLASS, PRIMITIVE, 1
|
||||||
|
os.write(0x81);
|
||||||
|
codeLength += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sublength = listOfDirectoryEntry.encode(os, true);
|
||||||
|
codeLength += sublength;
|
||||||
|
codeLength += BerLength.encodeLength(os, sublength);
|
||||||
|
// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
|
||||||
|
os.write(0xA0);
|
||||||
|
codeLength += 1;
|
||||||
|
|
||||||
|
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;
|
||||||
|
BerTag berTag = new BerTag();
|
||||||
|
|
||||||
|
if (withTag) {
|
||||||
|
codeLength += tag.decodeAndCheck(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
BerLength length = new BerLength();
|
||||||
|
codeLength += length.decode(is);
|
||||||
|
|
||||||
|
int totalLength = length.val;
|
||||||
|
codeLength += totalLength;
|
||||||
|
|
||||||
|
subCodeLength += berTag.decode(is);
|
||||||
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
|
||||||
|
subCodeLength += length.decode(is);
|
||||||
|
listOfDirectoryEntry = new ListOfDirectoryEntry();
|
||||||
|
subCodeLength += listOfDirectoryEntry.decode(is, true);
|
||||||
|
if (subCodeLength == totalLength) {
|
||||||
|
return codeLength;
|
||||||
|
}
|
||||||
|
subCodeLength += berTag.decode(is);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IOException("Tag does not match the mandatory sequence element tag.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
|
||||||
|
moreFollows = new BerBoolean();
|
||||||
|
subCodeLength += moreFollows.decode(is, false);
|
||||||
|
if (subCodeLength == totalLength) {
|
||||||
|
return codeLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void encodeAndSave(int encodingSizeGuess) throws IOException {
|
||||||
|
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(encodingSizeGuess);
|
||||||
|
encode(os, false);
|
||||||
|
code = os.getArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
appendAsString(sb, 0);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void appendAsString(StringBuilder sb, int indentLevel) {
|
||||||
|
|
||||||
|
sb.append("{");
|
||||||
|
sb.append("\n");
|
||||||
|
for (int i = 0; i < indentLevel + 1; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
if (listOfDirectoryEntry != null) {
|
||||||
|
sb.append("listOfDirectoryEntry: ");
|
||||||
|
listOfDirectoryEntry.appendAsString(sb, indentLevel + 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sb.append("listOfDirectoryEntry: <empty-required-field>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (moreFollows != null) {
|
||||||
|
sb.append(",\n");
|
||||||
|
for (int i = 0; i < indentLevel + 1; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append("moreFollows: ").append(moreFollows);
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("\n");
|
||||||
|
for (int i = 0; i < indentLevel; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append("}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,147 @@
|
|||||||
|
/**
|
||||||
|
* This class file was automatically generated by jASN1 v1.9.1-SNAPSHOT (http://www.openmuc.org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openmuc.openiec61850.internal.mms.asn1;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import org.openmuc.jasn1.ber.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.*;
|
||||||
|
import org.openmuc.jasn1.ber.types.string.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class FileName 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<BerGraphicString> seqOf = null;
|
||||||
|
|
||||||
|
public FileName() {
|
||||||
|
seqOf = new ArrayList<BerGraphicString>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileName(byte[] code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BerGraphicString> getBerGraphicString() {
|
||||||
|
if (seqOf == null) {
|
||||||
|
seqOf = new ArrayList<BerGraphicString>();
|
||||||
|
}
|
||||||
|
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, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
BerGraphicString element = new BerGraphicString();
|
||||||
|
subCodeLength += element.decode(is, true);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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<BerGraphicString> it = seqOf.iterator();
|
||||||
|
if (it.hasNext()) {
|
||||||
|
sb.append(it.next());
|
||||||
|
while (it.hasNext()) {
|
||||||
|
sb.append(",\n");
|
||||||
|
for (int i = 0; i < indentLevel + 1; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append(it.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("\n");
|
||||||
|
for (int i = 0; i < indentLevel; i++) {
|
||||||
|
sb.append("\t");
|
||||||
|
}
|
||||||
|
sb.append("}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue