001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2016 ForgeRock AS. 016 */ 017package org.opends.server.protocols.ldap; 018 019import org.forgerock.opendj.io.ASN1Writer; 020 021import java.io.IOException; 022 023 024/** 025 * This class defines the structures and methods for an LDAP protocol op, which 026 * is the core of an LDAP message. 027 */ 028public abstract class ProtocolOp 029{ 030 /** 031 * Retrieves the BER type for this protocol op. 032 * 033 * @return The BER type for this protocol op. 034 */ 035 public abstract byte getType(); 036 037 038 039 /** 040 * Retrieves the name for this protocol op type. 041 * 042 * @return The name for this protocol op type. 043 */ 044 public abstract String getProtocolOpName(); 045 046 047 048 /** 049 * Writes this protocol op to an ASN.1 output stream. 050 * 051 * @param stream The ASN.1 output stream to write to. 052 * @throws IOException If a problem occurs while writing to the stream. 053 */ 054 public abstract void write(ASN1Writer stream) throws IOException; 055 056 057 /** 058 * Retrieves a string representation of this LDAP protocol op. 059 * 060 * @return A string representation of this LDAP protocol op. 061 */ 062 @Override 063 public String toString() 064 { 065 StringBuilder buffer = new StringBuilder(); 066 toString(buffer); 067 return buffer.toString(); 068 } 069 070 071 072 /** 073 * Appends a string representation of this LDAP protocol op to the provided 074 * buffer. 075 * 076 * @param buffer The buffer to which the string should be appended. 077 */ 078 public abstract void toString(StringBuilder buffer); 079 080 081 082 /** 083 * Appends a multi-line string representation of this LDAP protocol op to the 084 * provided buffer. 085 * 086 * @param buffer The buffer to which the information should be appended. 087 * @param indent The number of spaces from the margin that the lines should 088 * be indented. 089 */ 090 public abstract void toString(StringBuilder buffer, int indent); 091} 092