/** * Process an individual element from the document during parse. Normally, implementations will * allow the base advertisments a chance to handle the element before attempting ot handle the * element themselves. ie. * * <p> * * <p> * * <pre><code> * protected boolean handleElement(Element elem) { * <p/> * if (super.handleElement()) { * // it's been handled. * return true; * } * <p/> * <i>... handle elements here ...</i> * <p/> * // we don't know how to handle the element * return false; * } * </code></pre> * * @param elem the element to be processed. * @return true if the element was recognized, otherwise false. */ protected boolean handleElement(XMLElement elem) { String value = elem.getTextValue(); if (null == value) { return false; } value = value.trim(); if (0 == value.length()) { return false; } if (elem.getName().equals(typeTag)) { setDiscoveryType(Integer.parseInt(value)); return true; } if (elem.getName().equals(thresholdTag)) { setThreshold(Integer.parseInt(value)); return true; } if (elem.getName().equals(peerAdvTag)) { try { XMLDocument asDoc = (XMLDocument) StructuredDocumentFactory.newStructuredDocument( MimeMediaType.XMLUTF8, new StringReader(value)); PeerAdvertisement adv = (PeerAdvertisement) AdvertisementFactory.newAdvertisement(asDoc); setPeerAdvertisement(adv); return true; } catch (IOException failed) { IllegalArgumentException failure = new IllegalArgumentException("Bad Peer Advertisement"); failure.initCause(failed); throw failure; } } if (elem.getName().equals(queryAttrTag)) { setAttr(value); return true; } if (elem.getName().equals(queryValueTag)) { setValue(value); return true; } // element was not handled return false; }