
org.yaoqiang.bpmn.model.elements.XMLElement Maven / Gradle / Ivy
package org.yaoqiang.bpmn.model.elements;
import org.yaoqiang.bpmn.model.BPMNModelUtils;
/**
* XMLElement
*
* @author Shi Yaoqiang([email protected])
*/
public abstract class XMLElement implements Cloneable{
protected String name;
protected String value;
protected XMLElement parent;
public XMLElement(XMLElement parent) {
this(parent, null, null);
}
public XMLElement(XMLElement parent, String name) {
this(parent, name, null);
}
public XMLElement(XMLElement parent, String name, String value) {
this.parent = parent;
if (name == null) {
this.name = getClass().getName();
this.name = BPMNModelUtils.getShortClassName(this.name);
} else {
this.name = name;
}
if (value == null) {
this.value = new String();
} else {
this.value = value;
}
}
public boolean isEmpty() {
return !(value != null && value.trim().length() > 0);
}
public XMLElement getParent() {
return parent;
}
public void setParent(XMLElement el) {
this.parent = el;
}
public void setElementName(String name) {
this.name = name;
}
public String toName() {
return name;
}
public void setValue(String value) {
this.value = value;
}
public String toValue() {
return value;
}
public boolean equals(Object e) {
if (this == e) {
return true;
}
boolean equals = false;
if (e != null && e instanceof XMLElement && e.getClass().equals(this.getClass())) {
XMLElement el = (XMLElement) e;
equals = this.name.equals(el.name);
equals = equals && this.value.equals(el.value);
}
return equals;
}
public Object clone() {
XMLElement d = null;
try {
d = (XMLElement) super.clone();
d.name = new String(this.name);
d.value = new String(this.value);
} catch (CloneNotSupportedException ex) {
}
return d;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy