Пример #1
0
  /**
   * Process this event with the given arguments. The number of arguments provided must be equal to
   * the number of formal parameters defined for this event, and their types must match. The actions
   * of this event are executed.
   *
   * @param arguments The arguments used to process this event, which must be either an ArrayToken
   *     or a RecordToken.
   * @return A refiring data structure that contains a non-negative double number if refire() should
   *     be called after that amount of model time, or null if refire() need not be called.
   * @exception IllegalActionException If the number of the arguments or their types do not match,
   *     the actions cannot be executed, or any expression (such as guards and arguments to the next
   *     events) cannot be evaluated.
   * @see #refire(Token, RefiringData)
   */
  public RefiringData fire(Token arguments) throws IllegalActionException {
    File[] listedFiles =
        RecursiveFileFilter.listFiles(
            directory.asFile(),
            ((BooleanToken) recursive.getToken()).booleanValue(),
            ((BooleanToken) includeFiles.getToken()).booleanValue(),
            ((BooleanToken) includeDirectories.getToken()).booleanValue(),
            filter.stringValue());
    StringBuffer buffer = new StringBuffer("{ ");
    int i = 0;
    for (File file : listedFiles) {
      if (i++ > 0) {
        buffer.append(",\n  ");
      }
      buffer.append('\"');
      buffer.append(StringUtilities.escapeString(file.getPath()));
      buffer.append('\"');
    }
    if (listedFiles.length > 0) {
      buffer.append(' ');
    }
    buffer.append('}');
    files.setExpression(buffer.toString());

    return super.fire(arguments);
  }