/** * For the specified Interpreter type node, parse all subordinate Interpreter definitions and add * them to the specified container. */ private void populateValidatorType(Element validatorTypeElement) { // Retrieve the 'id' attribute and the corresponding Interpreter type // object String id = validatorTypeElement.getAttribute(ATTR_ID); IValidatorType validatorType = ValidatorManager.getValidatorTypeFromID(id); if (validatorType != null) { // For each validator child node, populate the container with a // subordinate node NodeList validatorNodeList = validatorTypeElement.getChildNodes(); for (int i = 0; i < validatorNodeList.getLength(); ++i) { Node childNode = validatorNodeList.item(i); short type = childNode.getNodeType(); if (type == Node.ELEMENT_NODE) { Element validatorElement = (Element) childNode; if (validatorElement.getNodeName().equalsIgnoreCase(NODE_VALIDATOR)) { populateValidator(validatorType, validatorElement); } } } } else { final String msg = ValidatorMessages.ValidatorDefinitionsContainer_unknownValidatorType; ValidatorsCore.warn(NLS.bind(msg, id)); } }
/** * Parse the specified Interpreter node, create a InterpreterStandin for it, and add this to the * specified container. */ private void populateValidator(IValidatorType type, Element element) { String id = element.getAttribute(ATTR_ID); if (id != null) { try { final IValidator validator; if (type.isBuiltin()) { validator = type.findValidator(id); } else { validator = type.createValidator(id); } if (validator != null) { if (type.isConfigurable()) { validator.loadFrom(element); } addValidator(validator); } } catch (DOMException e) { final String msg = ValidatorMessages.ValidatorDefinitionsContainer_failedToLoadValidatorFromXml; ValidatorsCore.error(msg, e); } } else { if (DLTKCore.DEBUG) { System.err.println( "id attribute missing from validator element specification."); //$NON-NLS-1$ } } }
public String getAsXML() throws ParserConfigurationException, IOException, TransformerException { // Create the Document and the top-level node Document doc = ValidatorsCore.getDocument(); Element config = doc.createElement(NODE_VALIDATOR_SETTINGS); doc.appendChild(config); // Create a node for each validator type represented in this container for (Iterator i = fValidatorsByType.entrySet().iterator(); i.hasNext(); ) { final Map.Entry entry = (Map.Entry) i.next(); final IValidatorType validatorType = (IValidatorType) entry.getKey(); if (validatorType.isConfigurable()) { Element valiatorTypeElement = validatorTypeAsElement(doc, validatorType, (List) entry.getValue()); config.appendChild(valiatorTypeElement); } } // Serialize the Document and return the resulting String return ValidatorsCore.serializeDocument(doc); }