// Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
//     METRIC,
//     COMPANY_INFO
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
// 
//     public String selector;
// 
//     public String type;
// 
//     public Object citeyear;
// 
//     public ReplaceField replace;
// 
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
// 
//     public List<String> regex;
// 
//     public List<String> with;
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
// 
//     public Object label;
// 
//     public Object value;
// 
//     public Object citeyear;
// 
//     public void setLabel(ExtractionProperties ep) {
//         label = ep;
//     }
// 
//     public void setValue(ExtractionProperties ep) {
//         value = ep;
//     }
// 
//     public void setCiteyear(ExtractionProperties ep) {
//         citeyear = ep;
//     }
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
// 
//     public HTMLElementNotFoundException() {
//     }
// 
//     public HTMLElementNotFoundException(String message) {
//         super(message);
//     }
// 
//     public HTMLElementNotFoundException(Throwable cause) {
//         super(cause);
//     }
// 
//     public HTMLElementNotFoundException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
//    public PostProcessingException(){
//       
//    }
//    
//    public PostProcessingException(String message){
//       super(message);
//    }
//    
//    public PostProcessingException(Throwable cause){
//       super(cause);
//    }
//    
//    public PostProcessingException(String message, Throwable cause){
//       super(message, cause);
//    }
// }


import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/*
 * Copyright 2016 vasgat.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package certh.iti.mklab.easie.extractors;


/**
 *
 * @author vasgat
 */
public abstract class AbstractContentExtractor {

    protected Element document;
    protected String source;

    abstract protected List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException;

    public List getExtractedFields(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
        return run(fields, type);
    }

    /**
     * Returns the content of a specific field in the document
     *
     * @param field
     * @return a Pair of String, Object that corresponds to field name and field
     * value accordingly
     */

// Path: src/main/java/certh/iti/mklab/easie/FIELD_TYPE.java
// public enum FIELD_TYPE {
//     METRIC,
//     COMPANY_INFO
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ExtractionProperties {
// 
//     public String selector;
// 
//     public String type;
// 
//     public Object citeyear;
// 
//     public ReplaceField replace;
// 
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ReplaceField {
// 
//     public List<String> regex;
// 
//     public List<String> with;
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/configuration/Configuration.java
// public static class ScrapableField {
// 
//     public Object label;
// 
//     public Object value;
// 
//     public Object citeyear;
// 
//     public void setLabel(ExtractionProperties ep) {
//         label = ep;
//     }
// 
//     public void setValue(ExtractionProperties ep) {
//         value = ep;
//     }
// 
//     public void setCiteyear(ExtractionProperties ep) {
//         citeyear = ep;
//     }
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/exception/HTMLElementNotFoundException.java
// public class HTMLElementNotFoundException extends Exception {
// 
//     public HTMLElementNotFoundException() {
//     }
// 
//     public HTMLElementNotFoundException(String message) {
//         super(message);
//     }
// 
//     public HTMLElementNotFoundException(Throwable cause) {
//         super(cause);
//     }
// 
//     public HTMLElementNotFoundException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/certh/iti/mklab/easie/exception/PostProcessingException.java
// public class PostProcessingException extends Exception {
//    public PostProcessingException(){
//       
//    }
//    
//    public PostProcessingException(String message){
//       super(message);
//    }
//    
//    public PostProcessingException(Throwable cause){
//       super(cause);
//    }
//    
//    public PostProcessingException(String message, Throwable cause){
//       super(message, cause);
//    }
// }


// Path: src/main/java/certh/iti/mklab/easie/extractors/AbstractContentExtractor.java
import certh.iti.mklab.easie.FIELD_TYPE;
import certh.iti.mklab.easie.configuration.Configuration.ExtractionProperties;
import certh.iti.mklab.easie.configuration.Configuration.ReplaceField;
import certh.iti.mklab.easie.configuration.Configuration.ScrapableField;
import certh.iti.mklab.easie.exception.HTMLElementNotFoundException;
import certh.iti.mklab.easie.exception.PostProcessingException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bson.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/*
 * Copyright 2016 vasgat.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package certh.iti.mklab.easie.extractors;


/**
 *
 * @author vasgat
 */
public abstract class AbstractContentExtractor {

    protected Element document;
    protected String source;

    abstract protected List run(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException;

    public List getExtractedFields(List<ScrapableField> fields, FIELD_TYPE type) throws HTMLElementNotFoundException {
        return run(fields, type);
    }

    /**
     * Returns the content of a specific field in the document
     *
     * @param field
     * @return a Pair of String, Object that corresponds to field name and field
     * value accordingly
     */

    protected Document getSelectedElement(ScrapableField field, Object e) throws PostProcessingException {
