BufferedReader in = new BufferedReader(
new InputStreamReader(
(InputStream)gzip));
/* Parser */
NexsmDocHandler docHan = null;
// after doing this
// we should fire an event
// with an specific action
// the event is trapped by PullManager who fires
// another event to its listeners (in this case Mapper)
// Mapper should know what to do according to the event type
// This is only an example of how to fire the event
PullerEvent pe = new PullerEvent(this, "Hmmm");
// pe.setType(PullerEvent.PullerEventType.STATUS);
// pe.setObject(docHan.getList());
//
// fireEvent(pe);
switch (type) {
case OBJECTS:
// maybe passing some params to the
// dochandler it could do some things happend
// Objects well add the objects
docHan = new DHObjects();
pe.setType(PullerEvent.PullerEventType.OBJECTS);
pe.setObject(docHan.getList());
break;
case STATUS:
// change the status things
docHan = new DHStatus();
pe.setType(PullerEvent.PullerEventType.STATUS);
pe.setObject(docHan.getList());
break;
case CONFIG:
// change the system config
docHan = new DHConfig();
pe.setType(PullerEvent.PullerEventType.CONFIG);
pe.setObject(docHan.getList());
break;
case TEST:
docHan = new DHConfig();
break;
default:
// error
throw new Exception("Invalid type");
}
long cur3 = System.currentTimeMillis();
try {
QDParser.parse(docHan,in);
} catch (Exception e) {
// TODO send a visual alert instead of a system output
System.err.println("Please send this output to the developer at sergio AT gridshield DOT net");
System.err.println("-----------Error URLPuller.java report------------");
System.err.println("Exception parsing... ");
e.printStackTrace();
System.err.println("-----------Error URLPuller.java report------------");
}
/* Parser */
_procesedData = docHan.getList();
int cleanTimes = 0;
long cur4 = System.currentTimeMillis();
in.close();
gzip.close();
if (type == URLPullerType.TEST) {
LinkedList <Object> l = docHan.getList();
_testData = l;
return;
}
// gets the Manager to fire an event