001package org.eclipse.aether.spi.connector.transport;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 * 
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 * 
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.nio.ByteBuffer;
023
024import org.eclipse.aether.transfer.TransferCancelledException;
025
026/**
027 * A skeleton class for listeners used to monitor transport operations. Reusing common regular expression syntax, the
028 * sequence of events is generally as follows:
029 * 
030 * <pre>
031 * ( STARTED PROGRESSED* )*
032 * </pre>
033 * 
034 * The methods in this class do nothing.
035 */
036public abstract class TransportListener
037{
038
039    /**
040     * Enables subclassing.
041     */
042    protected TransportListener()
043    {
044    }
045
046    /**
047     * Notifies the listener about the start of the data transfer. This event may arise more than once if the transfer
048     * needs to be restarted (e.g. after an authentication failure).
049     * 
050     * @param dataOffset The byte offset in the resource at which the transfer starts, must not be negative.
051     * @param dataLength The total number of bytes in the resource or {@code -1} if the length is unknown.
052     * @throws TransferCancelledException If the transfer should be aborted.
053     */
054    public void transportStarted( long dataOffset, long dataLength )
055        throws TransferCancelledException
056    {
057    }
058
059    /**
060     * Notifies the listener about some progress in the data transfer. This event may even be fired if actually zero
061     * bytes have been transferred since the last event, for instance to enable cancellation.
062     * 
063     * @param data The (read-only) buffer holding the bytes that have just been tranferred, must not be {@code null}.
064     * @throws TransferCancelledException If the transfer should be aborted.
065     */
066    public void transportProgressed( ByteBuffer data )
067        throws TransferCancelledException
068    {
069    }
070
071}