This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.checksum;
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
022/**
023 * Status of checksum update for specific algorithm.
024 */
025public class UpdateStatus {
026
027    /**
028     * Checksum file did not exist before and was created
029     */
030    public static final int CREATED = 1;
031    /**
032     * Checksum file existed, but content differed
033     */
034    public static final int UPDATED = 2;
035    /**
036     * Nothing changed
037     */
038    public static final int NONE = 0;
039    /**
040     * Error occured during update/creation of the checksum file
041     */
042    public static final int ERROR = -1;
043
044    private final ChecksumAlgorithm algorithm;
045    private final int status;
046    private final Throwable error;
047
048    public UpdateStatus(ChecksumAlgorithm algorithm) {
049        this.algorithm = algorithm;
050        status = NONE;
051        error = null;
052    }
053
054    public UpdateStatus(ChecksumAlgorithm algorithm, int status) {
055        this.algorithm = algorithm;
056        this.status = status;
057        error = null;
058    }
059
060    public UpdateStatus(ChecksumAlgorithm algorithm, Throwable error) {
061        this.algorithm = algorithm;
062        this.status = ERROR;
063        this.error = error;
064    }
065
066    /**
067     * Return the status value.
068     * @return The value
069     */
070    public int getValue() {
071        return status;
072    }
073
074    /**
075     * Return error, if exists, otherwise <code>null</code> will be returned.
076     * @return
077     */
078    public Throwable getError() {
079        return error;
080    }
081
082    /**
083     * Return the algorithm, this status is assigned to.
084     * @return The checksum algorithm
085     */
086    public ChecksumAlgorithm getAlgorithm() {
087        return algorithm;
088    }
089}