/** * This method is used to set the Deserialized Object and it also calls * the parent LDAPXMLHandler (if not null), returning the value using * addValue() * @param data Object data. * @see #addValue(String, Object) */ protected final void setObject(Object data) { if ((state != START) && (state != CHILDELEMENT)) throw new IllegalStateException("setObject"); resultantObject = data; if (getParent() != null) { getParent().addValue(getName(), data); } } }
/** Default Constructor with element name for this Handler and parent * LDAPXMLHandler to be processed. * @param ElementName String name of the XML element to process. * @param parent LDAPXMLHandler , which is the parent of this Element. */ public LDAPXMLHandler(String ElementName, LDAPXMLHandler parent) { elementName = ElementName; parenthandler = parent; state = INIT; initHandler(); } /**
/** * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) */ public void startElement( String uri, String localName, String qName, Attributes attributes) throws SAXException { super.startElement(uri, localName, qName, attributes); Handlerstack.push(currenthandler); if (currenthandler == null) { currenthandler = defaulthandler; } else { currenthandler = currenthandler.nextHandler(localName); } //process Elements. if (!localName.equals(currenthandler.getName())) { throw new SAXException("Unknown tag:" + localName); } currenthandler.startElement(); currenthandler.handleAttributes(attributes); }
/** * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ public void endElement(String uri, String localName, String qName) throws SAXException { // Kind of assertion if (!localName.equals(currenthandler.getName())) { throw new SAXException("Invalid System State"); } currenthandler.value(buffer); // Reset StringBuffer. buffer.delete(0, buffer.length()); currenthandler.endElement(); //Pop the element. currenthandler = (LDAPXMLHandler) Handlerstack.pop(); super.endElement(uri, localName, qName); }
/** * Sets the Handler for the Child LDAPXMLHandler, it expects only * one handler for each code base. * @param handler This handler for specific child element. */ protected final void setchildelement(LDAPXMLHandler handler) { if (state != INIT) throw new IllegalStateException("setchildelement"); m_handler_map.put(handler.getName(), handler); } /**
"The XML cannot be parsed is configured incorrectly:" + e); return defaulthandler.getObject();
protected void endElement() { try { byte[] temp; String name = getName(); String value = getValue(); if (this.isBase64) { temp = Base64.decode(value); } else { temp = value.getBytes("UTF-8"); } //getParent().addValue("value", temp); getParent().addValue(name, temp); } catch (UnsupportedEncodingException e) { } } protected void handleAttributes(Attributes attributes) throws SAXException {