Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
maven-artifact-3.8.6.jar - Maven Artifact Module
maven-artifact-3.8.6.jar is the JAR file for Apache Maven 3.8.6 Artifact module.
Apache Maven is a software project management and comprehension tool.
JAR File Size and Download Location:
File: 58076 06-06-2022 16:16 lib/maven-artifact-3.8.6.jar Download: Apache Maven Website
✍: FYIcenter.com
⏎ org/apache/maven/artifact/versioning/DefaultArtifactVersion.java
package org.apache.maven.artifact.versioning;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
*
* http://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.
*/
import java.util.StringTokenizer;
import static org.apache.commons.lang3.math.NumberUtils.isDigits;
/**
* Default implementation of artifact versioning.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
public class DefaultArtifactVersion
implements ArtifactVersion
{
private Integer majorVersion;
private Integer minorVersion;
private Integer incrementalVersion;
private Integer buildNumber;
private String qualifier;
private ComparableVersion comparable;
public DefaultArtifactVersion( String version )
{
parseVersion( version );
}
@Override
public int hashCode()
{
return 11 + comparable.hashCode();
}
@Override
public boolean equals( Object other )
{
if ( this == other )
{
return true;
}
if ( !( other instanceof ArtifactVersion ) )
{
return false;
}
return compareTo( (ArtifactVersion) other ) == 0;
}
public int compareTo( ArtifactVersion otherVersion )
{
if ( otherVersion instanceof DefaultArtifactVersion )
{
return this.comparable.compareTo( ( (DefaultArtifactVersion) otherVersion ).comparable );
}
else
{
return compareTo( new DefaultArtifactVersion( otherVersion.toString() ) );
}
}
public int getMajorVersion()
{
return majorVersion != null ? majorVersion : 0;
}
public int getMinorVersion()
{
return minorVersion != null ? minorVersion : 0;
}
public int getIncrementalVersion()
{
return incrementalVersion != null ? incrementalVersion : 0;
}
public int getBuildNumber()
{
return buildNumber != null ? buildNumber : 0;
}
public String getQualifier()
{
return qualifier;
}
public final void parseVersion( String version )
{
comparable = new ComparableVersion( version );
int index = version.indexOf( '-' );
String part1;
String part2 = null;
if ( index < 0 )
{
part1 = version;
}
else
{
part1 = version.substring( 0, index );
part2 = version.substring( index + 1 );
}
if ( part2 != null )
{
if ( part2.length() == 1 || !part2.startsWith( "0" ) )
{
buildNumber = tryParseInt( part2 );
if ( buildNumber == null )
{
qualifier = part2;
}
}
else
{
qualifier = part2;
}
}
if ( ( !part1.contains( "." ) ) && !part1.startsWith( "0" ) )
{
majorVersion = tryParseInt( part1 );
if ( majorVersion == null )
{
// qualifier is the whole version, including "-"
qualifier = version;
buildNumber = null;
}
}
else
{
boolean fallback = false;
StringTokenizer tok = new StringTokenizer( part1, "." );
if ( tok.hasMoreTokens() )
{
majorVersion = getNextIntegerToken( tok );
if ( majorVersion == null )
{
fallback = true;
}
}
else
{
fallback = true;
}
if ( tok.hasMoreTokens() )
{
minorVersion = getNextIntegerToken( tok );
if ( minorVersion == null )
{
fallback = true;
}
}
if ( tok.hasMoreTokens() )
{
incrementalVersion = getNextIntegerToken( tok );
if ( incrementalVersion == null )
{
fallback = true;
}
}
if ( tok.hasMoreTokens() )
{
qualifier = tok.nextToken();
fallback = isDigits( qualifier );
}
// string tokenizer won't detect these and ignores them
if ( part1.contains( ".." ) || part1.startsWith( "." ) || part1.endsWith( "." ) )
{
fallback = true;
}
if ( fallback )
{
// qualifier is the whole version, including "-"
qualifier = version;
majorVersion = null;
minorVersion = null;
incrementalVersion = null;
buildNumber = null;
}
}
}
private static Integer getNextIntegerToken( StringTokenizer tok )
{
String s = tok.nextToken();
if ( ( s.length() > 1 ) && s.startsWith( "0" ) )
{
return null;
}
return tryParseInt( s );
}
private static Integer tryParseInt( String s )
{
// for performance, check digits instead of relying later on catching NumberFormatException
if ( !isDigits( s ) )
{
return null;
}
try
{
long longValue = Long.parseLong( s );
if ( longValue > Integer.MAX_VALUE )
{
return null;
}
return (int) longValue;
}
catch ( NumberFormatException e )
{
// should never happen since checked isDigits(s) before
return null;
}
}
@Override
public String toString()
{
return comparable.toString();
}
}
⏎ org/apache/maven/artifact/versioning/DefaultArtifactVersion.java
Or download all of them as a single archive file:
File name: maven-artifact-3.8.6-src.zip File size: 47529 bytes Release date: 2022-06-06 Download
⇒ maven-builder-support-3.8.6.jar - Builder Support Module
⇐ maven-core-3.8.6.jar - Maven Core Module
2023-07-17, ≈10🔥, 5💬
Popular Posts:
Where to get the Java source code for Connector/J 8.0 User Impl module? Java source code files for C...
What Is jaxb-api-2.1.6.jar? Java Architecture for XML Binding (JAXB) is a Java API that allows Java ...
JDK 11 jdk.scripting.nashorn.jm odis the JMOD file for JDK 11 Scripting Nashorn module. JDK 11 Scrip...
JDK 17 java.compiler.jmod is the JMOD file for JDK 17 Compiler module. JDK 17 Compiler module compil...
Apache Commons Lang 3 is the 3rd version of Apache Commons Lang, which provides a host of helper uti...