Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java @ 1180:1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
flys-artifacts/trunk@2770 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 16 Sep 2011 08:47:09 +0000 |
parents | 28154920e0b3 |
children | 17648043429f |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Fri Sep 16 06:52:16 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Fri Sep 16 08:47:09 2011 +0000 @@ -83,7 +83,7 @@ while (iter.hasNext()) { String name = iter.next(); - appendStaticData(flys, meta, creator, ui, name); + appendStaticData(flys, context, creator, ui, name); } return ui; @@ -92,8 +92,8 @@ protected void appendStaticData( FLYSArtifact flys, - CallMeta meta, - ElementCreator creator, + CallContext context, + ElementCreator cr, Element ui, String name ) { @@ -106,9 +106,36 @@ logger.debug("Append element '" + name + "' (" + value + ")"); + Element e = createStaticData(cr, context, name, value, data.getType()); + + ui.appendChild(e); + + } + + + /** + * Creates a <i>data</i> element used in the static part of the DESCRIBE + * document. + * + * @param creator The ElementCreator that is used to build new Elements. + * @param meta The CallMeta object used for i18n. + * @param name The name of the data item. + * @param value The value as string. + * + * @return an Element. + */ + protected Element createStaticData( + ElementCreator creator, + CallContext cc, + String name, + String value, + String type + ) { + CallMeta meta = cc.getMeta(); + Element dataElement = creator.create("data"); creator.addAttr(dataElement, "name", name, true); - creator.addAttr(dataElement, "type", data.getType(), true); + creator.addAttr(dataElement, "type", type, true); Element itemElement = creator.create("item"); creator.addAttr(itemElement, "value", value, true); @@ -128,9 +155,9 @@ } creator.addAttr(itemElement, "label", attrValue, true); + dataElement.appendChild(itemElement); - dataElement.appendChild(itemElement); - ui.appendChild(dataElement); + return dataElement; } @@ -260,6 +287,34 @@ /** + * This method is used to create an <i>item</i> Element that contains two + * further elements <i>label</i> and <i>value</i>. The label and value + * elements both have text nodes. + * + * @param cr The ElementCreator used to build new Elements. + * @param obj This implementation awaits a String array with [0] = label and + * [1] = value. + * + * @return an Element. + */ + protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { + Element item = ProtocolUtils.createArtNode(cr, "item", null, null); + Element label = ProtocolUtils.createArtNode(cr, "label", null, null); + Element value = ProtocolUtils.createArtNode(cr, "value", null, null); + + String[] arr = (String[]) obj; + + label.setTextContent(arr[0]); + value.setTextContent(arr[1]); + + item.appendChild(label); + item.appendChild(value); + + return item; + } + + + /** * This method transform a given value into a StateData object. * * @param flys The FLYSArtifact.