All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.palindromicity.syslog.KeyProvider Maven / Gradle / Ivy

/*
 * Copyright 2018-2022 simple-syslog authors
 * All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.palindromicity.syslog;

import com.github.palindromicity.syslog.dsl.SyslogFieldKeys;
import java.util.regex.Pattern;
import org.jspecify.nullness.NullMarked;

/**
 * {@code KeyProvider} defines an interface for classes that can be used to provide
 * Map keys used for Syslog message parts. Some keys only apply to certain RFCs
 */
@NullMarked
public interface KeyProvider {

  /**
   * Provides the key name for a given SyslogFieldKeys.
   *
   * @param key {@code SyslogFieldKeys}
   * @return the key name corresponding to the passed SyslogFieldKeys
   */
  String get(SyslogFieldKeys key);

  /**
   * Provides the key name for the MSG @see Section 6.4.
   *
   * @return MSG key name
   */
  String getMessage();

  /**
   * Provides the key name for the HEADER APP-NAME @see Section 6.2.5.
   *
   * @return APP-NAME key name
   */
  String getHeaderAppName();

  /**
   * Provides the key name for the HEADER HOSTNAME @see Section 6.2.4.
   *
   * @return HOSTNAME key name
   */
  String getHeaderHostName();

  /**
   * Provides the key name for the HEADER PRI @see Section 6.2.1.
   *
   * @return PRI key name
   */
  String getHeaderPriority();

  /**
   * Provides the key name for the Severity from the HEADER PRI @see Section 6.2.1.
   *
   * @return PRI key name
   */
  String getHeaderSeverity();

  /**
   * Provides the key name for the Facility from the HEADER PRI @see Section 6.2.1.
   *
   * @return PRI key name
   */
  String getHeaderFacility();

  /**
   * Provides the key name for the HEADER PROCID @see Section 6.2.6.
   *
   * @return PROCID key name
   */
  String getHeaderProcessId();

  /**
   * Provides the key name for the HEADER TIMESTAMP @see Section 6.2.3.
   *
   * @return TIMESTAMP key name
   */
  String getHeaderTimeStamp();

  /**
   * Provides the key name for the HEADER MSGID @see Section 6.2.7.
   *
   * @return MSGID key name
   */
  String getHeaderMessageId();

  /**
   * Provides the key name for the HEADER VERSION @see Section 6.2.2.
   *
   * @return VERSION key name
   */
  String getHeaderVersion();

  /**
   * The base String used for all STRUCTURED_DATA keys.
   * {@code syslog.structuredData. } for example.
   * This can be useful to find all STRUCTURED_DATA keys
   *
   * @return STRUCTURED_DATA base key name
   * @see Section 6.3
   */
  String getStructuredBase();

  /**
   * Provides a {@code String.format} {@code String} for producing key name for the
   * STRUCTURED_DATA SD-ID @see Section 6.3.2.
   * The format {@code String} supports one parameter {@code %s} that will be passed the SD-ID
   * value.
   * The format must begin with the value returned from {@link KeyProvider#getStructuredBase()}
   * For example:
   * 
   *   {@code syslog.structuredData.%s}
   * 
* * @return SD-ID format String */ String getStructuredElementIdFormat(); /** * Provides a {@code String.format} {@code String} for producing key name for the * STRUCTURED_DATA SD-PARAM @see Section 6.3.3. * The format {@code String} supports two parameters {@code %s} that will be passed the * SD-ID value and the SD-PARAM PARAM-NAME. * The format must begin with the value returned from {@link KeyProvider#getStructuredBase()} * For example: *
   *  {@code syslog.structuredData.%s.%s}
   * 
* * @return SD-PARAM format String */ String getStructuredElementIdParamNameFormat(); /** * Provides {@code Pattern} that will match and capture the SD-ID and SD-PARAM PARAM-NAME as * defined in the return from {@link KeyProvider#getStructuredElementIdParamNameFormat()}. * * @return {@code Pattern} */ Pattern getStructuredElementIdParamNamePattern(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy