| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Versioning |
|
| 1.3125;1.312 |
| 1 | /* | |
| 2 | * $Id$ | |
| 3 | */ | |
| 4 | ||
| 5 | package org.apache.maven.artifact.repository.metadata; | |
| 6 | ||
| 7 | //---------------------------------/ | |
| 8 | //- Imported classes and packages -/ | |
| 9 | //---------------------------------/ | |
| 10 | ||
| 11 | import java.util.Date; | |
| 12 | ||
| 13 | /** | |
| 14 | * Versioning information for an artifact. | |
| 15 | * | |
| 16 | * @version $Revision$ $Date$ | |
| 17 | */ | |
| 18 | 0 | public class Versioning implements java.io.Serializable { |
| 19 | ||
| 20 | ||
| 21 | //--------------------------/ | |
| 22 | //- Class/Member Variables -/ | |
| 23 | //--------------------------/ | |
| 24 | ||
| 25 | /** | |
| 26 | * What the latest version in the directory is, including | |
| 27 | * snapshots. | |
| 28 | */ | |
| 29 | private String latest; | |
| 30 | ||
| 31 | /** | |
| 32 | * What the latest version in the directory is, of the releases. | |
| 33 | */ | |
| 34 | private String release; | |
| 35 | ||
| 36 | /** | |
| 37 | * The current snapshot data in use for this version. | |
| 38 | */ | |
| 39 | private Snapshot snapshot; | |
| 40 | ||
| 41 | /** | |
| 42 | * Field versions. | |
| 43 | */ | |
| 44 | private java.util.List versions; | |
| 45 | ||
| 46 | /** | |
| 47 | * When the metadata was last updated. | |
| 48 | */ | |
| 49 | private String lastUpdated; | |
| 50 | ||
| 51 | ||
| 52 | //-----------/ | |
| 53 | //- Methods -/ | |
| 54 | //-----------/ | |
| 55 | ||
| 56 | /** | |
| 57 | * Method addVersion. | |
| 58 | * | |
| 59 | * @param string | |
| 60 | */ | |
| 61 | public void addVersion( String string ) | |
| 62 | { | |
| 63 | 0 | if ( !(string instanceof String) ) |
| 64 | { | |
| 65 | 0 | throw new ClassCastException( "Versioning.addVersions(string) parameter must be instanceof " + String.class.getName() ); |
| 66 | } | |
| 67 | 0 | getVersions().add( string ); |
| 68 | 0 | } //-- void addVersion( String ) |
| 69 | ||
| 70 | /** | |
| 71 | * Get when the metadata was last updated. | |
| 72 | * | |
| 73 | * @return String | |
| 74 | */ | |
| 75 | public String getLastUpdated() | |
| 76 | { | |
| 77 | 0 | return this.lastUpdated; |
| 78 | } //-- String getLastUpdated() | |
| 79 | ||
| 80 | /** | |
| 81 | * Get what the latest version in the directory is, including | |
| 82 | * snapshots. | |
| 83 | * | |
| 84 | * @return String | |
| 85 | */ | |
| 86 | public String getLatest() | |
| 87 | { | |
| 88 | 0 | return this.latest; |
| 89 | } //-- String getLatest() | |
| 90 | ||
| 91 | /** | |
| 92 | * Get what the latest version in the directory is, of the | |
| 93 | * releases. | |
| 94 | * | |
| 95 | * @return String | |
| 96 | */ | |
| 97 | public String getRelease() | |
| 98 | { | |
| 99 | 0 | return this.release; |
| 100 | } //-- String getRelease() | |
| 101 | ||
| 102 | /** | |
| 103 | * Get the current snapshot data in use for this version. | |
| 104 | * | |
| 105 | * @return Snapshot | |
| 106 | */ | |
| 107 | public Snapshot getSnapshot() | |
| 108 | { | |
| 109 | 0 | return this.snapshot; |
| 110 | } //-- Snapshot getSnapshot() | |
| 111 | ||
| 112 | /** | |
| 113 | * Method getVersions. | |
| 114 | * | |
| 115 | * @return java.util.List | |
| 116 | */ | |
| 117 | public java.util.List getVersions() | |
| 118 | { | |
| 119 | 0 | if ( this.versions == null ) |
| 120 | { | |
| 121 | 0 | this.versions = new java.util.ArrayList(); |
| 122 | } | |
| 123 | ||
| 124 | 0 | return this.versions; |
| 125 | } //-- java.util.List getVersions() | |
| 126 | ||
| 127 | /** | |
| 128 | * Method removeVersion. | |
| 129 | * | |
| 130 | * @param string | |
| 131 | */ | |
| 132 | public void removeVersion( String string ) | |
| 133 | { | |
| 134 | 0 | if ( !(string instanceof String) ) |
| 135 | { | |
| 136 | 0 | throw new ClassCastException( "Versioning.removeVersions(string) parameter must be instanceof " + String.class.getName() ); |
| 137 | } | |
| 138 | 0 | getVersions().remove( string ); |
| 139 | 0 | } //-- void removeVersion( String ) |
| 140 | ||
| 141 | /** | |
| 142 | * Set when the metadata was last updated. | |
| 143 | * | |
| 144 | * @param lastUpdated | |
| 145 | */ | |
| 146 | public void setLastUpdated( String lastUpdated ) | |
| 147 | { | |
| 148 | 0 | this.lastUpdated = lastUpdated; |
| 149 | 0 | } //-- void setLastUpdated( String ) |
| 150 | ||
| 151 | /** | |
| 152 | * Set what the latest version in the directory is, including | |
| 153 | * snapshots. | |
| 154 | * | |
| 155 | * @param latest | |
| 156 | */ | |
| 157 | public void setLatest( String latest ) | |
| 158 | { | |
| 159 | 0 | this.latest = latest; |
| 160 | 0 | } //-- void setLatest( String ) |
| 161 | ||
| 162 | /** | |
| 163 | * Set what the latest version in the directory is, of the | |
| 164 | * releases. | |
| 165 | * | |
| 166 | * @param release | |
| 167 | */ | |
| 168 | public void setRelease( String release ) | |
| 169 | { | |
| 170 | 0 | this.release = release; |
| 171 | 0 | } //-- void setRelease( String ) |
| 172 | ||
| 173 | /** | |
| 174 | * Set the current snapshot data in use for this version. | |
| 175 | * | |
| 176 | * @param snapshot | |
| 177 | */ | |
| 178 | public void setSnapshot( Snapshot snapshot ) | |
| 179 | { | |
| 180 | 0 | this.snapshot = snapshot; |
| 181 | 0 | } //-- void setSnapshot( Snapshot ) |
| 182 | ||
| 183 | /** | |
| 184 | * Set versions available for the artifact. | |
| 185 | * | |
| 186 | * @param versions | |
| 187 | */ | |
| 188 | public void setVersions( java.util.List versions ) | |
| 189 | { | |
| 190 | 0 | this.versions = versions; |
| 191 | 0 | } //-- void setVersions( java.util.List ) |
| 192 | ||
| 193 | ||
| 194 | public void updateTimestamp() | |
| 195 | { | |
| 196 | 0 | setLastUpdatedTimestamp( new java.util.Date() ); |
| 197 | 0 | } |
| 198 | ||
| 199 | public void setLastUpdatedTimestamp( java.util.Date date ) | |
| 200 | { | |
| 201 | 0 | java.util.TimeZone timezone = java.util.TimeZone.getTimeZone( "UTC" ); |
| 202 | 0 | java.text.DateFormat fmt = new java.text.SimpleDateFormat( "yyyyMMddHHmmss" ); |
| 203 | 0 | fmt.setTimeZone( timezone ); |
| 204 | 0 | setLastUpdated( fmt.format( date ) ); |
| 205 | 0 | } |
| 206 | ||
| 207 | 0 | private String modelEncoding = "UTF-8"; |
| 208 | ||
| 209 | /** | |
| 210 | * Set an encoding used for reading/writing the model. | |
| 211 | * | |
| 212 | * @param modelEncoding the encoding used when reading/writing the model. | |
| 213 | */ | |
| 214 | public void setModelEncoding( String modelEncoding ) | |
| 215 | { | |
| 216 | 0 | this.modelEncoding = modelEncoding; |
| 217 | 0 | } |
| 218 | ||
| 219 | /** | |
| 220 | * @return the current encoding used when reading/writing this model. | |
| 221 | */ | |
| 222 | public String getModelEncoding() | |
| 223 | { | |
| 224 | 0 | return modelEncoding; |
| 225 | } | |
| 226 | } |