All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.tsijercic1.Node Maven / Gradle / Ivy

There is a newer version: 1.3
Show newest version
package com.github.tsijercic1;

import java.util.*;

public class Node {
    private String name;
    private String content;
    private Map attributes;
    private ArrayList childNodes;

    public Node() {
        attributes = new TreeMap<>();
        childNodes = new ArrayList<>();
    }

    public Node(String name) {
        this();
        this.name = name;
    }

    public void setName(String name) {
        this.name=name;
    }

    public String getName() {
        return name;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public void addAttribute(String key, String value) {
        attributes.put(key, value);
    }

    public void addChildNode(Node node) {
        childNodes.add(node);
    }

    public Map getAttributes() {
        return attributes;
    }

    public ArrayList getChildNodes() {
        return childNodes;
    }
    public ArrayList getChildNodes(String name){
        ArrayList nodes = new ArrayList<>(childNodes);
        nodes.removeIf(node -> !node.getName().equals(name));
        return nodes;
    }
    public Set getAttributeKeys(){
        return attributes.keySet();
    }
    public Collection getAttributeValues(){
        return attributes.values();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy