package acspg; import java.sql.*; import java.io.*; import javax.mail.*; import javax.mail.internet.*; import java.util.*; import javax.activation.*; import nsjava.*; public class AttachmentsIter { NsSet rs; Integer col_data; Integer col_ct; Integer col_fn; Integer data; String content_type; String filename; public AttachmentsIter(Pg_Query st, String query) throws SQLException { this.rs = st.select(query); if(this.rs != null) { this.col_data = this.rs.find("lob"); this.col_ct = this.rs.find("content_type"); this.col_fn = this.rs.find("filename"); } } public boolean next(Pg_Query st) throws SQLException { if(this.rs != null) { if(st.getrow(this.rs) == true) { this.data = new Integer(this.rs.value(this.col_data)); this.content_type = this.rs.value(this.col_ct); this.filename = this.rs.value(this.col_fn); return true; } } return false; } public BLOB data(Pg_Query st) throws SQLException, IOException { BLOB b = new BLOB(this.data.intValue(),st); b.readFromDatabase(); return b; } public String content_type() { return this.content_type; } public String filename() { return this.filename; } public void close() throws SQLException { this.rs.free(); } }