1 package org.apache.maven.repository.indexing.record;
7 * Copyright 2005-2006 The Apache Software Foundation.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * The a record with the fields in the minimal index.
25 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
27 public class MinimalArtifactIndexRecord
28 implements RepositoryIndexRecord
31 * The classes in the archive for the artifact, if it is a JAR.
36 * The MD5 checksum of the artifact file.
38 private String md5Checksum;
41 * The filename of the artifact file (no path).
43 private String filename;
46 * The timestamp that the artifact file was last modified. Granularity is seconds.
48 private long lastModified;
51 * The size of the artifact file in bytes.
55 private static final int MS_PER_SEC = 1000;
57 public void setClasses( List classes )
59 this.classes = classes;
62 public void setMd5Checksum( String md5Checksum )
64 this.md5Checksum = md5Checksum;
67 public void setFilename( String filename )
69 this.filename = filename;
72 public void setLastModified( long lastModified )
74 this.lastModified = lastModified - lastModified % MS_PER_SEC;
77 public void setSize( long size )
82 public List getClasses()
87 public String getMd5Checksum()
92 public String getFilename()
97 public long getLastModified()
102 public long getSize()
108 * @noinspection RedundantIfStatement
110 public boolean equals( Object obj )
116 if ( obj == null || getClass() != obj.getClass() )
121 MinimalArtifactIndexRecord that = (MinimalArtifactIndexRecord) obj;
123 if ( lastModified != that.lastModified )
127 if ( size != that.size )
131 if ( classes != null ? !classes.equals( that.classes ) : that.classes != null )
135 if ( !filename.equals( that.filename ) )
139 if ( md5Checksum != null ? !md5Checksum.equals( that.md5Checksum ) : that.md5Checksum != null )
148 * @noinspection UnnecessaryParentheses
150 public int hashCode()
152 int result = classes != null ? classes.hashCode() : 0;
153 result = 31 * result + ( md5Checksum != null ? md5Checksum.hashCode() : 0 );
154 result = 31 * result + filename.hashCode();
155 result = 31 * result + (int) ( lastModified ^ ( lastModified >>> 32 ) );
156 result = 31 * result + (int) ( size ^ ( size >>> 32 ) );
160 public String toString()
162 return "Filename: " + filename + "; checksum: " + md5Checksum + "; size: " + size + "; lastModified: " +
163 new Date( lastModified ) + "; classes: " + classes;
166 public String getPrimaryKey()