001/*
002 * Copyright 2022-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2022-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2022-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.logs.v2;
037
038
039
040import java.io.Serializable;
041import java.util.Date;
042import java.util.List;
043import java.util.Map;
044
045import com.unboundid.ldap.sdk.unboundidds.logs.LogException;
046import com.unboundid.util.NotExtensible;
047import com.unboundid.util.NotNull;
048import com.unboundid.util.Nullable;
049import com.unboundid.util.ThreadSafety;
050import com.unboundid.util.ThreadSafetyLevel;
051
052
053
054/**
055 * This class provides a data structure that holds information about a log
056 * message.
057 * <BR>
058 * <BLOCKQUOTE>
059 *   <B>NOTE:</B>  This class, and other classes within the
060 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
061 *   supported for use against Ping Identity, UnboundID, and
062 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
063 *   for proprietary functionality or for external specifications that are not
064 *   considered stable or mature enough to be guaranteed to work in an
065 *   interoperable way with other types of LDAP servers.
066 * </BLOCKQUOTE>
067 */
068@NotExtensible()
069@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
070public interface LogMessage
071       extends Serializable
072{
073  /**
074   * Retrieves the timestamp for this log message.
075   *
076   * @return  The timestamp for this log message.
077   */
078  @NotNull()
079  Date getTimestamp();
080
081
082
083  /**
084   * Retrieves a map of the fields and their corresponding values in this
085   * log message.
086   *
087   * @return  A map of the fields and their corresponding values in this log
088   *          message.
089   */
090  @NotNull()
091  Map<String,List<String>> getFields();
092
093
094
095  /**
096   * Retrieves the value of the specified field as a {@code Boolean} object.  If
097   * the field has multiple values, the first will be returned.
098   *
099   * @param  logField  The field for which to retrieve the Boolean value.
100   *
101   * @return  The value of the specified field as a {@code Boolean} object, or
102   *          {@code null} if the log message does not have the specified field.
103   *
104   * @throws  LogException  If the value of the specified field cannot be parsed
105   *                        as a Boolean.
106   */
107  @Nullable()
108  Boolean getBoolean(@NotNull LogField logField)
109          throws LogException;
110
111
112
113  /**
114   * Retrieves the value of the specified field as a {@code Date} object decoded
115   * from the generalized time format.  If the field has multiple values, the
116   * first will be returned.
117   *
118   * @param  logField  The field for which to retrieve the timestamp value.
119   *
120   * @return  The value of the specified field as a {@code Date} object, or
121   *          {@code null} if the log message does not have the specified field.
122   *
123   * @throws  LogException  If the value of the specified field cannot be parsed
124   *                        as a {@code Date} in the generalized time format.
125   */
126  @Nullable()
127  Date getGeneralizedTime(@NotNull LogField logField)
128       throws LogException;
129
130
131
132  /**
133   * Retrieves the value of the specified field as a {@code Double} value.  If
134   * the field has multiple values, the first will be returned.
135   *
136   * @param  logField  The field for which to retrieve the {@code Double} value.
137   *
138   * @return  The value of the specified field as a {@code Double} value, or
139   *          {@code null} if the log message does not have the specified field.
140   *
141   * @throws  LogException  If the value of the specified field cannot be parsed
142   *                        as a {@code Double}.
143   */
144  @Nullable()
145  Double getDouble(@NotNull LogField logField)
146         throws LogException;
147
148
149
150  /**
151   * Retrieves the value of the specified field as an {@code Integer} value.  If
152   * the field has multiple values, the first will be returned.
153   *
154   * @param  logField  The field for which to retrieve the {@code Integer}
155   *                   value.
156   *
157   * @return  The {@code Integer} value of the specified field, or {@code null}
158   *          if the log message does not have the specified field.
159   *
160   * @throws  LogException  If the value of the specified field cannot be parsed
161   *                        as an {@code Integer}.
162   */
163  @Nullable()
164  Integer getInteger(@NotNull LogField logField)
165       throws LogException;
166
167
168
169  /**
170   * Retrieves the value of the specified field as a {@code Long} value.  If the
171   * field has multiple values, the first will be returned.
172   *
173   * @param  logField  The field for which to retrieve the {@code Long} value.
174   *
175   * @return  The {@code Long} value of the specified field, or {@code null}
176   *          if the log message does not have the specified field.
177   *
178   * @throws  LogException  If the value of the specified field cannot be parsed
179   *                        as a {@code Long}.
180   */
181  @Nullable()
182  Long getLong(@NotNull LogField logField)
183       throws LogException;
184
185
186
187  /**
188   * Retrieves the value of the specified field as a {@code Date} object decoded
189   * from the ISO 8601 format described in RFC 3339.  If the field has multiple
190   * values, the first will be returned.
191   *
192   * @param  logField  The field for which to retrieve the timestamp value.
193   *
194   * @return  The value of the specified field as a {@code Date} object, or
195   *          {@code null} if the log message does not have the specified field.
196   *
197   * @throws  LogException  If the value of the specified field cannot be parsed
198   *                        as a {@code Date} in the RFC 3339 format.
199   */
200  @Nullable()
201  Date getRFC3339Timestamp(@NotNull LogField logField)
202       throws LogException;
203
204
205
206  /**
207   * Retrieves the value of the specified field as a string.  If the field has
208   * multiple values, the first will be returned.
209   *
210   * @param  logField  The field for which to retrieve the string value.
211   *
212   * @return  The value of the specified field as a string, or {@code null} if
213   *          the log message does not have the specified field.
214   */
215  @Nullable()
216  String getString(@NotNull LogField logField);
217
218
219
220  /**
221   * Retrieves a string representation of this log message.
222   *
223   * @return  A string representation of this log message.
224   */
225  @NotNull()
226  String toString();
227}