Permalink
Browse files

upgraded to Java 8

  • Loading branch information...
scholnicks
scholnicks committed May 25, 2015
1 parent 6484d6f commit c19dd4b5f63c3feaa74fa00adda24d9e6242f6e1
View
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/Users/steve/development/java/library/commons-lang-2.5.jar"/>
<classpathentry kind="lib" path="/Users/steve/development/java/library/jackson-annotations.jar"/>
<classpathentry kind="lib" path="/Users/steve/development/java/library/jackson-core.jar"/>
<classpathentry kind="lib" path="/Users/steve/development/java/library/jackson-databind.jar"/>
<classpathentry kind="lib" path="/Users/steve/development/java/library/log4j-1.2.16.jar"/>
<classpathentry kind="lib" path="/Users/steve/development/java/library/jackson/jackson-annotations.jar"/>
<classpathentry kind="lib" path="/Users/steve/development/java/library/jackson/jackson-core.jar"/>
<classpathentry kind="lib" path="/Users/steve/development/java/library/jackson/jackson-databind.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
@@ -2,7 +2,7 @@
<project name="isbndb" default="jar" basedir=".">
<property name="app.name" value="isbndb" />
<property name="version" value="1.0.1" />
<property name="version" value="1.0.2" />
<property name="source.dir" value="src" />
<property name="class.dir" value="target" />
<property name="doc.dir" value="api-doc" />
@@ -24,7 +24,7 @@
</path>
<target name="compile" depends="clean,init" description="compiles isbndb">
<javac destdir="${class.dir}" srcdir="${source.dir}" target="1.6" source="1.6"
<javac destdir="${class.dir}" srcdir="${source.dir}" target="1.8" source="1.8"
includeantruntime="false" verbose="false" classpathref="class.path" />
</target>
@@ -3,7 +3,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -23,7 +22,7 @@
* BooksProxy handles all interactions with the isbndb.com REST API. Queries to isbndb are spaced out by waitInterval,
* which defaults to 1 second.
*
* @author Steve Scholnick <steve@scholnick.net>
* @author Steve Scholnick <scholnicks@gmail.com>
*/
public final class BooksProxy {
private static final Logger log = Logger.getLogger(BooksProxy.class);
@@ -93,19 +92,7 @@ public void setWaitInterval(int waitInterval) {
uri = new URI("http","isbndb.com","/api/v2/json/" + developerKey + "/books", "q=" + key + "&i=" + searchField,null);
return parse( uri.toURL() );
}
catch (URISyntaxException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (JsonParseException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (JsonMappingException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (MalformedURLException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (IOException e) {
catch (URISyntaxException | IOException e) {
throw new RESTException("Unable to parse JSON",e);
}
}
@@ -126,19 +113,7 @@ public void setWaitInterval(int waitInterval) {
log.debug("Getting JSON from " + uri);
return parse( uri.toURL() );
}
catch (URISyntaxException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (JsonParseException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (JsonMappingException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (MalformedURLException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (IOException e) {
catch (URISyntaxException | IOException e) {
throw new RESTException("Unable to parse JSON",e);
}
}
@@ -158,19 +133,7 @@ public Book getBookByISBN(String isbn) {
List<Book> results = parse( uri.toURL() );
return results.isEmpty() ? null : results.get(0);
}
catch (URISyntaxException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (JsonParseException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (JsonMappingException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (MalformedURLException e) {
throw new RESTException("Unable to parse JSON",e);
}
catch (IOException e) {
catch (URISyntaxException | IOException e) {
throw new RESTException("Unable to parse JSON",e);
}
}
@@ -221,17 +184,9 @@ private void loadProperties() {
huc.setRequestMethod("GET");
huc.connect();
InputStream is = null;
try {
is = huc.getInputStream();
try (InputStream is = huc.getInputStream()){
return mapper.readValue(is,BooksResult.class).getData();
}
finally {
if (is != null) {
try { is.close(); } catch (IOException e) { /* ignore */ }
}
}
}
/** Checks for the last accessed time. And if it is less than the wait interval, the wait interval is slept */
@@ -11,9 +11,9 @@
/**
* BooksResult holds all of the data returned by the REST call
*
* @author Steve Scholnick <steve@scholnick.net>
* @author Steve Scholnick <scholnicks@gmail.com>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonIgnoreProperties(ignoreUnknown=true)
final class BooksResult {
private List<Book> data;
@@ -3,7 +3,7 @@
/**
* RESTException can be thrown by any {@link BooksProxy} method that performs a REST call.
*
* @author Steve Scholnick <steve@scholnick.net>
* @author Steve Scholnick <scholnicks@gmail.com>
*/
public final class RESTException extends RuntimeException {
private static final long serialVersionUID = 6746233809715504263L;
@@ -5,7 +5,7 @@
/**
* Author of a book
*
* @author Steve Scholnick <steve@scholnick.net>
* @author Steve Scholnick <scholnicks@gmail.com>
*/
public final class Author {
private String id;
@@ -10,7 +10,7 @@
/**
* Book is a single instance of book data
*
* @author Steve Scholnick <steve@scholnick.net>
* @author Steve Scholnick <scholnicks@gmail.com>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public final class Book {

0 comments on commit c19dd4b

Please sign in to comment.