view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedDomFacet.java @ 1135:c8c753931514

Added a fallback mechanism to style mapserver layers as long as the theme mechanism is not implemented for maps (as it is for charts). flys-artifacts/trunk@2656 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 06 Sep 2011 17:41:07 +0000
parents 59ae2a823e73
children c2edf0032cf8
line wrap: on
line source
package de.intevation.flys.artifacts.model;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

import de.intevation.artifacts.ArtifactNamespaceContext;


public class ManagedDomFacet extends ManagedFacet {

    protected Element facet;


    public ManagedDomFacet(Element facet) {
        super(null, -1, null, null, -1, -1);

        this.facet = facet;
    }


    @Override
    public int getIndex() {
        if (this.index < 0) {
            String index = facet.getAttributeNS(
                ArtifactNamespaceContext.NAMESPACE_URI, "index");

            if (index != null && index.length() > 0) {
                this.index = Integer.parseInt(index);
            }
        }

        return this.index;
    }


    @Override
    public String getName() {
        if (this.name == null || this.name.length() == 0) {
            String name = facet.getAttributeNS(
                ArtifactNamespaceContext.NAMESPACE_URI, "facet");

            this.name = name;
        }

        return this.name;
    }


    @Override
    public String getDescription() {
        if (this.description == null || this.description.length() == 0) {
            String description = facet.getAttributeNS(
                ArtifactNamespaceContext.NAMESPACE_URI, "description");

            this.description = description;
        }

        return this.description;
    }


    @Override
    public int getPosition() {
        if (this.position < 0) {
            String position = facet.getAttributeNS(
                ArtifactNamespaceContext.NAMESPACE_URI, "pos");

            if (position != null && position.length() > 0) {
                this.position = Integer.parseInt(position);
            }
        }

        return this.position;
    }


    @Override
    public void setPosition(int position) {
        this.position = position;

        facet.setAttributeNS(
            ArtifactNamespaceContext.NAMESPACE_URI,
            "pos",
            String.valueOf(position));
    }


    @Override
    public int getActive() {
        if (this.active < 0) {
            String active = facet.getAttributeNS(
                ArtifactNamespaceContext.NAMESPACE_URI, "active");

            if (active != null && active.length() > 0) {
                this.active = Integer.parseInt(active);
            }
        }

        return this.active;
    }


    @Override
    public void setActive(int active) {
        this.active = active;

        facet.setAttributeNS(
            ArtifactNamespaceContext.NAMESPACE_URI,
            "active",
            String.valueOf(active));
    }


    @Override
    public String getArtifact() {
        if (this.uuid == null || this.uuid.length() == 0) {
            String uuid = facet.getAttributeNS(
                ArtifactNamespaceContext.NAMESPACE_URI, "artifact");

            this.uuid = uuid;
        }

        return this.uuid;
    }


    @Override
    public Node toXML(Document doc) {
        return doc.importNode(facet, true);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org