Methods Summary |
---|
public int | addListing(Listing listing, javax.activation.DataHandler handler)
_listings.put(new Integer(_nextId), listing);
int listno = _nextId;
_nextId++;
if (handler != null) {
String fname = String.valueOf(listno) + ".bin";
DataSource ds = handler.getDataSource();
ByteArrayDataSource bsource =
new ByteArrayDataSource(ds.getInputStream(),
handler.getContentType());
bsource.writeTo(new FileOutputStream(fname));
}
return listno;
|
protected java.util.Vector | findListingIds(java.lang.String make, java.lang.String model)
Vector result = new Vector();
for (Enumeration e = _listings.keys() ;
e.hasMoreElements() ;) {
Integer i = (Integer)e.nextElement();
Listing listing = (Listing)_listings.get(i);
if (make.equals(listing.getMake()) &&
model.equals(listing.getModel())) {
result.add(i);
}
}
return result;
|
public javax.activation.DataHandler | getImage(int id)
String fname = String.valueOf(id) + ".bin";
DataSource ds =
new ByteArrayDataSource(new File(fname), null);
DataHandler dh = new DataHandler(ds);
return dh;
|
public Listing | getListing(int id)
Listing listing = (Listing)_listings.get(new Integer(id));
return listing;
|
public java.lang.Integer[] | search(java.lang.String make, java.lang.String model)
Vector v = findListingIds(make, model);
int cnt = v.size();
if (cnt == 0)
return null;
Integer ids[] = new Integer[cnt];
for (int i = 0; i < cnt; i++) {
ids[i] = (Integer)v.elementAt(i);
}
return ids;
|