001/*
002 *  Copyright 2014 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.contentio.in.xml;
017
018import java.io.IOException;
019import java.io.InputStream;
020
021import org.w3c.dom.Document;
022
023import org.ametys.plugins.contentio.ContentImporter;
024
025/**
026 * {@link ContentImporter} which imports contents from XML files.<br>
027 * The {@link #supports(Document)} method is used instead of the {@link #supports(InputStream, String)},
028 * so that the XML file is parsed only once.
029 */
030public interface XmlContentImporter extends ContentImporter
031{
032    
033    /**
034     * Tests if the {@link ContentImporter} is able to import the corresponding stream.<br>
035     * Implementing classes should first test the file extension, if possible, and if the name is provided.
036     * @param is an input stream on the file, cannot be null. The stream is closed by the caller.
037     * @param name the file name, can be null.
038     * @return true if the {@link ContentImporter} can import the corresponding stream, false otherwise.
039     * @throws IOException if an error occurs.
040     */
041    
042    /**
043     * Tests if the {@link XmlContentImporter} is able to import the corresponding Document.
044     * @param document the XML {@link Document} to test.
045     * @return true if the {@link XmlContentImporter} can import the corresponding stream, false otherwise.
046     * @throws IOException if an error occurs.
047     */
048    public boolean supports(Document document) throws IOException;
049    
050}