Package net.n3.nanoxml

Examples of net.n3.nanoxml.XMLElement


  public ConfigNode create(String name) {
    if (root == null) {
      LogBuffer.println("Warning: root is null, creating dummy config node");
      return new DummyConfigNode(name);
    }
      XMLElement kid = new XMLElement(name);
      root.addChild(kid);
      XmlConfig.this.changed = true;
      return new XmlConfigNode(kid);
   }
View Full Code Here


    public AutomatedInstallData() {
        availablePacks = new ArrayList();
        selectedPacks = new ArrayList();
        panels = new ArrayList<IzPanel>();
        panelsOrder = new ArrayList();
        xmlData = new XMLElement("AutomatedInstallation");
        variables = new Properties();
        attributes = new HashMap<String, Object>();
        customData = new HashMap<String, List>();
        self = this;
    }
View Full Code Here

     *
     * @param idata     The installation data.
     * @param panelRoot The tree to put the data in.
     */
    public void makeXMLData(AutomatedInstallData idata, XMLElement panelRoot) {
        XMLElement hostsElement;
        XMLElement hostElement;

        // ----------------------------------------------------
        // add the item that combines all entries
        // ----------------------------------------------------
        hostsElement = new XMLElement(ELEMENT_HOSTS_NAME);
        panelRoot.addChild(hostsElement);

        // ----------------------------------------------------
        // add all entries
        // ----------------------------------------------------
        Iterator<String> keys = this.entries.keySet().iterator();
        while (keys.hasNext()) {
            String key = keys.next();
            String value = this.entries.get(key);

            hostElement = new XMLElement(ELENENT_HOST_NAME);
            hostElement.setAttribute(ATTRIBUTE_HOST_ID, key);
            hostElement.setAttribute(ATTRIBUTE_HOTS_ARGS, value);

            hostsElement.addChild(hostElement);
        }
    }
View Full Code Here

     * @param idata     The installation data.
     * @param panelRoot The XML tree to read the data from.
     * @return always true.
     */
    public boolean runAutomated(AutomatedInstallData idata, XMLElement panelRoot) {
        XMLElement hostsElement;
        XMLElement hostElement;
        String id;
        String arguments;

        // ----------------------------------------------------
        // get the section containing the user entries
        // ----------------------------------------------------
        hostsElement = panelRoot.getFirstChildNamed(ELEMENT_HOSTS_NAME);
        if (hostsElement == null) {
            return false;
        }

        Vector<XMLElement> hostElements = hostsElement.getChildrenNamed(ELENENT_HOST_NAME);
        if (hostElements == null) {
            return false;
        }

        // ----------------------------------------------------
        // retieve each entry and substitute the associated
        // variable
        // ----------------------------------------------------
        ArrayList<Host> allHosts = new ArrayList<Host>(hostElements.size());
        for (int i = 0; i < hostElements.size(); i++) {
            hostElement = hostElements.elementAt(i);

            id = hostElement.getAttribute(ATTRIBUTE_HOST_ID);
            arguments = hostElement.getAttribute(ATTRIBUTE_HOTS_ARGS);

            Debug.trace("Found host: '" + arguments + "'.");

            try {
                List<Host> hostsPart = Host.fromStringInstance(arguments);
View Full Code Here

    public ConfigureScript loadScript(String fileName) throws ConfigureException {
        configure.verbose("Loading configure script from " + fileName);
        final File file = new File(fileName);
        stack.add(new ParseContext(file));
        try {
            final XMLElement root = loadXML(file);
            configure.debug("Parsing script");
            return parseScript(root, file);
        } finally {
            stack.removeLast();
        }
View Full Code Here

        if (baseDirName.length() > 0) {
            File baseDir = new File(stack.getLast().getBaseDir(), baseDirName);
            stack.getLast().setBaseDir(baseDir);
        }
        for (Enumeration<?> en = root.enumerateChildren(); en.hasMoreElements(); /**/) {
            XMLElement element = (XMLElement) en.nextElement();
            String elementName = element.getName();
            if (elementName.equals(TYPE)) {
                parseType(element, script);
            } else if (elementName.equals(CONTROL_PROPS)) {
                parseControlProps(element, script);
            } else if (elementName.equals(PROP_FILE)) {
View Full Code Here

        if (includeFileName == null) {
            error("A '" + SCRIPT_FILE + "' attribute is required for an '" + INCLUDE + "' element",
                    element);
        }
        File includeFile = resolvePath(includeFileName);
        XMLElement includeRoot = loadXML(includeFile);
        stack.getLast().setElement(element);
        stack.add(new ParseContext(includeFile));
        try {
            parseScript(includeRoot, script);
        } finally {
View Full Code Here

        String name = element.getAttribute(NAME, null);
        checkName(name, NAME, TYPE, element);
        String patternString = element.getAttribute(PATTERN, null);
        List<EnumeratedType.Alternate> alternates = new LinkedList<EnumeratedType.Alternate>();
        for (Enumeration<?> en = element.enumerateChildren(); en.hasMoreElements(); /**/) {
            XMLElement child = (XMLElement) en.nextElement();
            if (!child.getName().equals(ALT)) {
                error("A '" + TYPE + "' element can only contain '" + ALT + "' elements", child);
            }
            String value = child.getAttribute(VALUE, null);
            String token = child.getAttribute(TOKEN, value);
            if (value == null) {
                error("A '" + VALUE + "' attribute is required for an '" + ALT + "' element", child);
            }
            if (token.length() == 0) {
                // An empty token is problematic because and empty input line is
View Full Code Here

    }

    private PropertySet parseProperties(XMLElement element, PropertySet propSet,
            ConfigureScript script) throws ConfigureException {
        for (Enumeration<?> en = element.enumerateChildren(); en.hasMoreElements(); /**/) {
            XMLElement child = (XMLElement) en.nextElement();
            if (child.getName().equals(PROPERTY)) {
                String name = child.getAttribute(NAME, null);
                checkName(name, NAME, PROPERTY, child);
                String typeName = child.getAttribute(TYPE, null);
                if (name == null) {
                    error("A '" + PROPERTY + "' element requires a '" + TYPE + "' attribute", child);
                }
                String description = child.getAttribute(DESCRIPTION, null);
                if (name == null) {
                    error("A '" + PROPERTY + "' element requires a '" + DESCRIPTION +
                            "' attribute", child);
                }
                String defaultText = child.getAttribute(DEFAULT, "");
                PropertyType type = script.getTypes().get(typeName);
                if (type == null) {
                    error("Use of undeclared type '" + typeName + "'", child);
                }
                Value defaultValue = type.fromValue(defaultText);
View Full Code Here

            }
        }
        Screen screen = new Screen(title, guardPropName, valueIs, valueIsNot);
        script.addScreen(screen);
        for (Enumeration<?> en = element.enumerateChildren(); en.hasMoreElements(); /**/) {
            XMLElement child = (XMLElement) en.nextElement();
            if (!child.getName().equals(ITEM)) {
                error("Expected an '" + ITEM + "' element", child);
            }
            String propName = child.getAttribute(PROPERTY, null);
            if (propName == null) {
                error("The '" + PROPERTY + "' attribute is required for an '" + ITEM + "' element",
                        child);
            }
            String changed = child.getAttribute(CHANGED, null);
            if (script.getProperty(propName) == null) {
                error("Use of undeclared property '" + propName + "'", child);
            }
            screen.addItem(new Item(script, propName, unindent(child.getContent()), changed));
        }
    }
View Full Code Here

TOP

Related Classes of net.n3.nanoxml.XMLElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.