com.espertech.esper.event.xml.ElementPathNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of esper Show documentation
Show all versions of esper Show documentation
Complex event processing and event series analysis component
/*
***************************************************************************************
* Copyright (C) 2006 EsperTech, Inc. All rights reserved. *
* http://www.espertech.com/esper *
* http://www.espertech.com *
* ---------------------------------------------------------------------------------- *
* The software in this package is published under the terms of the GPL license *
* a copy of which has been included with this distribution in the license.txt file. *
***************************************************************************************
*/
package com.espertech.esper.event.xml;
import java.util.ArrayList;
import java.util.List;
/**
* A simple node for the creation of a tree, intended in this case to mirror an XML model.
*/
public class ElementPathNode {
private final String name;
private final ElementPathNode parent;
private List children = null;
public ElementPathNode(final ElementPathNode parent, final String name) {
this.name = name;
this.parent = parent;
}
public ElementPathNode addChild(String name) {
if (children == null) {
children = new ArrayList();
}
ElementPathNode newChild = new ElementPathNode(this, name);
children.add(newChild);
return newChild;
}
public String getName() {
return name;
}
public ElementPathNode getParent() {
return parent;
}
public boolean doesNameAlreadyExistInHierarchy() {
return doesNameAlreadyExistInHierarchy(this.getName());
}
private boolean doesNameAlreadyExistInHierarchy(String nameToFind) {
boolean doesNameAlreadyExistInHierarchy = false;
if (parent != null) {
if (parent.getName().equals(nameToFind)) {
doesNameAlreadyExistInHierarchy = true;
} else {
return parent.doesNameAlreadyExistInHierarchy(nameToFind);
}
}
return doesNameAlreadyExistInHierarchy;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy