derconstructedset.java
来自「《移动Agent技术》一书的所有章节源代码。」· Java 代码 · 共 78 行
JAVA
78 行
package org.bouncycastle.asn1;import java.io.*;import java.util.*;public class DERConstructedSet extends DERObject{ private Vector set = new Vector(); public DERConstructedSet() { } public void addObject( DEREncodable obj) { set.addElement(obj); } public Enumeration getObjects() { return set.elements(); } /** * return the object at the set postion indicated by index. * * @param the set number (starting at zero) of the object * @return the object at the set postion indicated by index. */ public Object getObjectAt( int index) { return set.elementAt(index); } /** * return the number of objects in this set. * * @return the number of objects in this set. */ public int getSize() { return set.size(); } /* * A note on the implementation: * <p> * As DER requires the constructed, definite-length model to * be used for structured types, this varies slightly from the * ASN.1 descriptions given. Rather than just outputing SET, * we also have to specify CONSTRUCTED, and the objects length. */ void encode( DEROutputStream out) throws IOException { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); DEROutputStream dOut = new DEROutputStream(bOut); Enumeration e = getObjects(); while (e.hasMoreElements()) { Object obj = e.nextElement(); dOut.writeObject(obj); } dOut.close(); byte[] bytes = bOut.toByteArray(); out.writeEncoded(SET | CONSTRUCTED, bytes); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?