Refactored some code

This commit is contained in:
Patrick Gotthard 2014-04-13 14:47:07 +02:00
parent 4b79f6c1d5
commit 9bf5a75e2c
4 changed files with 18 additions and 13 deletions

View file

@ -27,6 +27,7 @@ import com.sun.syndication.feed.module.Module;
* ROME Extension Module to Atom protocol extensions to Atom format. * ROME Extension Module to Atom protocol extensions to Atom format.
*/ */
public interface AppModule extends Module { public interface AppModule extends Module {
public static final String URI = "http://www.w3.org/2007/app"; public static final String URI = "http://www.w3.org/2007/app";
/** True if entry is a draft */ /** True if entry is a draft */

View file

@ -91,7 +91,7 @@ public interface AtomRequest {
* Returns an Enumeration of String objects containing the names of the parameters contained in * Returns an Enumeration of String objects containing the names of the parameters contained in
* this request. * this request.
*/ */
public Enumeration getParameterNames(); public Enumeration<String> getParameterNames();
/** /**
* Returns an array of String objects containing all of the values the given request parameter * Returns an array of String objects containing all of the values the given request parameter
@ -123,12 +123,12 @@ public interface AtomRequest {
/** /**
* Returns all the values of the specified request header as an Enumeration of String objects. * Returns all the values of the specified request header as an Enumeration of String objects.
*/ */
public Enumeration getHeaders(String arg0); public Enumeration<String> getHeaders(String arg0);
/** /**
* Returns an enumeration of all the header names this request contains. * Returns an enumeration of all the header names this request contains.
*/ */
public Enumeration getHeaderNames(); public Enumeration<String> getHeaderNames();
/** /**
* Returns the value of the specified request header as an int. * Returns the value of the specified request header as an int.

View file

@ -89,7 +89,8 @@ public class AtomRequestImpl implements AtomRequest {
} }
@Override @Override
public Enumeration getParameterNames() { @SuppressWarnings("unchecked")
public Enumeration<String> getParameterNames() {
return wrapped.getParameterNames(); return wrapped.getParameterNames();
} }
@ -99,6 +100,7 @@ public class AtomRequestImpl implements AtomRequest {
} }
@Override @Override
@SuppressWarnings("unchecked")
public Map<String, Object> getParameterMap() { public Map<String, Object> getParameterMap() {
return wrapped.getParameterMap(); return wrapped.getParameterMap();
} }
@ -119,12 +121,14 @@ public class AtomRequestImpl implements AtomRequest {
} }
@Override @Override
public Enumeration getHeaders(final String arg0) { @SuppressWarnings("unchecked")
public Enumeration<String> getHeaders(final String arg0) {
return wrapped.getHeaders(arg0); return wrapped.getHeaders(arg0);
} }
@Override @Override
public Enumeration getHeaderNames() { @SuppressWarnings("unchecked")
public Enumeration<String> getHeaderNames() {
return wrapped.getHeaderNames(); return wrapped.getHeaderNames();
} }

View file

@ -408,7 +408,7 @@ public class MetaWeblogBlog implements Blog {
private int pos = 0; private int pos = 0;
private boolean eod = false; private boolean eod = false;
private static final int BUFSIZE = 30; private static final int BUFSIZE = 30;
private List results = null; private List<Map<String, Object>> results = null;
/** /**
* Iterator for looping over MetaWeblog API entries. * Iterator for looping over MetaWeblog API entries.
@ -436,9 +436,7 @@ public class MetaWeblogBlog implements Blog {
*/ */
@Override @Override
public BlogEntry next() { public BlogEntry next() {
@SuppressWarnings("unchecked") return new MetaWeblogEntry(MetaWeblogBlog.this, results.get(pos++));
final Map<String, Object> entryHash = (Map<String, Object>) results.get(pos++);
return new MetaWeblogEntry(MetaWeblogBlog.this, entryHash);
} }
/** /**
@ -451,8 +449,10 @@ public class MetaWeblogBlog implements Blog {
private void getNextEntries() throws BlogClientException { private void getNextEntries() throws BlogClientException {
final int requestSize = pos + BUFSIZE; final int requestSize = pos + BUFSIZE;
try { try {
final Object[] resultsArray = (Object[]) getXmlRpcClient().execute("metaWeblog.getRecentPosts", final Object[] params = new Object[] { blogid, userName, password, new Integer(requestSize) };
new Object[] { blogid, userName, password, new Integer(requestSize) }); final Object response = getXmlRpcClient().execute("metaWeblog.getRecentPosts", params);
@SuppressWarnings("unchecked")
final Map<String, Object>[] resultsArray = (Map<String, Object>[]) response;
results = Arrays.asList(resultsArray); results = Arrays.asList(resultsArray);
} catch (final Exception e) { } catch (final Exception e) {
throw new BlogClientException("ERROR: XML-RPC error getting entry", e); throw new BlogClientException("ERROR: XML-RPC error getting entry", e);