Class TransferEvent
java.lang.Object
org.apache.ivy.core.event.IvyEvent
org.apache.ivy.plugins.repository.TransferEvent
TransferEvent is used to notify TransferListeners about progress in transfer of resources form/to
the repository This class is LARGELY inspired by org.apache.maven.wagon.events.TransferEvent
released under the following copyright license:
Copyright 2001-2005 The Apache Software Foundation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Original class written by Michal Maczka.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates GET transfer (from the repository)static final intIndicates PUT transfer (to the repository)static final intA transfer is completed.static final Stringstatic final intAn error occurred during transferstatic final Stringstatic final intA transfer was attempted, but has not yet commenced.static final Stringstatic final intA transfer is in progress.static final Stringstatic final intA transfer was started.static final String -
Constructor Summary
ConstructorsConstructorDescriptionTransferEvent(Repository repository, Resource resource, int eventType, int requestType) TransferEvent(Repository repository, Resource resource, long length, int requestType) TransferEvent(Repository repository, Resource resource, Exception exception, int requestType) -
Method Summary
Modifier and TypeMethodDescriptionlonggetElapsedTime(int fromEventType, int toEventType) Returns the elapsed time (in ms) between when the event entered one type until it entered another event time.intlongintReturns the request type.longbooleanprotected voidsetEventType(int eventType) voidsetException(Exception exception) protected voidsetLength(long length) protected voidsetLocalFile(File localFile) protected voidsetRequestType(int requestType) Sets the request typeprotected voidsetResource(Resource resource) protected voidsetTotalLength(long totalLength) voidsetTotalLengthSet(boolean isTotalLengthSet) Methods inherited from class IvyEvent
addAttribute, addAttributes, addConfsAttribute, addMDAttributes, addModuleIdAttributes, addMridAttributes, equals, getAttributes, getName, getSource, hashCode, toString
-
Field Details
-
TRANSFER_INITIATED
public static final int TRANSFER_INITIATEDA transfer was attempted, but has not yet commenced.- See Also:
-
TRANSFER_STARTED
public static final int TRANSFER_STARTEDA transfer was started.- See Also:
-
TRANSFER_COMPLETED
public static final int TRANSFER_COMPLETEDA transfer is completed.- See Also:
-
TRANSFER_PROGRESS
public static final int TRANSFER_PROGRESSA transfer is in progress.- See Also:
-
TRANSFER_ERROR
public static final int TRANSFER_ERRORAn error occurred during transfer- See Also:
-
REQUEST_GET
public static final int REQUEST_GETIndicates GET transfer (from the repository)- See Also:
-
REQUEST_PUT
public static final int REQUEST_PUTIndicates PUT transfer (to the repository)- See Also:
-
TRANSFER_INITIATED_NAME
- See Also:
-
TRANSFER_STARTED_NAME
- See Also:
-
TRANSFER_PROGRESS_NAME
- See Also:
-
TRANSFER_COMPLETED_NAME
- See Also:
-
TRANSFER_ERROR_NAME
- See Also:
-
-
Constructor Details
-
TransferEvent
-
TransferEvent
public TransferEvent(Repository repository, Resource resource, Exception exception, int requestType) -
TransferEvent
-
-
Method Details
-
getResource
- Returns:
- Returns the resource.
-
getException
- Returns:
- Returns the exception.
-
getRequestType
public int getRequestType()Returns the request type.- Returns:
- Returns the request type. The Request type is one of TransferEvent.REQUEST_GET or TransferEvent.REQUEST_PUT
-
setRequestType
protected void setRequestType(int requestType) Sets the request type- Parameters:
requestType- The requestType to set. The Request type value should be either TransferEvent.REQUEST_GET or TransferEvent.REQUEST_PUT- Throws:
IllegalArgumentException- when
-
getEventType
public int getEventType()- Returns:
- Returns the eventType.
-
setEventType
protected void setEventType(int eventType) - Parameters:
eventType- The eventType to set.
-
setResource
- Parameters:
resource- The resource to set.
-
getLocalFile
- Returns:
- Returns the local file.
-
setLocalFile
- Parameters:
localFile- The local file to set.
-
getLength
public long getLength() -
setLength
protected void setLength(long length) -
getTotalLength
public long getTotalLength() -
setTotalLength
protected void setTotalLength(long totalLength) -
setException
-
isTotalLengthSet
public boolean isTotalLengthSet() -
setTotalLengthSet
public void setTotalLengthSet(boolean isTotalLengthSet) -
getRepository
-
getElapsedTime
public long getElapsedTime(int fromEventType, int toEventType) Returns the elapsed time (in ms) between when the event entered one type until it entered another event time.This is especially useful to get the elapsed transfer time:
getElapsedTime(TransferEvent.TRANSFER_STARTED, TransferEvent.TRANSFER_COMPLETED);
Special cases:
- returns -1 if the event never entered the fromEventType or the toEventType.
- returns 0 if the event entered toEventType before fromEventType
- Parameters:
fromEventType- the event type constant from which time should be measuredtoEventType- the event type constant to which time should be measured- Returns:
- the elapsed time (in ms) between when the event entered fromEventType until it entered toEventType.
- Throws:
IllegalArgumentException- if either type is not a known constant event type.
-