001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.location;
020
021import java.util.EventObject;
022
023/**
024 * Instances of this class represent events occurring when performing I/O operations between
025 * {@link Location} instances.
026 * @see java.util.EventObject
027 * @author Laurent Cohen
028 */
029public class LocationEvent extends EventObject {
030  /**
031   * Explicit serialVersionUID.
032   */
033  private static final long serialVersionUID = 1L;
034  /**
035   * The number of bytes that were transferred to another location.
036   */
037  private long n = 0;
038
039  /**
040   * Initialize this event with its source location.
041   * @param source - the location on which the event is occurring.
042   * @param n - the number of bytes that were transferred to another location.
043   */
044  public LocationEvent(final Location<?> source, final long n) {
045    super(source);
046    this.n = n;
047  }
048
049  /**
050   * Get the number of bytes transferred during this event.
051   * @return the number of bytes as an int.
052   */
053  public long getTransferredBytes() {
054    return n;
055  }
056
057  /**
058   * Get the source location, on which the event occurred.
059   * @return the source as a <code>Location</code> instance.
060   */
061  public Location<?> getLocation() {
062    return (Location<?>) getSource();
063  }
064}