1 package org.apache.archiva.repository.content;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
23 * Represents a artifact of a repository. This object contains unique coordinates of the
24 * artifact. A artifact has exactly one file representation in the repository.
25 * The artifact instance does not tell, if the file exists or is readable. It just
26 * keeps the coordinates and some meta information of the artifact.
28 * Artifact implementations should be immutable. The implementation must not always represent the current state of the
29 * corresponding storage asset (file). It is just a view of the attributes for a given point in time.
31 * Implementations must provide proper hash and equals methods.
33 * @author Martin Stockhammer <martin_s@apache.org>
35 public interface Artifact extends ContentItem
39 * The artifact identifier. The ID is unique in a given namespace of a given repository.
40 * But there may exist artifacts with the same ID but different types, classifiers or extensions.
42 * Never returns <code>null</code> or a empty string.
44 * @return the identifier of the artifact. Never returns <code>null</code> or empty string
49 * The version string of the artifact. The version string is exactly the version that is attached
51 * The version string may be different to the version string returned by the attached {@link Version} object.
52 * E.g for maven artifacts the artifact version may be 1.3-20070725.210059-1 and the attached {@link Version} object
53 * has version 1.3-SNAPSHOT.
55 * @return the artifact version string
58 String getArtifactVersion( );
61 * Returns the attached version this artifact is part of.
63 * @return the version object
65 Version getVersion( );
68 * Returns the type of the artifact. The type is some hint about the usage of the artifact.
69 * Implementations may always return a empty string, if it is not used.
71 * @return the type of the artifact. Returns never <code>null</code>, but may be empty string
76 * A classifier that distinguishes artifacts.
77 * Implementations may always return a empty string, if it is not used.
79 * @return the classifier of the artifact. Returns never <code>null</code>, but may be empty string
81 String getClassifier( );
84 * Short cut for the file name. Should always return the same value as the artifact name.
86 * @return the name of the file
88 default String getFileName( )
90 return getAsset( ).getName( );
94 * Returns the extension of the file. This method should always return the extension string after the last
97 * @return the file name extension
99 default String getExtension( )
101 final String name = getAsset( ).getName( );
102 final int idx = name.lastIndexOf( '.' );
105 return name.substring( idx );
114 * This may be different from extension and gives the remainder that is used to build the file path from
115 * the artifact coordinates (namespace, id, version, classifier, type)
117 * @return the file name remainder
119 String getRemainder( );
122 * Should return the mime type of the artifact.
124 * @return the mime type of the artifact.
126 String getContentType( );
129 * Returns the type of the artifact
132 ArtifactType getArtifactType();