'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _xml = require('../xml.js');

var _xml2 = _interopRequireDefault(_xml);

function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

/**
 * @classdesc
 * Generic format for reading non-feature XML data
 *
 * @constructor
 * @abstract
 * @struct
 */
var _ol_format_XML_ = function () {};

/**
 * @param {Document|Node|string} source Source.
 * @return {Object} The parsed result.
 */
_ol_format_XML_.prototype.read = function (source) {
  if (_xml2.default.isDocument(source)) {
    return this.readFromDocument( /** @type {Document} */source);
  } else if (_xml2.default.isNode(source)) {
    return this.readFromNode( /** @type {Node} */source);
  } else if (typeof source === 'string') {
    var doc = _xml2.default.parse(source);
    return this.readFromDocument(doc);
  } else {
    return null;
  }
};

/**
 * @abstract
 * @param {Document} doc Document.
 * @return {Object} Object
 */
_ol_format_XML_.prototype.readFromDocument = function (doc) {};

/**
 * @abstract
 * @param {Node} node Node.
 * @return {Object} Object
 */
_ol_format_XML_.prototype.readFromNode = function (node) {};
exports.default = _ol_format_XML_;
module.exports = exports['default'];