public static LegendOptionData decodeXML(Document document,String elementName){
  LegendOptionData legendOptionData=new LegendOptionData();
  if ((document != null) && (elementName != null)) {
    NodeList nodeList=document.getElementsByTagName(elementName);
    if (nodeList.getLength() > 0) {
      Node node=nodeList.item(0);
      Node child=node.getFirstChild();
      while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
          String nodeName=child.getNodeName();
          if (nodeName.compareToIgnoreCase(IMAGE_WIDTH) == 0) {
            legendOptionData.setImageWidth(decodeIntElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(IMAGE_HEIGHT) == 0) {
            legendOptionData.setImageHeight(decodeIntElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(IMAGE_DPI) == 0) {
            legendOptionData.setDpi(decodeIntElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(IMAGE_SIZE) == 0) {
            legendOptionData.setImageSize(decodeIntElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(MAINTAIN_ASPECT_RATIO) == 0) {
            legendOptionData.setMaintainAspectRatio(decodeBooleanElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(SHOW_LABELS) == 0) {
            legendOptionData.setShowLabels(decodeBooleanElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(SHOW_TITLE) == 0) {
            legendOptionData.setShowTitle(decodeBooleanElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(SPLIT_SYMBOLIZERS) == 0) {
            legendOptionData.setSplitSymbolizers(decodeBooleanElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(FONT_ANTI_ALIASING) == 0) {
            legendOptionData.setFontAntiAliasing(decodeBooleanElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(SHOW_BORDER) == 0) {
            legendOptionData.setBorder(decodeBooleanElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(BAND_INFORMATION) == 0) {
            legendOptionData.setBandInformation(decodeBooleanElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(BACKGROUND_TRANSPARENT) == 0) {
            legendOptionData.setTransparent(decodeBooleanElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(LABEL_FONT) == 0) {
            legendOptionData.setLabelFont(decodeFontElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(LABEL_FONT_COLOUR) == 0) {
            legendOptionData.setLabelFontColour(decodeColourElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(BORDER_COLOUR) == 0) {
            legendOptionData.setBorderColour(decodeColourElement(document,child));
          }
 else           if (nodeName.compareToIgnoreCase(BACKGROUND_COLOUR) == 0) {
            legendOptionData.setBackgroundColour(decodeColourElement(document,child));
          }
        }
        child=child.getNextSibling();
      }
    }
  }
  return legendOptionData;
}

public static LegendOptionData decodeXML ( Document document , String elementName ) { LegendOptionData legendOptionData = new LegendOptionData ( ) ; if ( ( document != null ) && ( elementName != null ) ) { NodeList nodeList = document . getElementsByTagName ( elementName ) ; if ( nodeList . getLength ( ) > 0 ) { Node node = nodeList . item ( 0 ) ; Node child = node . getFirstChild ( ) ; while ( child != null ) { if ( child . getNodeType ( ) == Node . ELEMENT_NODE ) { String nodeName = child . getNodeName ( ) ; if ( nodeName . compareToIgnoreCase ( IMAGE_WIDTH ) == 0 ) { legendOptionData . setImageWidth ( decodeIntElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( IMAGE_HEIGHT ) == 0 ) { legendOptionData . setImageHeight ( decodeIntElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( IMAGE_DPI ) == 0 ) { legendOptionData . setDpi ( decodeIntElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( IMAGE_SIZE ) == 0 ) { legendOptionData . setImageSize ( decodeIntElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( MAINTAIN_ASPECT_RATIO ) == 0 ) { legendOptionData . setMaintainAspectRatio ( decodeBooleanElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( SHOW_LABELS ) == 0 ) { legendOptionData . setShowLabels ( decodeBooleanElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( SHOW_TITLE ) == 0 ) { legendOptionData . setShowTitle ( decodeBooleanElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( SPLIT_SYMBOLIZERS ) == 0 ) { legendOptionData . setSplitSymbolizers ( decodeBooleanElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( FONT_ANTI_ALIASING ) == 0 ) { legendOptionData . setFontAntiAliasing ( decodeBooleanElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( SHOW_BORDER ) == 0 ) { legendOptionData . setBorder ( decodeBooleanElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( BAND_INFORMATION ) == 0 ) { legendOptionData . setBandInformation ( decodeBooleanElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( BACKGROUND_TRANSPARENT ) == 0 ) { legendOptionData . setTransparent ( decodeBooleanElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( LABEL_FONT ) == 0 ) { legendOptionData . setLabelFont ( decodeFontElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( LABEL_FONT_COLOUR ) == 0 ) { legendOptionData . setLabelFontColour ( decodeColourElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( BORDER_COLOUR ) == 0 ) { legendOptionData . setBorderColour ( decodeColourElement ( document , child ) ) ; } else if ( nodeName . compareToIgnoreCase ( BACKGROUND_COLOUR ) == 0 ) { legendOptionData . setBackgroundColour ( decodeColourElement ( document , child ) ) ; } } child = child . getNextSibling ( ) ; } } } return legendOptionData ; }
decode the legend options from xml .
