<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses(
    'remote.protocol.XpProtocolConstants',
    'remote.server.message.EascInitMessage',
    'remote.server.message.EascLookupMessage',
    'remote.server.message.EascValueMessage',
    'remote.server.message.EascExceptionMessage',
    'remote.server.message.EascCallMessage'
  );

  /**
   * Factory class for EASC message classes
   *
   * @purpose  Create EASC message
   */
  class EascMessageFactory extends Object {
  
    /**
     * Factory method
     *
     * @param   int type
     * @return  lang.XPClass
     */
    public static function forType($type) {
      $handlers= array(
        REMOTE_MSG_INIT       => 'Init',
        REMOTE_MSG_LOOKUP     => 'Lookup',
        REMOTE_MSG_CALL       => 'Call',
        REMOTE_MSG_VALUE      => 'Value',
        REMOTE_MSG_EXCEPTION  => 'Exception'
      );
      
      return XPClass::forName(sprintf('remote.server.message.Easc%sMessage', $handlers[$type]))->newInstance();
    }
  }
?><commit_msg>- Make handlers changeable via setHandler()<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses(
    'remote.protocol.XpProtocolConstants',
    'remote.server.message.EascInitMessage',
    'remote.server.message.EascLookupMessage',
    'remote.server.message.EascValueMessage',
    'remote.server.message.EascExceptionMessage',
    'remote.server.message.EascCallMessage'
  );

  /**
   * Factory class for EASC message classes
   *
   * @purpose  Create EASC message
   */
  abstract class EascMessageFactory extends Object {
    protected static 
      $handlers= array();
    
    static function __static() {
      self::$handlers[REMOTE_MSG_INIT]= XPClass::forName('remote.server.message.EascInitMessage');
      self::$handlers[REMOTE_MSG_LOOKUP]= XPClass::forName('remote.server.message.EascLookupMessage');
      self::$handlers[REMOTE_MSG_CALL]= XPClass::forName('remote.server.message.EascCallMessage');
      self::$handlers[REMOTE_MSG_VALUE]= XPClass::forName('remote.server.message.EascValueMessage');
      self::$handlers[REMOTE_MSG_EXCEPTION]= XPClass::forName('remote.server.message.EascExceptionMessage');
    }
  
    /**
     * Set handler for a given type to 
     *
     * @param   int type
     * @param   lang.XPClass class
     */
    public static function setHandler($type, XPClass $class) {
      self::$handlers[$type]= $class;
    }
  
    /**
     * Factory method
     *
     * @param   int type
     * @return  remote.server.message.EascMessage
     * @throws  lang.IllegalArgumentException if no message exists for this type.
     */
    public static function forType($type) {
      if (!isset(self::$handlers[$type])) {
        throw new IllegalArgumentException('Unknown message type '.$type);
      }
      return self::$handlers[$type]->newInstance();
    }
  }
?>
{'fraction_non_alphanumeric': 0.12782216047238623, 'fraction_numerical': 0.0, 'mean_word_length': 3.027972027972028, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6269992', 'n_tokens_mistral': 909, 'n_tokens_neox': 885, 'n_words': 162}