Exemple #1
0
 private int load(int addr) {
   if (addr == RN) {
     return rand.nextInt();
   }
   if (addr == KY) {
     return keys;
   }
   if (addr == KB) {
     if (keyQueue.size() > 0) {
       return keyQueue.remove();
     }
     return -1;
   }
   if (addr == CO) {
     try {
       return System.in.read();
     } catch (java.io.IOException e) {
       e.printStackTrace();
     }
   }
   if (addr == XO) {
     if (xi.containsKey(m[XA])) {
       try {
         return normalizeRead(xi.get(m[XA]));
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
     return -1;
   }
   if (addr == XS) {
     return 3; // supports reading/writing local files
   }
   return m[addr];
 }
Exemple #2
0
  public static Result start() {
    java.util.Map<String, String[]> map = request().body().asFormUrlEncoded();

    List<String> terms = new ArrayList<>(map.size());
    for (int i = 0; i < map.size(); i++) {
      String key = "terms[" + i + "]";
      if (map.containsKey(key)) {
        String[] values = map.get(key);
        if ((values != null) && (values.length >= 1)) {
          terms.add(values[0]);
        }
      }
    }

    StreamConfig config = getConfig();
    config.putTerms(terms);
    config.update();

    StringBuilder sb = new StringBuilder();
    for (String t : terms) {
      sb.append(t);
      sb.append(", ");
    }
    sb.delete(sb.length() - 2, sb.length());

    try {
      startStream(terms);
      flash("success", "Twitter stream started (" + sb.toString() + ")");
    } catch (TwitterException e) {
      Logger.info("Error starting twitter stream", e);
      flash("error", "Error starting Twitter stream" + e.getMessage());
    }
    return redirect(routes.Streams.listAll());
  }
 /**
  * @attribute syn
  * @aspect Fields
  * @declaredat /home/uoji/JastAddJ/Java1.4Frontend/LookupVariable.jrag:347
  */
 @SuppressWarnings({"unchecked", "cast"})
 public SimpleSet memberFields(String name) {
   Object _parameters = name;
   if (memberFields_String_values == null) memberFields_String_values = new java.util.HashMap(4);
   if (memberFields_String_values.containsKey(_parameters)) {
     return (SimpleSet) memberFields_String_values.get(_parameters);
   }
   ASTNode$State state = state();
   int num = state.boundariesCrossed;
   boolean isFinal = this.is$Final();
   SimpleSet memberFields_String_value = memberFields_compute(name);
   if (isFinal && num == state().boundariesCrossed)
     memberFields_String_values.put(_parameters, memberFields_String_value);
   return memberFields_String_value;
 }
 /**
  * @attribute syn
  * @aspect DU
  * @declaredat /home/uoji/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:864
  */
 @SuppressWarnings({"unchecked", "cast"})
 public boolean isDUafter(Variable v) {
   Object _parameters = v;
   if (isDUafter_Variable_values == null) isDUafter_Variable_values = new java.util.HashMap(4);
   if (isDUafter_Variable_values.containsKey(_parameters)) {
     return ((Boolean) isDUafter_Variable_values.get(_parameters)).booleanValue();
   }
   ASTNode$State state = state();
   int num = state.boundariesCrossed;
   boolean isFinal = this.is$Final();
   boolean isDUafter_Variable_value = isDUafter_compute(v);
   if (isFinal && num == state().boundariesCrossed)
     isDUafter_Variable_values.put(_parameters, Boolean.valueOf(isDUafter_Variable_value));
   return isDUafter_Variable_value;
 }
Exemple #5
0
 // Declared in DefiniteAssignment.jrag at line 982
 @SuppressWarnings({"unchecked", "cast"})
 public boolean isDAafterReachedFinallyBlocks(Variable v) {
   Object _parameters = v;
   if (isDAafterReachedFinallyBlocks_Variable_values == null)
     isDAafterReachedFinallyBlocks_Variable_values = new java.util.HashMap(4);
   if (isDAafterReachedFinallyBlocks_Variable_values.containsKey(_parameters))
     return ((Boolean) isDAafterReachedFinallyBlocks_Variable_values.get(_parameters))
         .booleanValue();
   int num = boundariesCrossed;
   boolean isFinal = this.is$Final();
   boolean isDAafterReachedFinallyBlocks_Variable_value = isDAafterReachedFinallyBlocks_compute(v);
   if (isFinal && num == boundariesCrossed)
     isDAafterReachedFinallyBlocks_Variable_values.put(
         _parameters, Boolean.valueOf(isDAafterReachedFinallyBlocks_Variable_value));
   return isDAafterReachedFinallyBlocks_Variable_value;
 }
 /**
  * @attribute syn
  * @aspect AncestorMethods
  * @declaredat /home/uoji/JastAddJ/Java1.4Frontend/LookupMethod.jrag:403
  */
 @SuppressWarnings({"unchecked", "cast"})
 public SimpleSet ancestorMethods(String signature) {
   Object _parameters = signature;
   if (ancestorMethods_String_values == null)
     ancestorMethods_String_values = new java.util.HashMap(4);
   if (ancestorMethods_String_values.containsKey(_parameters)) {
     return (SimpleSet) ancestorMethods_String_values.get(_parameters);
   }
   ASTNode$State state = state();
   int num = state.boundariesCrossed;
   boolean isFinal = this.is$Final();
   SimpleSet ancestorMethods_String_value = ancestorMethods_compute(signature);
   if (isFinal && num == state().boundariesCrossed)
     ancestorMethods_String_values.put(_parameters, ancestorMethods_String_value);
   return ancestorMethods_String_value;
 }
Exemple #7
0
  private final void clearDataCache() {
    java.util.Iterator it = dataCache.values().iterator();

    while (it.hasNext()) {
      File f = (File) it.next();
      f.delete();
    }
  }
Exemple #8
0
 private void stor(int addr, int value) {
   if (addr == CO) {
     System.out.print((char) value);
     return;
   }
   if (addr == AU) {
     abuffer[apointer] = (byte) value;
     if (apointer < abuffer.length - 1) {
       apointer++;
     }
   }
   if (addr == XO) {
     if (xo.containsKey(m[XA])) {
       try {
         xo.get(m[XA]).write(value);
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
   }
   if (addr == XS) {
     try {
       if (value == X_CLOSE) {
         if (xi.containsKey(m[XA])) {
           xi.get(m[XA]).close();
         }
         if (xo.containsKey(m[XA])) {
           xo.get(m[XA]).close();
         }
         xi.remove(m[XA]);
         xo.remove(m[XA]);
       }
       if (value == X_OPEN_READ) {
         xi.put(xc, new PushbackInputStream(new FileInputStream(extractString(m[XA]))));
         m[XA] = xc++;
       }
       if (value == X_OPEN_WRITE) {
         xo.put(xc, new FileOutputStream(extractString(m[XA])));
         m[XA] = xc++;
       }
     } catch (IOException e) {
       m[XA] = -1;
     }
   }
   m[addr] = value;
 }
 /**
  * @attribute syn
  * @aspect TypeConversion
  * @declaredat /home/uoji/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:99
  */
 @SuppressWarnings({"unchecked", "cast"})
 public boolean castingConversionTo(TypeDecl type) {
   Object _parameters = type;
   if (castingConversionTo_TypeDecl_values == null)
     castingConversionTo_TypeDecl_values = new java.util.HashMap(4);
   if (castingConversionTo_TypeDecl_values.containsKey(_parameters)) {
     return ((Boolean) castingConversionTo_TypeDecl_values.get(_parameters)).booleanValue();
   }
   ASTNode$State state = state();
   int num = state.boundariesCrossed;
   boolean isFinal = this.is$Final();
   boolean castingConversionTo_TypeDecl_value = castingConversionTo_compute(type);
   if (isFinal && num == state().boundariesCrossed)
     castingConversionTo_TypeDecl_values.put(
         _parameters, Boolean.valueOf(castingConversionTo_TypeDecl_value));
   return castingConversionTo_TypeDecl_value;
 }
Exemple #10
0
 /**
  * @attribute inh
  * @aspect ExceptionHandling
  * @declaredat
  *     /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/ExceptionHandling.jrag:45
  */
 @SuppressWarnings({"unchecked", "cast"})
 public boolean handlesException(TypeDecl exceptionType) {
   Object _parameters = exceptionType;
   if (handlesException_TypeDecl_values == null)
     handlesException_TypeDecl_values = new java.util.HashMap(4);
   if (handlesException_TypeDecl_values.containsKey(_parameters)) {
     return ((Boolean) handlesException_TypeDecl_values.get(_parameters)).booleanValue();
   }
   ASTNode$State state = state();
   int num = state.boundariesCrossed;
   boolean isFinal = this.is$Final();
   boolean handlesException_TypeDecl_value =
       getParent().Define_boolean_handlesException(this, null, exceptionType);
   if (isFinal && num == state().boundariesCrossed)
     handlesException_TypeDecl_values.put(
         _parameters, Boolean.valueOf(handlesException_TypeDecl_value));
   return handlesException_TypeDecl_value;
 }
Exemple #11
0
  private final synchronized File getDataCacheFile(byte[] data) {
    try {
      java.security.MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
      digest.update(data);

      String key = bytesToHex(digest.digest());

      if (dataCache.containsKey(key)) return (File) dataCache.get(key);

      File f = new File(this.getCacheDir(), "bindata_" + key);
      f.delete();
      FileOutputStream os = new FileOutputStream(f);
      os.write(data, 0, data.length);
      dataCache.put(key, f);
      return f;
    } catch (Throwable e) {
    }

    return null;
  }
  public void init() {
    root = new Element("cdi");

    // add schema definitions
    root.setAttribute(
        "noNamespaceSchemaLocation", // NOI18N
        "http://openlcb.org/trunk/specs/schema/cdi.xsd", // NOI18N
        org.jdom2.Namespace.getNamespace(
            "xsi", // NOI18N
            "http://www.w3.org/2001/XMLSchema-instance")); // NOI18N

    doc = new Document(root);

    // no DOCTYPE defined; this is a schema-only format

    // add XSLT processing instruction
    // <?xml-stylesheet type="text/xsl"
    // href="http://openlcb.org/trunk/prototypes/xml/xslt/cdi.xsl"?>
    java.util.Map<String, String> m = new java.util.HashMap<String, String>();
    m.put("type", "text/xsl");
    m.put("href", "http://openlcb.org/trunk/prototypes/xml/xslt/cdi.xsl");
    ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m);
    doc.addContent(0, p);
  }
 /**
  * @attribute syn
  * @aspect GenericsSubtype
  * @declaredat
  *     /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:212
  */
 @SuppressWarnings({"unchecked", "cast"})
 public boolean sameStructure(TypeDecl t) {
   Object _parameters = t;
   if (sameStructure_TypeDecl_values == null)
     sameStructure_TypeDecl_values = new java.util.HashMap(4);
   ASTNode$State.CircularValue _value;
   if (sameStructure_TypeDecl_values.containsKey(_parameters)) {
     Object _o = sameStructure_TypeDecl_values.get(_parameters);
     if (!(_o instanceof ASTNode$State.CircularValue)) {
       return ((Boolean) _o).booleanValue();
     } else _value = (ASTNode$State.CircularValue) _o;
   } else {
     _value = new ASTNode$State.CircularValue();
     sameStructure_TypeDecl_values.put(_parameters, _value);
     _value.value = Boolean.valueOf(true);
   }
   ASTNode$State state = state();
   if (!state.IN_CIRCLE) {
     state.IN_CIRCLE = true;
     int num = state.boundariesCrossed;
     boolean isFinal = this.is$Final();
     boolean new_sameStructure_TypeDecl_value;
     do {
       _value.visited = new Integer(state.CIRCLE_INDEX);
       state.CHANGE = false;
       new_sameStructure_TypeDecl_value = sameStructure_compute(t);
       if (new_sameStructure_TypeDecl_value != ((Boolean) _value.value).booleanValue()) {
         state.CHANGE = true;
         _value.value = Boolean.valueOf(new_sameStructure_TypeDecl_value);
       }
       state.CIRCLE_INDEX++;
     } while (state.CHANGE);
     if (isFinal && num == state().boundariesCrossed) {
       sameStructure_TypeDecl_values.put(_parameters, new_sameStructure_TypeDecl_value);
     } else {
       sameStructure_TypeDecl_values.remove(_parameters);
       state.RESET_CYCLE = true;
       sameStructure_compute(t);
       state.RESET_CYCLE = false;
     }
     state.IN_CIRCLE = false;
     return new_sameStructure_TypeDecl_value;
   }
   if (!new Integer(state.CIRCLE_INDEX).equals(_value.visited)) {
     _value.visited = new Integer(state.CIRCLE_INDEX);
     boolean new_sameStructure_TypeDecl_value = sameStructure_compute(t);
     if (state.RESET_CYCLE) {
       sameStructure_TypeDecl_values.remove(_parameters);
     } else if (new_sameStructure_TypeDecl_value != ((Boolean) _value.value).booleanValue()) {
       state.CHANGE = true;
       _value.value = new_sameStructure_TypeDecl_value;
     }
     return new_sameStructure_TypeDecl_value;
   }
   return ((Boolean) _value.value).booleanValue();
 }
 @SuppressWarnings("unchecked")
 public void setRenderArgs(java.util.Map<String, Object> args) {
   if (null != args && args.containsKey("type")) this.type = (String) args.get("type");
   if (null != args && args.containsKey("flash"))
     this.flash = (play.mvc.Scope.Flash) args.get("flash");
   if (null != args && args.containsKey("error_index"))
     this.error_index = (Integer) args.get("error_index");
   if (null != args && args.containsKey("error"))
     this.error = (play.data.validation.Error) args.get("error");
   if (null != args && args.containsKey("params"))
     this.params = (play.mvc.Scope.Params) args.get("params");
   if (null != args && args.containsKey("lang")) this.lang = (java.lang.String) args.get("lang");
   if (null != args && args.containsKey("messages"))
     this.messages = (play.i18n.Messages) args.get("messages");
   if (null != args && args.containsKey("error_isFirst"))
     this.error_isFirst = (Boolean) args.get("error_isFirst");
   if (null != args && args.containsKey("errors"))
     this.errors = (java.util.List<play.data.validation.Error>) args.get("errors");
   if (null != args && args.containsKey("error_isLast"))
     this.error_isLast = (Boolean) args.get("error_isLast");
   if (null != args && args.containsKey("session"))
     this.session = (play.mvc.Scope.Session) args.get("session");
   if (null != args && args.containsKey("request"))
     this.request = (play.mvc.Http.Request) args.get("request");
   if (null != args && args.containsKey("_rythmPlugin"))
     this._rythmPlugin = (com.greenlaw110.rythm.play.RythmPlugin) args.get("_rythmPlugin");
   if (null != args && args.containsKey("_response_encoding"))
     this._response_encoding = (java.lang.String) args.get("_response_encoding");
   if (null != args && args.containsKey("_renderArgs"))
     this._renderArgs = (play.mvc.Scope.RenderArgs) args.get("_renderArgs");
   if (null != args && args.containsKey("_rythm"))
     this._rythm = (com.greenlaw110.rythm.RythmEngine) args.get("_rythm");
   if (null != args && args.containsKey("error_parity"))
     this.error_parity = (java.lang.String) args.get("error_parity");
   if (null != args && args.containsKey("_play")) this._play = (play.Play) args.get("_play");
   super.setRenderArgs(args);
 }
 static {
   _jspx_dependants = new java.util.HashMap<java.lang.String, java.lang.Long>(1);
   _jspx_dependants.put("/generic/../head.inc", Long.valueOf(1406205714000L));
 }
Exemple #16
0
 @SuppressWarnings({"unchecked", "cast"})
 public boolean subtype(TypeDecl type) {
   Object _parameters = type;
   if (subtype_TypeDecl_visited == null) subtype_TypeDecl_visited = new java.util.HashMap(4);
   if (subtype_TypeDecl_values == null) subtype_TypeDecl_values = new java.util.HashMap(4);
   if (subtype_TypeDecl_computed.contains(_parameters))
     return ((Boolean) subtype_TypeDecl_values.get(_parameters)).booleanValue();
   if (!subtype_TypeDecl_initialized.contains(_parameters)) {
     subtype_TypeDecl_initialized.add(_parameters);
     subtype_TypeDecl_values.put(_parameters, Boolean.valueOf(true));
   }
   if (!IN_CIRCLE) {
     IN_CIRCLE = true;
     int num = boundariesCrossed;
     boolean isFinal = this.is$Final();
     CIRCLE_INDEX = 1;
     boolean new_subtype_TypeDecl_value;
     do {
       subtype_TypeDecl_visited.put(_parameters, new Integer(CIRCLE_INDEX));
       CHANGE = false;
       new_subtype_TypeDecl_value = subtype_compute(type);
       if (new_subtype_TypeDecl_value
           != ((Boolean) subtype_TypeDecl_values.get(_parameters)).booleanValue()) CHANGE = true;
       subtype_TypeDecl_values.put(_parameters, Boolean.valueOf(new_subtype_TypeDecl_value));
       CIRCLE_INDEX++;
     } while (CHANGE);
     if (isFinal && num == boundariesCrossed) {
       subtype_TypeDecl_computed.add(_parameters);
     } else {
       RESET_CYCLE = true;
       subtype_compute(type);
       RESET_CYCLE = false;
       subtype_TypeDecl_computed.remove(_parameters);
       subtype_TypeDecl_initialized.remove(_parameters);
     }
     IN_CIRCLE = false;
     return new_subtype_TypeDecl_value;
   }
   if (!new Integer(CIRCLE_INDEX).equals(subtype_TypeDecl_visited.get(_parameters))) {
     subtype_TypeDecl_visited.put(_parameters, new Integer(CIRCLE_INDEX));
     if (RESET_CYCLE) {
       subtype_TypeDecl_computed.remove(_parameters);
       subtype_TypeDecl_initialized.remove(_parameters);
       return ((Boolean) subtype_TypeDecl_values.get(_parameters)).booleanValue();
     }
     boolean new_subtype_TypeDecl_value = subtype_compute(type);
     if (new_subtype_TypeDecl_value
         != ((Boolean) subtype_TypeDecl_values.get(_parameters)).booleanValue()) CHANGE = true;
     subtype_TypeDecl_values.put(_parameters, Boolean.valueOf(new_subtype_TypeDecl_value));
     return new_subtype_TypeDecl_value;
   }
   return ((Boolean) subtype_TypeDecl_values.get(_parameters)).booleanValue();
 }
Exemple #17
0
  /**
   * Interface definition for implementation classes that listen for events from the SageTV core
   *
   * <p>Variable types are in brackets[] after the var name unless they are the same as the var name
   * itself. List of known core events:
   *
   * <p>MediaFileImported - vars: MediaFile ImportingStarted ImportingCompleted RecordingCompleted
   * (called when a complete recording is done) vars: MediaFile RecordingStarted (called when any
   * kind of recording is started) vars: MediaFile RecordingStopped (called whenever a recording is
   * stopped for any reason) vars: MediaFile AllPluginsLoaded RecordingScheduleChanged
   * ConflictStatusChanged SystemMessagePosted vars: SystemMessage EPGUpdateCompleted
   * MediaFileRemoved vars: MediaFile PlaybackStopped (called when the file is closed) vars:
   * MediaFile, UIContext[String], Duration[Long], MediaTime[Long], ChapterNum[Integer],
   * TitleNum[Integer] PlaybackFinished (called at the EOF) vars: MediaFile, UIContext[String],
   * Duration[Long], MediaTime[Long], ChapterNum[Integer], TitleNum[Integer] PlaybackStarted vars:
   * MediaFile, UIContext[String], Duration[Long], MediaTime[Long], ChapterNum[Integer],
   * TitleNum[Integer] FavoriteAdded vars: Favorite FavoriteModified vars: Favorite FavoriteRemoved
   * vars: Favorite PlaylistAdded vars: Playlist, UIContext[String] PlaylistModified vars: Playlist,
   * UIContext[String] PlaylistRemoved vars: Playlist, UIContext[String] ClientConnected vars:
   * IPAddress[String], MACAddress[String] (if its a placeshifter/extender, MACAddress is null
   * otherwise) ClientDisconnected vars: IPAddress[String], MACAddress[String] (if its a
   * placeshifter/extender, MACAddress is null otherwise)
   *
   * <p>This is a callback method invoked from the SageTV core for any events the listener has
   * subscribed to. See the sage.SageTVPluginRegistry interface definition for details regarding
   * subscribing and unsubscribing to events. The eventName will be a predefined String which
   * indicates the event type. The eventVars will be a Map of variables specific to the event
   * information. This Map should NOT be modified. The keys to the eventVars Map will generally be
   * Strings; but this may change in the future and plugins that submit events are not required to
   * follow that rule.
   */
  @Override
  public synchronized void sageEvent(String eventName, java.util.Map eventVars) {

    Log.getInstance().write(Log.LOGLEVEL_TRACE, "sageEvent: Event received = " + eventName);

    // Check that we have the right event.
    if (!(eventName.startsWith("RecordingCompleted") || eventName.startsWith("RecordingStopped"))) {
      Log.getInstance()
          .write(Log.LOGLEVEL_WARN, "sageEvent: Unexpected event received = " + eventName);
      return;
    }

    // Check that we have a valid MediaFile.
    Object MediaFile = eventVars.get("MediaFile");

    if (MediaFile == null) {
      Log.getInstance().write(Log.LOGLEVEL_WARN, "sageEvent: null MediaFile");
      return;
    }

    Log.getInstance()
        .write(
            Log.LOGLEVEL_TRACE,
            "sageEvent: Finished recording "
                + AiringAPI.GetAiringTitle(MediaFile)
                + " - "
                + ShowAPI.GetShowEpisode(MediaFile));

    // If it's a Manual, Favorite, or TimedRecord (manual) we do not need to worry about it.
    if (AiringAPI.IsFavorite(MediaFile) || AiringAPI.IsManualRecord(MediaFile)) {
      Log.getInstance().write(Log.LOGLEVEL_TRACE, "sageEvent: Is not an Intelligent Recording.");
      return;
    }

    // Create the DataStore which will allow us to access the data for this MediaFile.
    DataStore store = new DataStore(MediaFile);

    int maxToKeep;

    // If it's monitored keep the number specified. If it's not monitored use the
    // global default.
    if (store.isMonitored()) {
      Log.getInstance().write(Log.LOGLEVEL_TRACE, "sageEvent: Using max for this show.");
      maxToKeep = store.getMax();
    } else {
      Log.getInstance().write(Log.LOGLEVEL_TRACE, "sageEvent: Using global max.");
      maxToKeep = Util.GetIntProperty(PROPERTY_DEFAULT_MAX, DEFAULT_MAX_STRING);
    }

    Log.getInstance()
        .write(
            Log.LOGLEVEL_TRACE,
            "sageEvent: Max to keep = " + (maxToKeep == DEFAULT_MAX ? "unlimited" : maxToKeep));

    // See how many are already recorded.
    int numberRecorded = Util.getNumberRecorded(MediaFile);
    Log.getInstance()
        .write(Log.LOGLEVEL_TRACE, "sageEvent: Number already recorded = " + numberRecorded);

    // If it's unlimited or below the threshhold don't worry about it.
    if (maxToKeep == UNLIMITED || numberRecorded <= maxToKeep) {
      Log.getInstance().write(Log.LOGLEVEL_TRACE, "sageEvent: Below threshhold.");
      return;
    }

    Log.getInstance()
        .write(
            Log.LOGLEVEL_TRACE,
            "sageEvent: Threshhold exceeded. Deleting one or more "
                + AiringAPI.GetAiringTitle(MediaFile));

    // Get the direction to sort.
    boolean keepOldest =
        Configuration.GetServerProperty(PROPERTY_KEEP_OLDEST, "true").equalsIgnoreCase("true");
    Log.getInstance().write(Log.LOGLEVEL_TRACE, "sageEvent: Keep oldest = " + keepOldest);

    // Get all of the recordings in the proper order. Recordings at the beginning of the
    // List will be deleted first.
    List<Object> allRecorded = Util.getAllRecorded(MediaFile, "GetAiringStartTime", keepOldest);

    Log.getInstance()
        .write(Log.LOGLEVEL_TRACE, "sageEvent: Sorted list size = " + allRecorded.size());

    if (Log.getInstance().GetLogLevel() <= Log.LOGLEVEL_VERBOSE) {
      for (Object MF : allRecorded)
        Log.getInstance()
            .write(
                Log.LOGLEVEL_VERBOSE,
                "sageEvent: Date recorded = "
                    + Utility.PrintDateLong(AiringAPI.GetAiringStartTime(MF))
                    + " : "
                    + Utility.PrintTimeLong(AiringAPI.GetAiringStartTime(MF))
                    + " - "
                    + AiringAPI.GetAiringTitle(MF)
                    + " - "
                    + ShowAPI.GetShowEpisode(MF));
    }

    boolean reduceToMax =
        Configuration.GetServerProperty(PROPERTY_REDUCE_TO_MAX, "false").equalsIgnoreCase("true");

    // Calculate how many to delete.
    int numberToDelete = (reduceToMax ? numberRecorded - maxToKeep : 1);

    Log.getInstance().write(Log.LOGLEVEL_TRACE, "sageEvent: Need to delete " + numberToDelete);

    // Sanity check.
    if (allRecorded == null || allRecorded.size() < numberToDelete || numberToDelete < 1) {
      Log.getInstance()
          .write(
              Log.LOGLEVEL_WARN,
              "sageEvent: Internal error. numberToDelete exceeds allRecorded. Deleting this MediaFile.");
      MediaFileAPI.DeleteFile(MediaFile);
      return;
    }

    for (int i = 0; i < numberToDelete; i++) {
      Object MF = allRecorded.get(i);

      // Log.getInstance().write(Log.LOGLEVEL_TRACE, "sageEvent: TESTMODE. Would have deleted " +
      // AiringAPI.GetAiringTitle(MF) + " - " + ShowAPI.GetShowEpisode(MF));
      if (MediaFileAPI.DeleteFile(MF))
        Log.getInstance()
            .write(
                Log.LOGLEVEL_TRACE,
                "sageEvent: Deleted "
                    + AiringAPI.GetAiringTitle(MF)
                    + " - "
                    + ShowAPI.GetShowEpisode(MF));
      else
        Log.getInstance()
            .write(
                Log.LOGLEVEL_WARN,
                "sageEvent: Failed to delete "
                    + AiringAPI.GetAiringTitle(MF)
                    + " - "
                    + ShowAPI.GetShowEpisode(MF));
    }
  }