/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at * trunk/opends/resource/legal-notices/OpenDS.LICENSE * or https://OpenDS.dev.java.net/OpenDS.LICENSE. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, * add the following below this CDDL HEADER, with the fields enclosed * by brackets "[]" replaced with your own identifying information: * Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * * Copyright 2006-2008 Sun Microsystems, Inc. */ package org.opends.testqa.monitoringclient; import java.util.Hashtable; import java.util.Properties; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; /** * Parse a XML config file. */ public class ConfigHandler extends DefaultHandler { /** * Main class of the client. */ private MonitoringClient client; private Properties parsedArguments; /** * The parsed properties. */ private Hashtable config; /** * The locator used for display informations about the line and the column * number of the error. */ private Locator locator; /** * The name of the protocol markup. */ private String inProtocol; /** * Indicate if a attribute markup have already been open. */ private boolean inAttribute; /** * The constructor of the handler. * * @param client The main class of the client * @param parsedArguments The parsed arguments */ public ConfigHandler(MonitoringClient client, Properties parsedArguments) { super(); this.client = client; this.parsedArguments = parsedArguments; this.config = new Hashtable(); inProtocol = ""; inAttribute = false; } /** * Set the document locator to display information about the line or column * number of the error. * * @param locator The locator used for display informations about the line and * the column number of the error. */ @Override public void setDocumentLocator (Locator locator) { this.locator = locator; } /** * If an element is open, set the parameters of the client or add an attribute * to monitor. * * @param uri The Namespace URI, or the empty string if the element * has no Namespace URI or if Namespace processing is not being performed. * @param localName The local name (without prefix), or the empty string if * Namespace processing is not being performed. * @param qName The qualified name (with prefix), or the empty string if * qualified names are not available. * @param attributes The attributes attached to the element. If there are no * attributes, it shall be an empty Attributes object. * @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping * another exception. */ @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { Properties params = new Properties(); if (qName.equals("protocol")) { for (int i=0; i