<commit_before>/*
 * $Id$
 *
 * Copyright 2003-2006 Wanadoo Nederland B.V.
 * See the COPYRIGHT file for redistribution and use restrictions.
 */
package org.xins.server;

import org.xins.common.MandatoryArgumentChecker;
import org.xins.common.collections.PropertyReader;
import org.xins.common.xml.Element;

/**
 * Context for a function call. Objects of this kind are passed with a
 * function call.
 *
 * @version $Revision$ $Date$
 * @author <NAME> (<a href="mailto:<EMAIL>"><EMAIL></a>)
 *
 * @since XINS 1.0.0
 */
public final class CallContext
extends Object {

   //-------------------------------------------------------------------------
   // Constructors
   //-------------------------------------------------------------------------

   /**
    * Constructs a new <code>CallContext</code> and configures it for the
    * specified request.
    *
    * @param functionRequest
    *    the request, never <code>null</code>.
    *
    * @param start
    *    the start time of the call, as milliseconds since midnight January 1,
    *    1970.
    *
    * @param function
    *    the concerning function, cannot be <code>null</code>.
    *
    * @param callID
    *    the assigned call ID.
    *
    * @param remoteIP
    *    the IP address of the caller.
    *
    * @throws IllegalArgumentException
    *    if <code>parameters == null || function == null</code>.
    */
   CallContext(FunctionRequest functionRequest,
               long            start,
               Function        function,
               int             callID,
               String          remoteIP)
   throws IllegalArgumentException {

      // Check preconditions
      MandatoryArgumentChecker.check("functionRequest",  functionRequest,
                                     "function",         function);

      // Initialize fields
      _parameters   = functionRequest.getParameters();
      _dataElement  = functionRequest.getDataElement();
      _start        = start;
      _callID       = callID;
      _remoteIP     = remoteIP;
      _builder      = new FunctionResult();
   }


   //-------------------------------------------------------------------------
   // Fields
   //-------------------------------------------------------------------------

   /**
    * The parameters of the request.
    */
   private final PropertyReader _parameters;

   /**
    * The data section of the request.
    */
   private final Element _dataElement;

   /**
    * The call result builder. Cannot be <code>null</code>.
    */
   private final FunctionResult _builder;

   /**
    * The start time of the call, as a number of milliseconds since midnight
    * January 1, 1970 UTC.
    */
   private final long _start;

   /**
    * The call ID, unique in the context of the pertaining function.
    */
   private final int _callID;

   /**
    * The IP address of the caller.
    */
   private final String _remoteIP;


   //-------------------------------------------------------------------------
   // Methods
   //-------------------------------------------------------------------------

   /**
    * Returns the start time of the call.
    *
    * @return
    *    the timestamp indicating when the call was started, as a number of
    *    milliseconds since midnight January 1, 1970 UTC.
    */
   public long getStart() {
      return _start;
   }

   /**
    * Returns the stored return code.
    *
    * @return
    *    the return code, can be <code>null</code>.
    */
   final String getErrorCode() {
      return _builder.getErrorCode();
   }<commit_msg>Added @see System#currentTimeMillis() for the getStart() method.<commit_after>/*
 * $Id$
 *
 * Copyright 2003-2006 Wanadoo Nederland B.V.
 * See the COPYRIGHT file for redistribution and use restrictions.
 */
package org.xins.server;

import org.xins.common.MandatoryArgumentChecker;
import org.xins.common.collections.PropertyReader;
import org.xins.common.xml.Element;

/**
 * Context for a function call. Objects of this kind are passed with a
 * function call.
 *
 * @version $Revision$ $Date$
 * @author <NAME> (<a href="mailto:<EMAIL>"><EMAIL></a>)
 *
 * @since XINS 1.0.0
 */
public final class CallContext
extends Object {

   //-------------------------------------------------------------------------
   // Constructors
   //-------------------------------------------------------------------------

   /**
    * Constructs a new <code>CallContext</code> and configures it for the
    * specified request.
    *
    * @param functionRequest
    *    the request, never <code>null</code>.
    *
    * @param start
    *    the start time of the call, as milliseconds since midnight January 1,
    *    1970.
    *
    * @param function
    *    the concerning function, cannot be <code>null</code>.
    *
    * @param callID
    *    the assigned call ID.
    *
    * @param remoteIP
    *    the IP address of the caller.
    *
    * @throws IllegalArgumentException
    *    if <code>parameters == null || function == null</code>.
    */
   CallContext(FunctionRequest functionRequest,
               long            start,
               Function        function,
               int             callID,
               String          remoteIP)
   throws IllegalArgumentException {

      // Check preconditions
      MandatoryArgumentChecker.check("functionRequest",  functionRequest,
                                     "function",         function);

      // Initialize fields
      _parameters   = functionRequest.getParameters();
      _dataElement  = functionRequest.getDataElement();
      _start        = start;
      _callID       = callID;
      _remoteIP     = remoteIP;
      _builder      = new FunctionResult();
   }


   //-------------------------------------------------------------------------
   // Fields
   //-------------------------------------------------------------------------

   /**
    * The parameters of the request.
    */
   private final PropertyReader _parameters;

   /**
    * The data section of the request.
    */
   private final Element _dataElement;

   /**
    * The call result builder. Cannot be <code>null</code>.
    */
   private final FunctionResult _builder;

   /**
    * The start time of the call, as a number of milliseconds since midnight
    * January 1, 1970 UTC.
    */
   private final long _start;

   /**
    * The call ID, unique in the context of the pertaining function.
    */
   private final int _callID;

   /**
    * The IP address of the caller.
    */
   private final String _remoteIP;


   //-------------------------------------------------------------------------
   // Methods
   //-------------------------------------------------------------------------

   /**
    * Returns the start time of the call.
    *
    * @return
    *    the timestamp indicating when the call was started, as a number of
    *    milliseconds since midnight January 1, 1970 UTC.
    *
    * @see System#currentTimeMillis()
    */
   public long getStart() {
      return _start;
   }

   /**
    * Returns the stored return code.
    *
    * @return
    *    the return code, can be <code>null</code>.
    */
   final String getErrorCode() {
      return _builder.getErrorCode();
   }
{'fraction_non_alphanumeric': 0.20881252598032424, 'fraction_numerical': 0.007205209921019814, 'mean_word_length': 1.4254032258064515, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1690724', 'n_tokens_mistral': 1847, 'n_tokens_neox': 1763, 'n_words': 566}