Method from org.apache.jmeter.monitor.parser.MonitorHandler Detail: |
public void characters(char[] ch,
int start,
int length) throws SAXException {
}
Receive notification of character data inside an element.
By default, do nothing. Application writers may override this method to
take specific actions for each chunk of character data (such as adding
the data to a node or buffer, or printing it to a file).
|
public void endDocument() throws SAXException {
// this.startDoc = false;
// this.endDoc = true;
}
|
public void endElement(String uri,
String localName,
String qName) throws SAXException {
if (qName.equals(Constants.STATUS)) {
if (stacktree.peek() instanceof Status) {
stacktree.pop();
}
} else if (qName.equals(Constants.JVM)) {
if (stacktree.peek() instanceof Jvm) {
stacktree.pop();
}
} else if (qName.equals(Constants.MEMORY)) {
if (stacktree.peek() instanceof Memory) {
stacktree.pop();
}
} else if (qName.equals(Constants.CONNECTOR)) {
if (stacktree.peek() instanceof Connector || stacktree.peek() instanceof Connector) {
stacktree.pop();
}
} else if (qName.equals(Constants.THREADINFO)) {
if (stacktree.peek() instanceof ThreadInfo) {
stacktree.pop();
}
} else if (qName.equals(Constants.REQUESTINFO)) {
if (stacktree.peek() instanceof RequestInfo) {
stacktree.pop();
}
} else if (qName.equals(Constants.WORKERS)) {
if (stacktree.peek() instanceof Workers) {
stacktree.pop();
}
} else if (qName.equals(Constants.WORKER)) {
if (stacktree.peek() instanceof Worker || stacktree.peek() instanceof Worker) {
stacktree.pop();
}
}
}
Receive notification of the end of an element.
By default, do nothing. Application writers may override this method in a
subclass to take specific actions at the end of each element (such as
finalising a tree node or writing output to a file).
|
public Status getContents() {
return this.status;
}
method returns the status object. |
public int parseInt(String data) {
int val = 0;
if (data.length() > 0) {
try {
val = Integer.parseInt(data);
} catch (NumberFormatException e) {
val = 0;
}
}
return val;
}
Convienance method for parsing integers. |
public long parseLong(String data) {
long val = 0;
if (data.length() > 0) {
try {
val = Long.parseLong(data);
} catch (NumberFormatException e) {
val = 0;
}
}
return val;
}
Convienance method for parsing long. If the string was not a number, the
method returns zero. |
public void setObjectFactory(ObjectFactory factory) {
this.factory = factory;
}
Set the ObjectFactory used to create new |
public void startDocument() throws SAXException {
// this.startDoc = true;
}
|
public void startElement(String uri,
String localName,
String qName,
Attributes attributes) throws SAXException {
if (qName.equals(Constants.STATUS)) {
status = factory.createStatus();
stacktree.push(status);
} else if (qName.equals(Constants.JVM)) {
jvm = factory.createJvm();
if (stacktree.peek() instanceof Status) {
status.setJvm(jvm);
stacktree.push(jvm);
}
} else if (qName.equals(Constants.MEMORY)) {
memory = factory.createMemory();
if (stacktree.peek() instanceof Jvm) {
stacktree.push(memory);
if (attributes != null) {
for (int idx = 0; idx < attributes.getLength(); idx++) {
String attr = attributes.getQName(idx);
if (attr.equals(Constants.MEMORY_FREE)) {
memory.setFree(parseLong(attributes.getValue(idx)));
} else if (attr.equals(Constants.MEMORY_TOTAL)) {
memory.setTotal(parseLong(attributes.getValue(idx)));
} else if (attr.equals(Constants.MEMORY_MAX)) {
memory.setMax(parseLong(attributes.getValue(idx)));
}
}
}
jvm.setMemory(memory);
}
} else if (qName.equals(Constants.CONNECTOR)) {
connector = factory.createConnector();
if (stacktree.peek() instanceof Status || stacktree.peek() instanceof Connector) {
status.addConnector(connector);
stacktree.push(connector);
if (attributes != null) {
for (int idx = 0; idx < attributes.getLength(); idx++) {
String attr = attributes.getQName(idx);
if (attr.equals(Constants.ATTRIBUTE_NAME)) {
connector.setName(attributes.getValue(idx));
}
}
}
}
} else if (qName.equals(Constants.THREADINFO)) {
threadinfo = factory.createThreadInfo();
if (stacktree.peek() instanceof Connector) {
stacktree.push(threadinfo);
connector.setThreadInfo(threadinfo);
if (attributes != null) {
for (int idx = 0; idx < attributes.getLength(); idx++) {
String attr = attributes.getQName(idx);
if (attr.equals(Constants.MAXTHREADS)) {
threadinfo.setMaxThreads(parseInt(attributes.getValue(idx)));
} else if (attr.equals(Constants.MINSPARETHREADS)) {
threadinfo.setMinSpareThreads(parseInt(attributes.getValue(idx)));
} else if (attr.equals(Constants.MAXSPARETHREADS)) {
threadinfo.setMaxSpareThreads(parseInt(attributes.getValue(idx)));
} else if (attr.equals(Constants.CURRENTTHREADCOUNT)) {
threadinfo.setCurrentThreadCount(parseInt(attributes.getValue(idx)));
} else if (attr.equals(Constants.CURRENTBUSYTHREADS)) {
threadinfo.setCurrentThreadsBusy(parseInt(attributes.getValue(idx)));
}
}
}
}
} else if (qName.equals(Constants.REQUESTINFO)) {
requestinfo = factory.createRequestInfo();
if (stacktree.peek() instanceof Connector) {
stacktree.push(requestinfo);
connector.setRequestInfo(requestinfo);
if (attributes != null) {
for (int idx = 0; idx < attributes.getLength(); idx++) {
String attr = attributes.getQName(idx);
if (attr.equals(Constants.MAXTIME)) {
requestinfo.setMaxTime(parseInt(attributes.getValue(idx)));
} else if (attr.equals(Constants.PROCESSINGTIME)) {
requestinfo.setProcessingTime(parseInt(attributes.getValue(idx)));
} else if (attr.equals(Constants.REQUESTCOUNT)) {
requestinfo.setRequestCount(parseInt(attributes.getValue(idx)));
} else if (attr.equals(Constants.ERRORCOUNT)) {
requestinfo.setErrorCount(parseInt(attributes.getValue(idx)));
} else if (attr.equals(Constants.BYTESRECEIVED)) {
requestinfo.setBytesReceived(parseLong(attributes.getValue(idx)));
} else if (attr.equals(Constants.BYTESSENT)) {
requestinfo.setBytesSent(parseLong(attributes.getValue(idx)));
}
}
}
}
} else if (qName.equals(Constants.WORKERS)) {
workers = factory.createWorkers();
if (stacktree.peek() instanceof Connector) {
connector.setWorkers(workers);
stacktree.push(workers);
}
} else if (qName.equals(Constants.WORKER)) {
worker = factory.createWorker();
if (stacktree.peek() instanceof Workers || stacktree.peek() instanceof Worker) {
stacktree.push(worker);
((WorkersImpl) workers).addWorker(worker);
if (attributes != null) {
for (int idx = 0; idx < attributes.getLength(); idx++) {
String attr = attributes.getQName(idx);
if (attr.equals(Constants.STAGE)) {
worker.setStage(attributes.getValue(idx));
} else if (attr.equals(Constants.REQUESTPROCESSINGTIME)) {
worker.setRequestProcessingTime(parseInt(attributes.getValue(idx)));
} else if (attr.equals(Constants.REQUESTBYTESSENT)) {
worker.setRequestBytesSent(parseLong(attributes.getValue(idx)));
} else if (attr.equals(Constants.REQUESTBYTESRECEIVED)) {
worker.setRequestBytesReceived(parseLong(attributes.getValue(idx)));
} else if (attr.equals(Constants.REMOTEADDR)) {
worker.setRemoteAddr(attributes.getValue(idx));
} else if (attr.equals(Constants.VIRTUALHOST)) {
worker.setVirtualHost(attributes.getValue(idx));
} else if (attr.equals(Constants.METHOD)) {
worker.setMethod(attributes.getValue(idx));
} else if (attr.equals(Constants.CURRENTURI)) {
worker.setCurrentUri(attributes.getValue(idx));
} else if (attr.equals(Constants.CURRENTQUERYSTRING)) {
worker.setCurrentQueryString(attributes.getValue(idx));
} else if (attr.equals(Constants.PROTOCOL)) {
worker.setProtocol(attributes.getValue(idx));
}
}
}
}
}
}
Receive notification of the start of an element.
By default, do nothing. Application writers may override this method in a
subclass to take specific actions at the start of each element (such as
allocating a new tree node or writing output to a file).
|