Trivial code cleanup

This commit is contained in:
Vhati 2013-08-24 03:39:30 -04:00
parent 9b34c5119f
commit f9680d4cda
2 changed files with 17 additions and 16 deletions

View file

@ -2,6 +2,7 @@ package net.vhati.modmanager.core;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import net.vhati.modmanager.core.ModInfo; import net.vhati.modmanager.core.ModInfo;
@ -11,7 +12,7 @@ public class ModDB {
// Accociates Forum thread urls with hashes of their forst post's content. // Accociates Forum thread urls with hashes of their forst post's content.
private HashMap<String,String> threadHashMap = new HashMap<String,String>(); private HashMap<String,String> threadHashMap = new HashMap<String,String>();
private ArrayList<ModInfo> catalog = new ArrayList<ModInfo>(); private List<ModInfo> catalog = new ArrayList<ModInfo>();
/** /**
@ -55,7 +56,7 @@ public class ModDB {
/** /**
* Returns the internal ArrayList of mod info. * Returns the internal ArrayList of mod info.
*/ */
public ArrayList<ModInfo> getCatalog() { public List<ModInfo> getCatalog() {
return catalog; return catalog;
} }
} }

View file

@ -30,28 +30,28 @@ public class JacksonGrognakCatalogReader {
Exception exception = null; Exception exception = null;
try { try {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); mapper.configure( JsonParser.Feature.ALLOW_SINGLE_QUOTES, true );
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); mapper.setVisibility( PropertyAccessor.FIELD, Visibility.ANY );
JsonNode rootNode = mapper.readTree(jsonFile); JsonNode rootNode = mapper.readTree( jsonFile );
JsonNode catalogsNode = rootNode.get("catalog_versions"); JsonNode catalogsNode = rootNode.get( "catalog_versions" );
JsonNode catalogNode = catalogsNode.get("1"); JsonNode catalogNode = catalogsNode.get( "1" );
for ( JsonNode infoNode : catalogNode ) { for ( JsonNode infoNode : catalogNode ) {
String threadURL = infoNode.get("url").textValue(); String threadURL = infoNode.get( "url" ).textValue();
String threadHash = infoNode.get("thread_hash").textValue(); String threadHash = infoNode.get( "thread_hash" ).textValue();
if ( !threadURL.equals("???") && !threadHash.equals("???") ) if ( !threadURL.equals("???") && !threadHash.equals("???") )
modDB.putThreadHash( threadURL, threadHash ); modDB.putThreadHash( threadURL, threadHash );
JsonNode versionsNode = infoNode.get("versions"); JsonNode versionsNode = infoNode.get( "versions" );
for ( JsonNode versionNode : versionsNode ) { for ( JsonNode versionNode : versionsNode ) {
ModInfo modInfo = new ModInfo(); ModInfo modInfo = new ModInfo();
modInfo.setTitle( infoNode.get("title").textValue() ); modInfo.setTitle( infoNode.get( "title" ).textValue() );
modInfo.setAuthor( infoNode.get("author").textValue() ); modInfo.setAuthor( infoNode.get( "author" ).textValue() );
modInfo.setURL( infoNode.get("url").textValue() ); modInfo.setURL( infoNode.get( "url" ).textValue() );
modInfo.setDescription( infoNode.get("desc").textValue() ); modInfo.setDescription( infoNode.get( "desc" ).textValue() );
modInfo.setFileHash( versionNode.get("hash").textValue() ); modInfo.setFileHash( versionNode.get( "hash" ).textValue() );
modInfo.setVersion( versionNode.get("version").textValue() ); modInfo.setVersion( versionNode.get( "version" ).textValue() );
modDB.addMod( modInfo ); modDB.addMod( modInfo );
} }
} }