class NodeReader {

    public List<WMSLayerState> readNode(Node node, boolean activateDataLayer)
    {
        List<WMSLayerState> layerStates = New.list();

        try
        {
            NodeList children = null;

            String path = activateDataLayer ? StateConstants.WMS_DATA_LAYER_PATH : StateConstants.WMS_MAP_LAYERS_PATH;
            children = StateXML.getChildNodes(node, path);

            if (children != null)
            {
                for (int i = 0; i < children.getLength(); i++)
                {
                    Node child = children.item(i);
                    try
                    {
                        WMSLayerState layerState = XMLUtilities.readXMLObject(child, WMSLayerState.class);
                        layerStates.add(layerState);
                    }
                    catch (JAXBException e)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.append("Failed to read WMS layer state for index ");
                        sb.append(i);
                        sb.append(", isDataLayer = ");
                        sb.append(activateDataLayer);
                        sb.append(e.getMessage());
                        LOGGER.error(sb.toString(), e);
                    }
                }
            }
        }
        catch (XPathExpressionException e)
        {
            LOGGER.error(e.getMessage(), e);
        }

        return layerStates;
    }

}