Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/bin/
/target/
/.classpath
/.project
/.settings/
30 changes: 20 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.commonjava.mimeparse</groupId>
<artifactId>mimeparse</artifactId>
<version>0.1.4-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>

<name>mimeparse</name>
<url>http://github.com/jdcasey/mimeparse/</url>
Expand Down Expand Up @@ -32,6 +32,13 @@
</licenses>

<developers>
<developer>
<name>Andrew Norman</name>
<id>normana400</id>
<roles>
<role>fork-maintainer</role>
</roles>
</developer>
<developer>
<name>John Casey</name>
<id>jdcasey</id>
Expand All @@ -51,11 +58,15 @@

<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
<scope>compile</scope>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.18.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -69,19 +80,18 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.14.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
<version>3.1.1</version>
<configuration>
<mavenExecutorId>forked-path</mavenExecutorId>
<useReleaseProfile>false</useReleaseProfile>
<arguments>-Prelease</arguments>
</configuration>
</plugin>
</plugins>
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/commonjava/mimeparse/MIMEParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.StringUtils;

/**
* MIME-Type Parser
Expand Down Expand Up @@ -251,8 +251,7 @@ public static String bestMatch(Collection<String> supported, String header)

FitnessAndQuality lastOne = weightedMatches
.get(weightedMatches.size() - 1);
return NumberUtils.compare(lastOne.quality, 0) != 0 ? lastOne.mimeType
: "";
return Float.compare(lastOne.quality, 0f) != 0 ? lastOne.mimeType : "";
}

// hidden
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/commonjava/mimeparse/MIMEParseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import junit.framework.TestCase;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

public class MIMEParseTest extends TestCase
{
Expand All @@ -24,10 +24,10 @@ public void testParseMediaRange()
.parseMediaRange("application/xml;q=").toString());
assertEquals("('application', 'xml', {'q':'1',})", MIMEParse
.parseMediaRange("application/xml ; q=").toString());
assertEquals("('application', 'xml', {'b':'other','q':'1',})",
assertEquals("('application', 'xml', {'q':'1','b':'other',})",
MIMEParse.parseMediaRange("application/xml ; q=1;b=other")
.toString());
assertEquals("('application', 'xml', {'b':'other','q':'1',})",
assertEquals("('application', 'xml', {'q':'1','b':'other',})",
MIMEParse.parseMediaRange("application/xml ; q=2;b=other")
.toString());
// Java URLConnection class sends an Accept header that includes a
Expand Down