ingo@226: package de.intevation.artifactdatabase.state; ingo@226: ingo@295: import org.w3c.dom.Document; ingo@295: import org.w3c.dom.Element; ingo@295: import org.w3c.dom.Node; ingo@295: ingo@280: import de.intevation.artifacts.Artifact; ingo@295: import de.intevation.artifacts.ArtifactNamespaceContext; ingo@280: import de.intevation.artifacts.CallContext; ingo@280: ingo@295: import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; ingo@295: ingo@226: ingo@226: /** ingo@226: * The default implementation of a Facet. ingo@226: * ingo@226: * @author Ingo Weinzierl ingo@226: */ ingo@226: public class DefaultFacet implements Facet { ingo@226: ingo@277: /** The index of this facet.*/ ingo@277: protected int index; ingo@277: ingo@226: /** The name of this facet.*/ ingo@226: protected String name; ingo@226: ingo@226: /** The description of this facet.*/ ingo@226: protected String description; ingo@226: sascha@322: public DefaultFacet() { sascha@322: } ingo@226: ingo@226: /** ingo@226: * The default constructor to create new Facet objects. ingo@226: * ingo@226: * @param name The name of this new facet. ingo@226: * @param description The description of this new facet. ingo@226: */ ingo@226: public DefaultFacet(String name, String description) { ingo@277: this(0, name, description); ingo@277: } ingo@277: ingo@277: ingo@277: /** ingo@277: * The default constructor to create new Facet objects. ingo@277: * ingo@277: * @param index The index of this new facet. ingo@277: * @param name The name of this new facet. ingo@277: * @param description The description of this new facet. ingo@277: */ ingo@277: public DefaultFacet(int index, String name, String description) { ingo@277: this.index = index; ingo@226: this.name = name; ingo@226: this.description = description; ingo@226: } ingo@226: sascha@322: public void set(Facet other) { sascha@322: index = other.getIndex(); sascha@322: name = other.getName(); sascha@322: description = other.getDescription(); sascha@322: } sascha@322: sascha@322: public Facet deepCopy() { sascha@322: DefaultFacet copy = new DefaultFacet(); sascha@322: copy.set(this); sascha@322: return copy; sascha@322: } sascha@322: ingo@226: ingo@277: public int getIndex() { ingo@277: return index; ingo@277: } ingo@277: ingo@277: ingo@226: public String getName() { ingo@226: return name; ingo@226: } ingo@226: ingo@226: ingo@226: public String getDescription() { ingo@226: return description; ingo@226: } ingo@280: ingo@280: ingo@280: public Object getData(Artifact artifact, CallContext context) { ingo@280: return null; ingo@280: } sascha@283: sascha@283: public String toString() { sascha@283: return new StringBuilder("name = '") sascha@283: .append(name).append("', index = ") sascha@283: .append(index).append(", description = '") sascha@283: .append(description).append("'") sascha@283: .toString(); sascha@283: } ingo@295: ingo@295: ingo@295: public Node toXML(Document doc) { ingo@295: ElementCreator ec = new ElementCreator( ingo@295: doc, ingo@295: ArtifactNamespaceContext.NAMESPACE_URI, ingo@295: ArtifactNamespaceContext.NAMESPACE_PREFIX); ingo@295: ingo@295: Element facet = ec.create("facet"); ingo@295: ec.addAttr(facet, "description", description, true); ingo@295: ec.addAttr(facet, "name", name, true); ingo@295: ec.addAttr(facet, "index", String.valueOf(index), true); ingo@295: ingo@295: return facet; ingo@295: } ingo@226: } ingo@226: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :