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

org.jdiameter.api.validation.Dictionary Maven / Gradle / Ivy

There is a newer version: 1.7.1-123
Show newest version
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2010, Red Hat, Inc. and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.jdiameter.api.validation;

import java.io.InputStream;

import org.jdiameter.api.Message;

/**
 * Second generation Dictionary/Validator. This interface is exposed directly.
 * 
 * @author  Alexandre Mendonca 
 * @author  Bartosz Baranowski 
 * @version 1.1
 */
public interface Dictionary {

  /**
   * Fetches Avp representation for given code. If no such AVP is found,
   * null value is returned.
   * 
   * @param code
   *            - positive integer, equal to AVP code.
   * @return AvpRepresentation for given code or null
   */
  public AvpRepresentation getAvp(int code);

  /**
   * Fetches Avp representation for given code and vendorId. If no such AVP is
   * found, null value is returned.
   * 
   * @param code
   *            - positive integer, equal to AVP code.
   * @param vendorId
   *            - positive long representing vendor code.
   * @return AvpRepresentation for given code/vendor pair or null
   */
  public AvpRepresentation getAvp(int code, long vendorId);

  /**
   * Fetches Avp representation for given name. If no such AVP is found,
   * null value is returned.
   * 
   * @param name
   *            - name of AVP, like Session-Id.
   * @return AvpRepresentation for given name or null
   */
  public AvpRepresentation getAvp(String avpName);

  /**
   * 
   * @param commandCode
   *            - command code of message
   * @param isRequest
   *            - switches if lookup searches for request or answer
   * @return message representation for given code and flag value or
   *         null
   */
  public MessageRepresentation getMessage(int commandCode, boolean isRequest);

  /**
   * 
   * @param commandCode
   *            - command code of message
   * @param applicationId
   *            - application id present in message header
   * @param isRequest
   *            - switches if lookup searches for request or answer
   * 
   * @return message representation for given code, application and flag value
   *         or null
   */
  public MessageRepresentation getMessage(int commandCode, long applicationId, boolean isRequest);

  /**
   * Configures dictionary. It can be called multiple times, each call
   * reconfigures dictionary.
   * 
   * @param is
   */
  public void configure(InputStream is);

  // Validator ----------------------------------------------------------------

  /**
   * Gets whether validator is enabled.
   * 
   * @return 
    *
  • true if validator is enabled
  • *
  • false if validator is disabled
  • *
*/ public boolean isEnabled(); /** * Sets whether validator is enabled. * * @param enabled true to enable the validator, false to disable it */ public void setEnabled(boolean enabled); /** * Gets whether validator is configured. * * @return
    *
  • true if validator has been initialized
  • *
  • false if validator has not yet been initialized
  • *
*/ public boolean isConfigured(); /** * Gets validator level for OUTGOING messages. * Possible values are defined at {@link ValidatorLevel} * * @return an instance of {@link ValidatorLevel} representing the current level */ public ValidatorLevel getSendLevel(); /** * Gets validator level for OUTGOING messages. * Possible values are defined at {@link ValidatorLevel} * * @param sendLevel an instance of {@link ValidatorLevel} representing the new level */ public void setSendLevel(ValidatorLevel sendLevel); /** * Gets validator level for INCOMING messages. * Possible values are defined at {@link ValidatorLevel} * * @return an instance of {@link ValidatorLevel} representing the current level */ public ValidatorLevel getReceiveLevel(); /** * Sets validator level for INCOMING messages. * Possible values are defined at {@link ValidatorLevel} * * @param receiveLevel an instance of {@link ValidatorLevel} representing the new level */ public void setReceiveLevel(ValidatorLevel receiveLevel); /** * Performs validation according to configured levels * * @param message - message we want to validate * @param incoming - flag indicating if {@link #message} is incoming message or outgoing. * @throws AvpNotAllowedException - in case validation fails. Exception has details(avp code and similar) about failure. */ public void validate(Message message, boolean incoming) throws AvpNotAllowedException; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy