| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.protocols.asn1; |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | import static org.opends.server.protocols.asn1.ASN1Constants.*; |
| | |
| | | public class ASN1Set |
| | | extends ASN1Element |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.protocols.asn1.ASN1Set"; |
| | | |
| | | |
| | | |
| | |
| | | { |
| | | super(UNIVERSAL_SET_TYPE); |
| | | |
| | | assert debugConstructor(CLASS_NAME); |
| | | |
| | | this.elements = new ArrayList<ASN1Element>(); |
| | | } |
| | |
| | | { |
| | | super(type); |
| | | |
| | | assert debugConstructor(CLASS_NAME, byteToHex(type)); |
| | | |
| | | this.elements = new ArrayList<ASN1Element>(); |
| | | } |
| | |
| | | { |
| | | super(UNIVERSAL_SET_TYPE, encodeValue(elements)); |
| | | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(elements)); |
| | | |
| | | if (elements == null) |
| | | { |
| | |
| | | { |
| | | super(type, encodeValue(elements)); |
| | | |
| | | assert debugConstructor(CLASS_NAME, byteToHex(type), |
| | | String.valueOf(elements)); |
| | | |
| | | if (elements == null) |
| | | { |
| | |
| | | { |
| | | super(type, value); |
| | | |
| | | assert debugConstructor(CLASS_NAME, byteToHex(type), bytesToHex(value), |
| | | String.valueOf(elements)); |
| | | |
| | | if (elements == null) |
| | | { |
| | |
| | | */ |
| | | public ArrayList<ASN1Element> elements() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "elements"); |
| | | |
| | | return elements; |
| | | } |
| | |
| | | */ |
| | | public void setElements(ArrayList<ASN1Element> elements) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setValue", String.valueOf(elements)); |
| | | |
| | | if (elements == null) |
| | | { |
| | |
| | | public void setValue(byte[] value) |
| | | throws ASN1Exception |
| | | { |
| | | assert debugEnter(CLASS_NAME, "setValue", bytesToHex(value)); |
| | | |
| | | if (value == null) |
| | | { |
| | |
| | | public static ASN1Set decodeAsSet(ASN1Element element) |
| | | throws ASN1Exception |
| | | { |
| | | assert debugEnter(CLASS_NAME, "decodeAsSet", String.valueOf(element)); |
| | | |
| | | if (element == null) |
| | | { |
| | |
| | | public static ASN1Set decodeAsSet(byte[] encodedElement) |
| | | throws ASN1Exception |
| | | { |
| | | assert debugEnter(CLASS_NAME, "decodeAsSet", |
| | | bytesToHex(encodedElement)); |
| | | |
| | | // First make sure that the array is not null and long enough to contain |
| | | // a valid ASN.1 set element. |
| | |
| | | */ |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "toString", "java.lang.StringBuilder"); |
| | | |
| | | buffer.append("ASN1Set(type="); |
| | | buffer.append(byteToHex(getType())); |
| | |
| | | */ |
| | | public void toString(StringBuilder buffer, int indent) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "toString", "java.lang.StringBuilder", |
| | | String.valueOf(indent)); |
| | | |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | | for (int i=0 ; i < indent; i++) |