Code modifications to support new IntMap interface.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@320 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Model.java,v 1.2 2001/07/26 00:24:22 mdb Exp $
|
// $Id: Model.java,v 1.3 2001/09/15 17:31:09 mdb Exp $
|
||||||
|
|
||||||
package robodj.repository;
|
package robodj.repository;
|
||||||
|
|
||||||
@@ -8,8 +8,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import com.samskivert.util.IntMap;
|
import com.samskivert.util.*;
|
||||||
import com.samskivert.util.IntIntMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model provides an interface to the contents of the repository which
|
* The model provides an interface to the contents of the repository which
|
||||||
@@ -79,7 +78,10 @@ public class Model
|
|||||||
{
|
{
|
||||||
Entry entry = (Entry)_entries.get(entryid);
|
Entry entry = (Entry)_entries.get(entryid);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
_entries.put(entryid, entry = _rep.getEntry(entryid));
|
entry = _rep.getEntry(entryid);
|
||||||
|
if (entry != null) {
|
||||||
|
_entries.put(entryid, entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
@@ -240,7 +242,9 @@ public class Model
|
|||||||
protected Repository _rep;
|
protected Repository _rep;
|
||||||
protected Category[] _cats;
|
protected Category[] _cats;
|
||||||
|
|
||||||
protected IntMap _entries = new IntMap();
|
protected IntMap _entries =
|
||||||
protected IntMap _catmap = new IntMap();
|
Collections.synchronizedIntMap(new HashIntMap());
|
||||||
|
protected IntMap _catmap =
|
||||||
|
Collections.synchronizedIntMap(new HashIntMap());
|
||||||
protected IntIntMap _entmap = new IntIntMap();
|
protected IntIntMap _entmap = new IntIntMap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
//
|
//
|
||||||
// $Id: Repository.java,v 1.5 2001/06/07 08:37:47 mdb Exp $
|
// $Id: Repository.java,v 1.6 2001/09/15 17:31:09 mdb Exp $
|
||||||
|
|
||||||
package robodj.repository;
|
package robodj.repository;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Enumeration;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ public class Repository extends MySQLRepository
|
|||||||
// SQL, but I can't be bothered to sort it out for a
|
// SQL, but I can't be bothered to sort it out for a
|
||||||
// data set that isn't going to be so big that it
|
// data set that isn't going to be so big that it
|
||||||
// can't be done in Java
|
// can't be done in Java
|
||||||
IntMap ids = new IntMap();
|
HashIntMap ids = new HashIntMap();
|
||||||
Statement stmt = _session.connection.createStatement();
|
Statement stmt = _session.connection.createStatement();
|
||||||
try {
|
try {
|
||||||
// first add all the entryids in the repository
|
// first add all the entryids in the repository
|
||||||
@@ -359,9 +359,9 @@ public class Repository extends MySQLRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
int[] eids = new int[ids.size()];
|
int[] eids = new int[ids.size()];
|
||||||
Enumeration keys = ids.keys();
|
Iterator keys = ids.keys();
|
||||||
for (int i = 0; keys.hasMoreElements(); i++) {
|
for (int i = 0; keys.hasNext(); i++) {
|
||||||
eids[i] = ((Integer)keys.nextElement()).intValue();
|
eids[i] = ((Integer)keys.next()).intValue();
|
||||||
}
|
}
|
||||||
return eids;
|
return eids;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user