| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | private final int messageID; |
| | | |
| | | // The protocol op for this LDAP message. |
| | | private ProtocolOp protocolOp; |
| | | private final ProtocolOp protocolOp; |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | public LDAPMessage(int messageID, ProtocolOp protocolOp) |
| | | { |
| | | this.messageID = messageID; |
| | | this.protocolOp = protocolOp; |
| | | |
| | | controls = new ArrayList<Control>(0); |
| | | this(messageID, protocolOp, null); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.messageID = messageID; |
| | | this.protocolOp = protocolOp; |
| | | |
| | | if (controls == null) |
| | | { |
| | | this.controls = new ArrayList<Control>(0); |
| | | } |
| | | else |
| | | { |
| | | this.controls = controls; |
| | | } |
| | | this.controls = controls; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Specifies the protocol op for this LDAP message. |
| | | * |
| | | * @param protocolOp The protocol op for this LDAP message. |
| | | */ |
| | | public void setProtocolOp(ProtocolOp protocolOp) |
| | | { |
| | | this.protocolOp = protocolOp; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the set of controls for this LDAP message. It may be modified by |
| | | * the caller. |
| | | * |
| | |
| | | */ |
| | | public List<Control> getControls() |
| | | { |
| | | // This method is not thread-safe. |
| | | if (controls == null) |
| | | { |
| | | controls = new ArrayList<Control>(0); |
| | | } |
| | | return controls; |
| | | } |
| | | |
| | |
| | | stream.writeInteger(messageID); |
| | | protocolOp.write(stream); |
| | | |
| | | if(!controls.isEmpty()) |
| | | if(controls != null && !controls.isEmpty()) |
| | | { |
| | | stream.writeStartSequence(TYPE_CONTROL_SEQUENCE); |
| | | for(Control control : controls) |
| | |
| | | buffer.append(EOL); |
| | | protocolOp.toString(buffer, indent+4); |
| | | |
| | | if (! controls.isEmpty()) |
| | | if (controls != null && !controls.isEmpty()) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Controls:"); |