/*
 * Copyright 2010 akquinet
 * 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 de.akquinet.chameria.launcher;

import java.awt.SplashScreen;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.osgi.framework.BundleException;
import org.osgi.framework.launch.Framework;
import org.ow2.chameleon.core.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.trolltech.qt.core.QCoreApplication;
import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QIcon;

/**
 * Main class starting a ChameRIA application.
 */
public class Launcher {

    private static ChameRIA m_chameleon;

    /**
     * Constructor to avoid creating a new Launcher object.
     */
    private Launcher() { }

    public static void main(String[] args) throws Exception {

        String loc = System.getProperty("chameria.install.location");
        File root = null;
        if (loc != null) {
            root = new File(loc);
        } else {
            root = new File(System.getProperty("user.dir"));
        }

        printWelcomeBanner();

        m_chameleon = null;
        try {
            m_chameleon = createChameleon(args);
        } catch (Exception e) {
            System.err
                    .println("Cannot initalize Chameleon : " + e.getMessage());
            e.printStackTrace();
        }
        if (m_chameleon == null) {
            return;
        }

        final Logger logger = LoggerFactory.getLogger("Chameria-Launcher");
        registerShutdownHook(m_chameleon);
        try {
            logger.info("Initiliazing QT");
            // In order to enable the anti-aliasing of rounded corner, we set the
            // graphic system to 'raster'. opengl is currently not supported on mac.
            QApplication.setGraphicsSystem("raster");
            QApplication.initialize(new String[0]);

            // Add plugins.
            File qt = new File(root, "qt");
            File plugins = new File(qt, "plugins");
            if (plugins.exists()) {
                QCoreApplication.addLibraryPath(plugins.getAbsolutePath());
            }

            logger.info("QT initialized");

            configureApplication();
            logger.info("Application configured");

            Framework fmwk = m_chameleon.start(args);
            if (fmwk != null) {
                // The framework was created,
                // If a splash screen is here, removed it
                SplashScreen splash = SplashScreen.getSplashScreen();
                if (splash != null) {
                    splash.close();
                }

                QApplication.exec();
            }
            // Else we just exit immediately.
            // Reason might be the .lock file...

            m_chameleon.stop();
            logger.info("Chameleon Stopped");
        } catch (BundleException e) {
            System.err.println("Cannot start Chameleon : " + e.getMessage());
        }

    }

    public static ChameRIA getChameleon() {
        return m_chameleon;
    }

    /**
     * Configures the application.
     */
    private static void configureApplication() {
        // Try to load the file.
        File file = new File("chameria.props");
        if (file.exists()) {
            Properties props = new Properties();
            InputStream is = null;
            try {
                is = new FileInputStream(file);
                props.load(is);

                String n = props.getProperty("application.name");
                if (n != null) {
                    QApplication.setApplicationName(n);
                } else {
                    QApplication.setApplicationName("akquinet ChameRIA");
                }

                n = props.getProperty("application.version");
                if (n != null) {
                    QApplication.setApplicationVersion(n);
                }

                n = props.getProperty("application.icon");
                if (n != null) {
                    QIcon icon = new QIcon(n);
                    QApplication.setWindowIcon(icon);
                }

            } catch (Exception e) {
                System.err.println("Cannot read the application configuration "
                        + e.getMessage());
                e.printStackTrace();
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                        // Ignored
                    }
                }
            }
        }

        QApplication.setOrganizationName("akquinet A.G.");
    }

    /**
     * Prints Welcome Banner.
     */
    private static void printWelcomeBanner() {
        StringBuffer banner = new StringBuffer();
        banner.append("\n");
        banner.append("\t============================\n");
        banner.append("\t|                          |\n");
        banner.append("\t|   Welcome to ChameRIA    |\n");
        banner.append("\t|                          |\n");
        banner.append("\t============================\n");
        banner.append("\n");
        System.out.println(banner);
    }

    /**
     * Prints Stopped Banner.
     */
    private static void printStoppedBanner() {
        System.out.println("\n");
        System.out.println("\t=========================");
        System.out.println("\t|   ChameRIA  stopped   |");
        System.out.println("\t=========================");
        System.out.println("\n");
    }

    /**
     * Creates the Chameleon instance.The instance is not started.
     * @param args the command line parameters.
     * @return the Chameleon instance
     * @throws Exception if the chameleon instance cannot be created correctly.
     */
    public static ChameRIA createChameleon(String[] args) throws Exception {
        boolean debug = isDebugModeEnabled(args);
        String core = getCore(args);
        String app = getApp(args);
        String runtime = getRuntime(args);
        String fileinstall = getDeployDirectory(args);
        String config = getProps(args);
        if (config == null  || ! new File(config).exists()) {
            return new ChameRIA(core, debug, app, runtime, fileinstall, null);
        } else {
            return new ChameRIA(core, debug, app, runtime, fileinstall, config);
        }

    }

    /**
     * Parses the --deploy parameter.
     * @param args the parameters.
     * @return the deploy folder or null if not found.
     */
    private static String getDeployDirectory(String[] args) {
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (StringUtils.contains(arg, "--deploy=")) {
                return arg.substring("--deploy=".length());
            }
        }
        return null;
    }

    /**
     * Registers a shutdown hook to stop nicely the embedded framework.
     * @param chameleon the stopped chameleon
     */
    private static void registerShutdownHook(final ChameRIA chameleon) {
        Runtime runtime = Runtime.getRuntime();
        Runnable hook = new Runnable() {

            public void run() {
                try {
                    if (chameleon != null) {
                        chameleon.stop();
                        printStoppedBanner();
                    }
                } catch (BundleException e) {
                    System.err.println("Cannot stop Chameleon correctly : "
                            + e.getMessage());
                } catch (InterruptedException e) {
                    System.err.println("Unexpected Exception : "
                            + e.getMessage());
                    // nothing to do
                }
            }
        };
        runtime.addShutdownHook(new Thread(hook));

    }

    /**
     * Parses the --debug parameter.
     * @param args the parameters.
     * @return true if the debug mode is enabled.
     */
    private static boolean isDebugModeEnabled(String[] args) {
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (arg.equalsIgnoreCase("--debug")) {
                return true;
            }
        }
        return false;

    }

    /**
     * Parses the --core parameter.
     * @param args the parameters.
     * @return the core folder or null if not found.
     */
    private static String getCore(String[] args) {
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (StringUtils.contains(arg, "--core=")) {
                return arg.substring("--core=".length());
            }
        }
        return null;
    }

    /**
     * Parses the --app parameter.
     * @param args the parameters.
     * @return the application folder or null if not found.
     */
    private static String getApp(String[] args) {
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (StringUtils.contains(arg, "--app=")) {
                return arg.substring("--app=".length());
            }
        }
        return null;
    }

    /**
     * Parses the --config parameter.
     * @param args the parameters.
     * @return the configuration file path or null if not found.
     */
    private static String getProps(String[] args) {
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (StringUtils.contains(arg, "--config=")) {
                return arg.substring("--config=".length());
            }
        }
        return null;
    }

    /**
     * Parses the --runtime parameter.
     * @param args the parameters.
     * @return the runtime folder or null if not found.
     */
    private static String getRuntime(String[] args) {
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (StringUtils.contains(arg, "--runtime=")) {
                return arg.substring("--runtime=".length());
            }
        }
        return null;
    }

}


/*
 * Copyright (c) 2002 Cunningham & Cunningham, Inc.
 * Copyright (c) 2009-2015 by Jochen Wierum & Cologne Intelligence
 *
 * This file is part of FitGoodies.
 *
 * FitGoodies is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FitGoodies is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with FitGoodies.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.cologneintelligence.fitgoodies;

import de.cologneintelligence.fitgoodies.htmlparser.FitCell;
import de.cologneintelligence.fitgoodies.htmlparser.FitRow;
import de.cologneintelligence.fitgoodies.typehandler.TypeHandler;
import de.cologneintelligence.fitgoodies.util.FitUtils;
import de.cologneintelligence.fitgoodies.util.WaitForResult;
import de.cologneintelligence.fitgoodies.valuereceivers.ValueReceiver;

import java.lang.reflect.Method;
import java.text.ParseException;
import java.util.List;

public class ActionFixture extends Fixture {

	public static final long DEFAULT_SLEEP_TIME = 100;

	protected final WaitForResult waitForResult;

	protected FitRow row;
	protected Object actor;

	private String currentCellParameter;

	public ActionFixture(WaitForResult waitForResult) {
		this.waitForResult = waitForResult;
		this.actor = this;
	}

	public ActionFixture() {
		this(new WaitForResult());
	}

	// Traversal ////////////////////////////////

    @Override
    protected void doRow(FitRow row) throws Exception {
        currentCellParameter = FitUtils.extractCellParameter(row.cells().get(0));
        this.row = row;
        super.doRow(row);
    }

    protected void doCells(List<FitCell> cells) {
		try {
			Method action = getClass().getMethod(cells.get(0).getFitValue());
			action.invoke(this);
		} catch (Exception e) {
			cells.get(0).exception(e);
		}
	}

	// Actions //////////////////////////////////

	public void start() throws Exception {
		actor = Class.forName(row.cells().get(1).getFitValue()).newInstance();
	}

	public void enter() throws Exception {
		Method method = method(1);
		String cellText = row.cells().get(2).getFitValue();
		method.invoke(actor, parse(method.getParameterTypes()[0], cellText));
	}

	private <T> T parse(Class<?> type, String cellText) throws java.text.ParseException {
		String preprocessedText = validator.preProcess(cellText);
		TypeHandler th = getTypeHandler(type, currentCellParameter);

		@SuppressWarnings("unchecked")
		T result = (T) th.parse(preprocessedText);

		return result;
	}

	public void press() throws Exception {
		method(0).invoke(actor);
	}

	public void check() throws Exception {
		ValueReceiver receiver = createReceiver(actor, method(0));
		check(row.cells().get(2), receiver, null);
	}

	// Utility //////////////////////////////////

	protected Method method(int args) throws NoSuchMethodException {
		return method(FitUtils.camel(row.cells().get(1).getFitValue()), args);
	}

	protected Method method(String name, int args) throws NoSuchMethodException {
		Method methods[] = actor.getClass().getMethods();
		Method result = null;

		for (Method m : methods) {
			if (m.getName().equals(name) && m.getParameterTypes().length == args) {
				if (result == null) {
					result = m;
				} else {
					throw new NoSuchMethodException("too many implementations");
				}
			}
		}
		if (result == null) {
			throw new NoSuchMethodException(name);
		}
		return result;
	}

	/**
	 * Waits until a method returns true. The command takes a method name
	 * without parameters and a return value of {@code Boolean} as the first
	 * parameter and a timeout in ms as the second parameter.

	 * The method is called every {@code sleepTime}ms, until it returns true or the timeout is
	 * exceeded.
     *
     * @throws ParseException when the cell cannot be parsed.
     * @throws NoSuchMethodException when the specified method does not exist.
	 */
	public void waitFor() throws ParseException, NoSuchMethodException {
		Method method = method(0);

		long maxTime = parse(Long.class, row.cells().get(2).getFitValue());
		long sleepTime = getSleepTime();

		waitForResult.wait(actor, method, maxTime, sleepTime);

		writeResultIntoCell(waitForResult);
	}

	private long getSleepTime() throws ParseException {
		long sleepTime = DEFAULT_SLEEP_TIME;
		if (row.size() > 3) {
			sleepTime = parse(Long.class, row.cells().get(3).getFitValue());
		}
		return sleepTime;
	}

	private void writeResultIntoCell(final WaitForResult waitForResult) {
        FitCell cell = row.cells().get(2);

        cell.setDisplayValue(Long.toString(waitForResult.getLastElapsedTime()));
		if (waitForResult.lastCallWasSuccessful()) {
            cell.right();
		} else {
            cell.wrong();
            cell.info("(Timeout)");
		}
	}

	private TypeHandler getTypeHandler(final Class<?> type, String currentCellParameter) {
		return typeHandlerFactory.getHandler(type, currentCellParameter);
	}

	/**
	 * Transforms the selected row into an "enter" command and
	 * reinterprets it.
	 *

	 * Example:
	 * Row content: {@code setEncoding | utf-8}

	 * Code in the fixture:
	 * {@code
	 * public void setEncoding() throws Exception {
	 * transformAndEnter();
	 * }
     * }
	 *

     * {@code
	 * public void setEncoding(String encoding) {
	 * // do stuff with encoding here
	 * }
     * }
	 *
	 * @throws Exception should be propagated to fit.
	 */
	protected final void transformAndEnter() throws Exception {
        FitCell cell = row.insert(0);
        cell.setFitValue("enter");

		Object oldActor = actor;
		actor = this;
		enter();
		actor = oldActor;

        row.remove(0);
	}

}


package net.typedrest.vaadin.views;

import com.google.common.eventbus.EventBus;
import net.typedrest.*;
import net.typedrest.vaadin.events.TriggerEvent;
import com.vaadin.ui.*;
import org.apache.http.*;
import java.io.*;

/**
 * View component operating on a {@link ActionEndpoint}.
 */
public class ActionView extends AbstractEndpointView<ActionEndpoint> {

    protected final Button button;

    /**
     * Creates a new REST trigger endpoint component.
     *
     * @param endpoint The REST endpoint this component operates on.
     * @param eventBus Used to send event between components.
     * @param caption A caption for the triggerable action.
     */
    @SuppressWarnings("OverridableMethodCallInConstructor") // False positive due to lambda
    public ActionView(ActionEndpoint endpoint, EventBus eventBus, String caption) {
        super(endpoint, eventBus);
        setWidthUndefined();

        setCompositionRoot(button = new Button(caption, x -> trigger()));
    }

    @Override
    protected void onLoad() {
        try {
            endpoint.probe();
        } catch (IOException | IllegalAccessException | RuntimeException ex) {
            // HTTP OPTIONS server-side implementation is optional
        }

        endpoint.isTriggerAllowed().ifPresent(this::setEnabled);
    }

    /**
     * Triggers the action.
     */
    public void trigger() {
        try {
            onTrigger();
            Notification.show(getCaption(), "Successful.", Notification.Type.TRAY_NOTIFICATION);
        } catch (IOException | IllegalArgumentException | IllegalAccessException | IllegalStateException ex) {
            onError(ex);
        }
    }

    /**
     * Handler for triggering the action.
     *
     * @throws IOException Network communication failed.
     * @throws IllegalArgumentException {@link HttpStatus#SC_BAD_REQUEST}
     * @throws IllegalAccessException {@link HttpStatus#SC_UNAUTHORIZED} or
     * {@link HttpStatus#SC_FORBIDDEN}
     * @throws FileNotFoundException {@link HttpStatus#SC_NOT_FOUND} or
     * {@link HttpStatus#SC_GONE}
     * @throws IllegalStateException {@link HttpStatus#SC_CONFLICT}
     * @throws RuntimeException Other non-success status code.
     */
    protected void onTrigger()
            throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException {
        endpoint.trigger();
        eventBus.post(new TriggerEvent(endpoint));
    }
}


/*
 * Copyright (c) 2002 Cunningham & Cunningham, Inc.
 * Copyright (c) 2009-2015 by Jochen Wierum & Cologne Intelligence
 *
 * This file is part of FitGoodies.
 *
 * FitGoodies is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FitGoodies is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with FitGoodies.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.cologneintelligence.fitgoodies.log4j;

import org.apache.log4j.Level;
import org.apache.log4j.spi.LoggingEvent;

import java.util.Map;

/**
 * Abstract class which decides which logging event matches given conditions.
 * The method {@link #matches(LoggingEvent)} must be overridden to provide
 * custom matches.
 * <p>
 * The class uses two parameters of the map: minlevel and thread. They are used
 * to pre-filter the matches. If minlevel is set, only log entries with this
 * level or higher are analyzed. If thread is set, only log entries produced by
 * the given thread are analyzed.
 */
public abstract class AbstractLoggingEventMatcher {
	/**
	 * Gets the first matching event which matches {@link #matches(LoggingEvent)}
	 * and the given parameters.
	 *
	 * @param events     log entries to process
	 * @param parameters filter parameters
	 * @return first matching log entry or {@code null} otherwise
	 */
	public final LoggingEvent getFirstMatchingEvent(final LoggingEvent[] events,
	                                                final Map<String, String> parameters) {

		for (LoggingEvent event : events) {
			if (matchesParameters(event, parameters) && matches(event)) {
				return event;
			}
		}
		return null;
	}

	private boolean matchesParameters(final LoggingEvent event,
	                                  final Map<String, String> parameters) {
		if (!isSelectedThread(event, parameters)) {
			return false;
		} else if (!isSelectedLevel(event, parameters)) {
			return false;
		}

		return true;
	}

	private boolean isSelectedLevel(final LoggingEvent event,
	                                final Map<String, String> parameters) {
		if (!parameters.containsKey("minlevel")) {
			return true;
		} else {
			return event.getLevel().isGreaterOrEqual(
					Level.toLevel(parameters.get("minlevel")));
		}
	}

	private boolean isSelectedThread(final LoggingEvent event,
	                                 final Map<String, String> parameters) {
		if (!parameters.containsKey("thread")) {
			return true;
		} else {
			return parameters.get("thread").equalsIgnoreCase(event.getThreadName());
		}
	}

	/**
	 * Called to check whether a event matches custom conditions.
	 *
	 * @param event event to process
	 * @return {@code true} iif the event matches
	 */
	abstract boolean matches(LoggingEvent event);
}


/*
 * Copyright (c) 2002 Cunningham & Cunningham, Inc.
 * Copyright (c) 2009-2015 by Jochen Wierum & Cologne Intelligence
 *
 * This file is part of FitGoodies.
 *
 * FitGoodies is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FitGoodies is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with FitGoodies.  If not, see <http://www.gnu.org/licenses/>.
*/

package de.cologneintelligence.fitgoodies.runners;

import de.cologneintelligence.fitgoodies.Counts;
import de.cologneintelligence.fitgoodies.htmlparser.FitCell;
import de.cologneintelligence.fitgoodies.htmlparser.FitRow;
import de.cologneintelligence.fitgoodies.htmlparser.FitTable;
import de.cologneintelligence.fitgoodies.util.FitUtils;

import java.io.*;
import java.util.LinkedList;
import java.util.List;

/**
 * Implementation of {@link FitResult} which replaces a Parse-Row with one
 * or more results. The fixture is used with {@link RunFixture}, which uses
 * a dummy cell. This dummy cell is preserved.
 */

public final class FitParseResult implements FitResult {
	private final List<FileCount> results = new LinkedList<>();

	@Override
	public void print(final File directory, final OutputStream stream) throws IOException {
		try (Writer writer = new OutputStreamWriter(stream); BufferedWriter bufferedWriter = new BufferedWriter(writer)) {

			bufferedWriter.write("

");
			bufferedWriter.write(directory.getName());
			bufferedWriter.write("
");

			for (FileCount fileCount : results) {
				bufferedWriter.write("
");
				bufferedWriter.write(file);
				bufferedWriter.write("");
				bufferedWriter.write("	");
				bufferedWriter.write(fileCount.getCounts().toString());
				bufferedWriter.write("
");
			}

			bufferedWriter.write("
");
		}
	}

	@Override
	public void put(final File file, final Counts result) {
		FileCount fileCount = new FileCount(file, result);
		if (results.contains(fileCount)) {
			results.remove(fileCount);
		}
		results.add(fileCount);
	}

	private String color(final Counts counts) {
		if (counts.wrong > 0 || counts.exceptions > 0) {
			return FitUtils.HTML_RED;
		} else {
			return FitUtils.HTML_GREEN;
		}
	}

	private void addRows(FitTable table, int index) {
        for (int i = 0; i < results.size(); i++) {
            FileCount fileCount = results.get(i);
            FitRow row = table.insert(index + i);

            FitCell cell = row.append();
            cell.setDisplayValueRaw(""
                + FitUtils.htmlSafeFile(fileCount.getFile()) + "");

            cell = row.append();
            cell.setDisplayValue(fileCount.getCounts().toString());

            if (fileCount.getCounts().wrong > 0 || fileCount.getCounts().exceptions > 0) {
                cell.wrong();
            } else {
                cell.right();
            }
        }
	}

    /**
	 * Replaces a row with one or more results.
	 *
     * @param row the row to replace
     */
	public void insertAndReplace(final FitRow row) {
        if (results.isEmpty()) {
            return;
        }

        int index = row.getIndex();
        FitTable table = row.getTable();
        table.remove(index);
        addRows(table, index);
	}

	/**
	 * Gets the sum of all results.
	 *
	 * @return sum of all saved results
	 */
	public Counts getCounts() {
		Counts counts = new Counts();
		for (FileCount fileCount : results) {
			counts.tally(fileCount.getCounts());
		}
		return counts;
	}
}


/*
 * Copyright (c) 2002 Cunningham & Cunningham, Inc.
 * Copyright (c) 2009-2015 by Jochen Wierum & Cologne Intelligence
 *
 * This file is part of FitGoodies.
 *
 * FitGoodies is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FitGoodies is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with FitGoodies.  If not, see <http://www.gnu.org/licenses/>.
*/

package de.cologneintelligence.fitgoodies.date;

import de.cologneintelligence.fitgoodies.ActionFixture;
import de.cologneintelligence.fitgoodies.typehandler.TypeHandler;
import de.cologneintelligence.fitgoodies.util.DependencyManager;

import java.text.SimpleDateFormat;

/**
 * This fixture allows it to set the locale and format of dates.
 * A {@link TypeHandler} uses these formats when it parse dates.
 *

 * Example to allow German dates:
 *

 *
fitgoodies.date.SetupFixture

 *
locale	de_DE

 *
format	dd.MM.yyyy hh:mm:ss

 *

 */
public class SetupFixture extends ActionFixture {
	/**
	 * Calls {@link #locale(String)}, using the next cell as its parameter.
	 *
	 * @throws Exception propagated to fit
	 */
	public void locale() throws Exception {
		transformAndEnter();
	}

	/**
	 * Calls {@link #format(String)}, using the next cell as its parameter.
	 *
	 * @throws Exception propagated to fit
	 */
	public void format() throws Exception {
		transformAndEnter();
	}

	/**
	 * Sets the locale value to {@code locale}.
	 *
	 * @param locale name of the local to use
	 * @see FitDateHelper#setLocale(String) SetupHelper.setLocale(String)
	 * @see FitDateHelper#getLocale() SetupHelper.getLocale()
	 */
	public void locale(final String locale) {
		FitDateHelper helper = DependencyManager.getOrCreate(FitDateHelper.class);
		helper.setLocale(locale);
	}

	/**
	 * Sets the format value to {@code format}.
	 *
	 * @param format format string which is parsable by {@link SimpleDateFormat}
	 * @see FitDateHelper#setFormat(String) SetupHelper.setFormat(String)
	 * @see FitDateHelper#getFormat() SetupHelper.getFormat()
	 */
	public void format(final String format) {
		FitDateHelper helper = DependencyManager.getOrCreate(FitDateHelper.class);
		helper.setFormat(format);
	}
}


/* First created by JCasGen Sat Apr 11 19:49:33 EDT 2015 */
package edu.cmu.lti.oaqa.type.answer;

import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.TOP_Type;

import org.apache.uima.jcas.cas.TOP;

import org.apache.uima.jcas.cas.StringList;

/** A short summary of ideal answer generated by the QA system.
 * Updated by JCasGen Sun Apr 19 19:46:49 EDT 2015
 * XML source: /home/yangzi/QA/baseqa/src/main/resources/baseqa/type/OAQATypes.xml
 * @generated */
public class Summary extends TOP {
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int typeIndexID = JCasRegistry.register(Summary.class);
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int type = typeIndexID;
  /** @generated
   * @return index of the type
   */
  @Override
  public              int getTypeIndexID() {return typeIndexID;}

  /** Never called.  Disable default constructor
   * @generated */
  protected Summary() {/* intentionally empty block */}

  /** Internal - constructor used by generator
   * @generated
   * @param addr low level Feature Structure reference
   * @param type the type of this Feature Structure
   */
  public Summary(int addr, TOP_Type type) {
    super(addr, type);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   */
  public Summary(JCas jcas) {
    super(jcas);
    readObject();
  }

  /**
   * <!-- begin-user-doc -->
   * Write your own initialization here
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  private void readObject() {/*default - does nothing empty block */}

  //*--------------*
  //* Feature: text

  /** getter for text - gets The actual answer string.
   * @generated
   * @return value of the feature
   */
  public String getText() {
    if (Summary_Type.featOkTst && ((Summary_Type)jcasType).casFeat_text == null)
      jcasType.jcas.throwFeatMissing("text", "edu.cmu.lti.oaqa.type.answer.Summary");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Summary_Type)jcasType).casFeatCode_text);}

  /** setter for text - sets The actual answer string.
   * @generated
   * @param v value to set into the feature
   */
  public void setText(String v) {
    if (Summary_Type.featOkTst && ((Summary_Type)jcasType).casFeat_text == null)
      jcasType.jcas.throwFeatMissing("text", "edu.cmu.lti.oaqa.type.answer.Summary");
    jcasType.ll_cas.ll_setStringValue(addr, ((Summary_Type)jcasType).casFeatCode_text, v);}

  //*--------------*
  //* Feature: score

  /** getter for score - gets The score associated with the answer.
   * @generated
   * @return value of the feature
   */
  public double getScore() {
    if (Summary_Type.featOkTst && ((Summary_Type)jcasType).casFeat_score == null)
      jcasType.jcas.throwFeatMissing("score", "edu.cmu.lti.oaqa.type.answer.Summary");
    return jcasType.ll_cas.ll_getDoubleValue(addr, ((Summary_Type)jcasType).casFeatCode_score);}

  /** setter for score - sets The score associated with the answer.
   * @generated
   * @param v value to set into the feature
   */
  public void setScore(double v) {
    if (Summary_Type.featOkTst && ((Summary_Type)jcasType).casFeat_score == null)
      jcasType.jcas.throwFeatMissing("score", "edu.cmu.lti.oaqa.type.answer.Summary");
    jcasType.ll_cas.ll_setDoubleValue(addr, ((Summary_Type)jcasType).casFeatCode_score, v);}

  //*--------------*
  //* Feature: variants

  /** getter for variants - gets List of alternative answer summaries.
   * @generated
   * @return value of the feature
   */
  public StringList getVariants() {
    if (Summary_Type.featOkTst && ((Summary_Type)jcasType).casFeat_variants == null)
      jcasType.jcas.throwFeatMissing("variants", "edu.cmu.lti.oaqa.type.answer.Summary");
    return (StringList)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Summary_Type)jcasType).casFeatCode_variants)));}

  /** setter for variants - sets List of alternative answer summaries.
   * @generated
   * @param v value to set into the feature
   */
  public void setVariants(StringList v) {
    if (Summary_Type.featOkTst && ((Summary_Type)jcasType).casFeat_variants == null)
      jcasType.jcas.throwFeatMissing("variants", "edu.cmu.lti.oaqa.type.answer.Summary");
    jcasType.ll_cas.ll_setRefValue(addr, ((Summary_Type)jcasType).casFeatCode_variants, jcasType.ll_cas.ll_getFSRef(v));}
  }


/* First created by JCasGen Sat Apr 11 19:49:33 EDT 2015 */
package edu.cmu.lti.oaqa.type.input;

import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.TOP_Type;

import org.apache.uima.jcas.tcas.Annotation;

/** The Question and any associated meta-data.
 * Updated by JCasGen Sun Apr 19 19:46:50 EDT 2015
 * XML source: /home/yangzi/QA/baseqa/src/main/resources/baseqa/type/OAQATypes.xml
 * @generated */
public class Question extends Annotation {
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int typeIndexID = JCasRegistry.register(Question.class);
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int type = typeIndexID;
  /** @generated
   * @return index of the type
   */
  @Override
  public              int getTypeIndexID() {return typeIndexID;}

  /** Never called.  Disable default constructor
   * @generated */
  protected Question() {/* intentionally empty block */}

  /** Internal - constructor used by generator
   * @generated
   * @param addr low level Feature Structure reference
   * @param type the type of this Feature Structure
   */
  public Question(int addr, TOP_Type type) {
    super(addr, type);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   */
  public Question(JCas jcas) {
    super(jcas);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   * @param begin offset to the begin spot in the SofA
   * @param end offset to the end spot in the SofA
  */
  public Question(JCas jcas, int begin, int end) {
    super(jcas);
    setBegin(begin);
    setEnd(end);
    readObject();
  }

  /**
   * <!-- begin-user-doc -->
   * Write your own initialization here
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  private void readObject() {/*default - does nothing empty block */}

  //*--------------*
  //* Feature: id

  /** getter for id - gets A unique id for the question.
   * @generated
   * @return value of the feature
   */
  public String getId() {
    if (Question_Type.featOkTst && ((Question_Type)jcasType).casFeat_id == null)
      jcasType.jcas.throwFeatMissing("id", "edu.cmu.lti.oaqa.type.input.Question");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Question_Type)jcasType).casFeatCode_id);}

  /** setter for id - sets A unique id for the question.
   * @generated
   * @param v value to set into the feature
   */
  public void setId(String v) {
    if (Question_Type.featOkTst && ((Question_Type)jcasType).casFeat_id == null)
      jcasType.jcas.throwFeatMissing("id", "edu.cmu.lti.oaqa.type.input.Question");
    jcasType.ll_cas.ll_setStringValue(addr, ((Question_Type)jcasType).casFeatCode_id, v);}

  //*--------------*
  //* Feature: source

  /** getter for source - gets The source of the question, e.g., TREC11, Jeopardy, etc.
   * @generated
   * @return value of the feature
   */
  public String getSource() {
    if (Question_Type.featOkTst && ((Question_Type)jcasType).casFeat_source == null)
      jcasType.jcas.throwFeatMissing("source", "edu.cmu.lti.oaqa.type.input.Question");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Question_Type)jcasType).casFeatCode_source);}

  /** setter for source - sets The source of the question, e.g., TREC11, Jeopardy, etc.
   * @generated
   * @param v value to set into the feature
   */
  public void setSource(String v) {
    if (Question_Type.featOkTst && ((Question_Type)jcasType).casFeat_source == null)
      jcasType.jcas.throwFeatMissing("source", "edu.cmu.lti.oaqa.type.input.Question");
    jcasType.ll_cas.ll_setStringValue(addr, ((Question_Type)jcasType).casFeatCode_source, v);}

  //*--------------*
  //* Feature: questionType

  /** getter for questionType - gets The class of the question, determined by either an automatic question classification process or human judgment.
   * @generated
   * @return value of the feature
   */
  public String getQuestionType() {
    if (Question_Type.featOkTst && ((Question_Type)jcasType).casFeat_questionType == null)
      jcasType.jcas.throwFeatMissing("questionType", "edu.cmu.lti.oaqa.type.input.Question");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Question_Type)jcasType).casFeatCode_questionType);}

  /** setter for questionType - sets The class of the question, determined by either an automatic question classification process or human judgment.
   * @generated
   * @param v value to set into the feature
   */
  public void setQuestionType(String v) {
    if (Question_Type.featOkTst && ((Question_Type)jcasType).casFeat_questionType == null)
      jcasType.jcas.throwFeatMissing("questionType", "edu.cmu.lti.oaqa.type.input.Question");
    jcasType.ll_cas.ll_setStringValue(addr, ((Question_Type)jcasType).casFeatCode_questionType, v);}

  //*--------------*
  //* Feature: text

  /** getter for text - gets The question content.
   * @generated
   * @return value of the feature
   */
  public String getText() {
    if (Question_Type.featOkTst && ((Question_Type)jcasType).casFeat_text == null)
      jcasType.jcas.throwFeatMissing("text", "edu.cmu.lti.oaqa.type.input.Question");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Question_Type)jcasType).casFeatCode_text);}

  /** setter for text - sets The question content.
   * @generated
   * @param v value to set into the feature
   */
  public void setText(String v) {
    if (Question_Type.featOkTst && ((Question_Type)jcasType).casFeat_text == null)
      jcasType.jcas.throwFeatMissing("text", "edu.cmu.lti.oaqa.type.input.Question");
    jcasType.ll_cas.ll_setStringValue(addr, ((Question_Type)jcasType).casFeatCode_text, v);}
  }


/**
 * Copyright © 2013 Sven Ruppert (sven.ruppert@gmail.com)
 *
 * 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 org.rapidpm.microservice.rest.ddi;

import org.jboss.resteasy.resteasy_jaxrs.i18n.Messages;
import org.jboss.resteasy.spi.ConstructorInjector;
import org.jboss.resteasy.spi.HttpRequest;
import org.jboss.resteasy.spi.HttpResponse;
import org.jboss.resteasy.spi.PropertyInjector;
import org.jboss.resteasy.spi.ResourceFactory;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.jboss.resteasy.spi.metadata.ResourceBuilder;
import org.jboss.resteasy.spi.metadata.ResourceClass;
import org.jboss.resteasy.spi.metadata.ResourceConstructor;
import org.rapidpm.ddi.DI;

/**
 *
 */
public class PoJoDDIRessourceFactory implements ResourceFactory {
  private final   Class<?>            scannableClass;
    private final ResourceClass       resourceClass;
  private         ConstructorInjector constructorInjector;
  private         PropertyInjector    propertyInjector;

  public PoJoDDIRessourceFactory(Class<?> scannableClass) {
    this.scannableClass = scannableClass;
    this.resourceClass = ResourceBuilder.rootResourceFromAnnotations(scannableClass);
  }

//  public PoJoDDIRessourceFactory(ResourceClass resourceClass) {
//    this.scannableClass = resourceClass.getClazz();
//    this.resourceClass = resourceClass;
//  }

  public void registered(ResteasyProviderFactory factory) {
    System.out.println("registered - factory = " + factory);
    ResourceConstructor constructor = this.resourceClass.getConstructor();
    if (constructor == null) {
      final Class<?> clazz = this.resourceClass.getClazz();
      final Class<?> aClass = DI.getSubTypesWithoutInterfacesAndGeneratedOf(clazz).stream().findFirst().get();
      constructor = ResourceBuilder.constructor(aClass);
    }
//
    if (constructor == null) {
      throw new RuntimeException(Messages.MESSAGES.unableToFindPublicConstructorForClass(this.scannableClass.getName()));
    } else {
      this.constructorInjector = factory.getInjectorFactory().createConstructor(constructor , factory);
      this.propertyInjector = factory.getInjectorFactory().createPropertyInjector(this.resourceClass , factory);
    }
  }

  public Object createResource(HttpRequest request , HttpResponse response , ResteasyProviderFactory factory) {
//    Object obj = this.constructorInjector.construct(request , response);
//    this.propertyInjector.inject(request , response , obj);
//    return obj;
    return DI.activateDI(scannableClass);
  }

  public void unregistered() {
  }

  public Class<?> getScannableClass() {
    return this.scannableClass;
  }

  public void requestFinished(HttpRequest request , HttpResponse response , Object resource) {
  }
}


/* First created by JCasGen Sat Apr 11 19:49:33 EDT 2015 */
package edu.cmu.lti.oaqa.type.nlp;

import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.TOP_Type;

import org.apache.uima.jcas.tcas.Annotation;

/** The phrase in the question that indicates the answer variable.
 * Updated by JCasGen Sun Apr 19 19:46:50 EDT 2015
 * XML source: /home/yangzi/QA/baseqa/src/main/resources/baseqa/type/OAQATypes.xml
 * @generated */
public class Focus extends Annotation {
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int typeIndexID = JCasRegistry.register(Focus.class);
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int type = typeIndexID;
  /** @generated
   * @return index of the type
   */
  @Override
  public              int getTypeIndexID() {return typeIndexID;}

  /** Never called.  Disable default constructor
   * @generated */
  protected Focus() {/* intentionally empty block */}

  /** Internal - constructor used by generator
   * @generated
   * @param addr low level Feature Structure reference
   * @param type the type of this Feature Structure
   */
  public Focus(int addr, TOP_Type type) {
    super(addr, type);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   */
  public Focus(JCas jcas) {
    super(jcas);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   * @param begin offset to the begin spot in the SofA
   * @param end offset to the end spot in the SofA
  */
  public Focus(JCas jcas, int begin, int end) {
    super(jcas);
    setBegin(begin);
    setEnd(end);
    readObject();
  }

  /**
   * <!-- begin-user-doc -->
   * Write your own initialization here
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  private void readObject() {/*default - does nothing empty block */}

  //*--------------*
  //* Feature: token

  /** getter for token - gets The corresponding token for the focus.
   * @generated
   * @return value of the feature
   */
  public Token getToken() {
    if (Focus_Type.featOkTst && ((Focus_Type)jcasType).casFeat_token == null)
      jcasType.jcas.throwFeatMissing("token", "edu.cmu.lti.oaqa.type.nlp.Focus");
    return (Token)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Focus_Type)jcasType).casFeatCode_token)));}

  /** setter for token - sets The corresponding token for the focus.
   * @generated
   * @param v value to set into the feature
   */
  public void setToken(Token v) {
    if (Focus_Type.featOkTst && ((Focus_Type)jcasType).casFeat_token == null)
      jcasType.jcas.throwFeatMissing("token", "edu.cmu.lti.oaqa.type.nlp.Focus");
    jcasType.ll_cas.ll_setRefValue(addr, ((Focus_Type)jcasType).casFeatCode_token, jcasType.ll_cas.ll_getFSRef(v));}

  //*--------------*
  //* Feature: label

  /** getter for label - gets String representation of the Question Focus.
   * @generated
   * @return value of the feature
   */
  public String getLabel() {
    if (Focus_Type.featOkTst && ((Focus_Type)jcasType).casFeat_label == null)
      jcasType.jcas.throwFeatMissing("label", "edu.cmu.lti.oaqa.type.nlp.Focus");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Focus_Type)jcasType).casFeatCode_label);}

  /** setter for label - sets String representation of the Question Focus.
   * @generated
   * @param v value to set into the feature
   */
  public void setLabel(String v) {
    if (Focus_Type.featOkTst && ((Focus_Type)jcasType).casFeat_label == null)
      jcasType.jcas.throwFeatMissing("label", "edu.cmu.lti.oaqa.type.nlp.Focus");
    jcasType.ll_cas.ll_setStringValue(addr, ((Focus_Type)jcasType).casFeatCode_label, v);}
  }


/* First created by JCasGen Sat Apr 11 19:49:33 EDT 2015 */
package edu.cmu.lti.oaqa.type.nlp;

import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.TOP_Type;

import org.apache.uima.jcas.tcas.Annotation;

/** Annotation on a token, which may have arguments if they are predicates; useful in transforming text into a "logical form", with affordances similar to the ones provided in Extended WordNet and the like.
 * Updated by JCasGen Sun Apr 19 19:46:50 EDT 2015
 * XML source: /home/yangzi/QA/baseqa/src/main/resources/baseqa/type/OAQATypes.xml
 * @generated */
public class Token extends Annotation {
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int typeIndexID = JCasRegistry.register(Token.class);
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int type = typeIndexID;
  /** @generated
   * @return index of the type
   */
  @Override
  public              int getTypeIndexID() {return typeIndexID;}

  /** Never called.  Disable default constructor
   * @generated */
  protected Token() {/* intentionally empty block */}

  /** Internal - constructor used by generator
   * @generated
   * @param addr low level Feature Structure reference
   * @param type the type of this Feature Structure
   */
  public Token(int addr, TOP_Type type) {
    super(addr, type);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   */
  public Token(JCas jcas) {
    super(jcas);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   * @param begin offset to the begin spot in the SofA
   * @param end offset to the end spot in the SofA
  */
  public Token(JCas jcas, int begin, int end) {
    super(jcas);
    setBegin(begin);
    setEnd(end);
    readObject();
  }

  /**
   * <!-- begin-user-doc -->
   * Write your own initialization here
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  private void readObject() {/*default - does nothing empty block */}

  //*--------------*
  //* Feature: head

  /** getter for head - gets The head of the token in the dependency parse tree.
   * @generated
   * @return value of the feature
   */
  public Token getHead() {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_head == null)
      jcasType.jcas.throwFeatMissing("head", "edu.cmu.lti.oaqa.type.nlp.Token");
    return (Token)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Token_Type)jcasType).casFeatCode_head)));}

  /** setter for head - sets The head of the token in the dependency parse tree.
   * @generated
   * @param v value to set into the feature
   */
  public void setHead(Token v) {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_head == null)
      jcasType.jcas.throwFeatMissing("head", "edu.cmu.lti.oaqa.type.nlp.Token");
    jcasType.ll_cas.ll_setRefValue(addr, ((Token_Type)jcasType).casFeatCode_head, jcasType.ll_cas.ll_getFSRef(v));}

  //*--------------*
  //* Feature: depLabel

  /** getter for depLabel - gets The dependency label of the token with respect to its head.
   * @generated
   * @return value of the feature
   */
  public String getDepLabel() {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_depLabel == null)
      jcasType.jcas.throwFeatMissing("depLabel", "edu.cmu.lti.oaqa.type.nlp.Token");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Token_Type)jcasType).casFeatCode_depLabel);}

  /** setter for depLabel - sets The dependency label of the token with respect to its head.
   * @generated
   * @param v value to set into the feature
   */
  public void setDepLabel(String v) {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_depLabel == null)
      jcasType.jcas.throwFeatMissing("depLabel", "edu.cmu.lti.oaqa.type.nlp.Token");
    jcasType.ll_cas.ll_setStringValue(addr, ((Token_Type)jcasType).casFeatCode_depLabel, v);}

  //*--------------*
  //* Feature: semanticType

  /** getter for semanticType - gets A semantic type, typically the name of an Entity Annotation type.
   * @generated
   * @return value of the feature
   */
  public String getSemanticType() {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_semanticType == null)
      jcasType.jcas.throwFeatMissing("semanticType", "edu.cmu.lti.oaqa.type.nlp.Token");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Token_Type)jcasType).casFeatCode_semanticType);}

  /** setter for semanticType - sets A semantic type, typically the name of an Entity Annotation type.
   * @generated
   * @param v value to set into the feature
   */
  public void setSemanticType(String v) {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_semanticType == null)
      jcasType.jcas.throwFeatMissing("semanticType", "edu.cmu.lti.oaqa.type.nlp.Token");
    jcasType.ll_cas.ll_setStringValue(addr, ((Token_Type)jcasType).casFeatCode_semanticType, v);}

  //*--------------*
  //* Feature: partOfSpeech

  /** getter for partOfSpeech - gets Coarse-grained part of speech. --- Example: noun, verb, adj, cord
   * @generated
   * @return value of the feature
   */
  public String getPartOfSpeech() {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_partOfSpeech == null)
      jcasType.jcas.throwFeatMissing("partOfSpeech", "edu.cmu.lti.oaqa.type.nlp.Token");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Token_Type)jcasType).casFeatCode_partOfSpeech);}

  /** setter for partOfSpeech - sets Coarse-grained part of speech. --- Example: noun, verb, adj, cord
   * @generated
   * @param v value to set into the feature
   */
  public void setPartOfSpeech(String v) {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_partOfSpeech == null)
      jcasType.jcas.throwFeatMissing("partOfSpeech", "edu.cmu.lti.oaqa.type.nlp.Token");
    jcasType.ll_cas.ll_setStringValue(addr, ((Token_Type)jcasType).casFeatCode_partOfSpeech, v);}

  //*--------------*
  //* Feature: lemmaForm

  /** getter for lemmaForm - gets A canonical/lemmatized form of the covered text.
   * @generated
   * @return value of the feature
   */
  public String getLemmaForm() {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_lemmaForm == null)
      jcasType.jcas.throwFeatMissing("lemmaForm", "edu.cmu.lti.oaqa.type.nlp.Token");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Token_Type)jcasType).casFeatCode_lemmaForm);}

  /** setter for lemmaForm - sets A canonical/lemmatized form of the covered text.
   * @generated
   * @param v value to set into the feature
   */
  public void setLemmaForm(String v) {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_lemmaForm == null)
      jcasType.jcas.throwFeatMissing("lemmaForm", "edu.cmu.lti.oaqa.type.nlp.Token");
    jcasType.ll_cas.ll_setStringValue(addr, ((Token_Type)jcasType).casFeatCode_lemmaForm, v);}

  //*--------------*
  //* Feature: isMainReference

  /** getter for isMainReference - gets If true, then this is the main reference to the first argument. Modifiers and anaphoric references do not have isMainReference set. --- Example: "A dark blue [hat]"
   * @generated
   * @return value of the feature
   */
  public boolean getIsMainReference() {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_isMainReference == null)
      jcasType.jcas.throwFeatMissing("isMainReference", "edu.cmu.lti.oaqa.type.nlp.Token");
    return jcasType.ll_cas.ll_getBooleanValue(addr, ((Token_Type)jcasType).casFeatCode_isMainReference);}

  /** setter for isMainReference - sets If true, then this is the main reference to the first argument. Modifiers and anaphoric references do not have isMainReference set. --- Example: "A dark blue [hat]"
   * @generated
   * @param v value to set into the feature
   */
  public void setIsMainReference(boolean v) {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_isMainReference == null)
      jcasType.jcas.throwFeatMissing("isMainReference", "edu.cmu.lti.oaqa.type.nlp.Token");
    jcasType.ll_cas.ll_setBooleanValue(addr, ((Token_Type)jcasType).casFeatCode_isMainReference, v);}

  //*--------------*
  //* Feature: isVariable

  /** getter for isVariable - gets True iff the token expresses some unknown entity, typically the focus of a question: --- Example: "[Who] shot JR?", "What [city] was JR born in?"
   * @generated
   * @return value of the feature
   */
  public boolean getIsVariable() {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_isVariable == null)
      jcasType.jcas.throwFeatMissing("isVariable", "edu.cmu.lti.oaqa.type.nlp.Token");
    return jcasType.ll_cas.ll_getBooleanValue(addr, ((Token_Type)jcasType).casFeatCode_isVariable);}

  /** setter for isVariable - sets True iff the token expresses some unknown entity, typically the focus of a question: --- Example: "[Who] shot JR?", "What [city] was JR born in?"
   * @generated
   * @param v value to set into the feature
   */
  public void setIsVariable(boolean v) {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_isVariable == null)
      jcasType.jcas.throwFeatMissing("isVariable", "edu.cmu.lti.oaqa.type.nlp.Token");
    jcasType.ll_cas.ll_setBooleanValue(addr, ((Token_Type)jcasType).casFeatCode_isVariable, v);}

  //*--------------*
  //* Feature: determiner

  /** getter for determiner - gets The determiner attached to the node, if any --- Example: [the] book
   * @generated
   * @return value of the feature
   */
  public String getDeterminer() {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_determiner == null)
      jcasType.jcas.throwFeatMissing("determiner", "edu.cmu.lti.oaqa.type.nlp.Token");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Token_Type)jcasType).casFeatCode_determiner);}

  /** setter for determiner - sets The determiner attached to the node, if any --- Example: [the] book
   * @generated
   * @param v value to set into the feature
   */
  public void setDeterminer(String v) {
    if (Token_Type.featOkTst && ((Token_Type)jcasType).casFeat_determiner == null)
      jcasType.jcas.throwFeatMissing("determiner", "edu.cmu.lti.oaqa.type.nlp.Token");
    jcasType.ll_cas.ll_setStringValue(addr, ((Token_Type)jcasType).casFeatCode_determiner, v);}
  }


/* First created by JCasGen Sat Apr 11 19:49:33 EDT 2015 */
package edu.cmu.lti.oaqa.type.retrieval;

import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.TOP_Type;

import org.apache.uima.jcas.cas.StringArray;

/** A document search result.
 * Updated by JCasGen Sun Apr 19 19:46:50 EDT 2015
 * XML source: /home/yangzi/QA/baseqa/src/main/resources/baseqa/type/OAQATypes.xml
 * @generated */
public class Document extends SearchResult {
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int typeIndexID = JCasRegistry.register(Document.class);
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int type = typeIndexID;
  /** @generated
   * @return index of the type
   */
  @Override
  public              int getTypeIndexID() {return typeIndexID;}

  /** Never called.  Disable default constructor
   * @generated */
  protected Document() {/* intentionally empty block */}

  /** Internal - constructor used by generator
   * @generated
   * @param addr low level Feature Structure reference
   * @param type the type of this Feature Structure
   */
  public Document(int addr, TOP_Type type) {
    super(addr, type);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   */
  public Document(JCas jcas) {
    super(jcas);
    readObject();
  }

  /**
   * <!-- begin-user-doc -->
   * Write your own initialization here
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  private void readObject() {/*default - does nothing empty block */}

  //*--------------*
  //* Feature: title

  /** getter for title - gets The title of the document.
   * @generated
   * @return value of the feature
   */
  public String getTitle() {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_title == null)
      jcasType.jcas.throwFeatMissing("title", "edu.cmu.lti.oaqa.type.retrieval.Document");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Document_Type)jcasType).casFeatCode_title);}

  /** setter for title - sets The title of the document.
   * @generated
   * @param v value to set into the feature
   */
  public void setTitle(String v) {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_title == null)
      jcasType.jcas.throwFeatMissing("title", "edu.cmu.lti.oaqa.type.retrieval.Document");
    jcasType.ll_cas.ll_setStringValue(addr, ((Document_Type)jcasType).casFeatCode_title, v);}

  //*--------------*
  //* Feature: docId

  /** getter for docId - gets A unique identifier for this document.
   * @generated
   * @return value of the feature
   */
  public String getDocId() {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_docId == null)
      jcasType.jcas.throwFeatMissing("docId", "edu.cmu.lti.oaqa.type.retrieval.Document");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Document_Type)jcasType).casFeatCode_docId);}

  /** setter for docId - sets A unique identifier for this document.
   * @generated
   * @param v value to set into the feature
   */
  public void setDocId(String v) {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_docId == null)
      jcasType.jcas.throwFeatMissing("docId", "edu.cmu.lti.oaqa.type.retrieval.Document");
    jcasType.ll_cas.ll_setStringValue(addr, ((Document_Type)jcasType).casFeatCode_docId, v);}

  //*--------------*
  //* Feature: sections

  /** getter for sections - gets Content of sections in the document.
   * @generated
   * @return value of the feature
   */
  public StringArray getSections() {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_sections == null)
      jcasType.jcas.throwFeatMissing("sections", "edu.cmu.lti.oaqa.type.retrieval.Document");
    return (StringArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sections)));}

  /** setter for sections - sets Content of sections in the document.
   * @generated
   * @param v value to set into the feature
   */
  public void setSections(StringArray v) {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_sections == null)
      jcasType.jcas.throwFeatMissing("sections", "edu.cmu.lti.oaqa.type.retrieval.Document");
    jcasType.ll_cas.ll_setRefValue(addr, ((Document_Type)jcasType).casFeatCode_sections, jcasType.ll_cas.ll_getFSRef(v));}

  /** indexed getter for sections - gets an indexed value - Content of sections in the document.
   * @generated
   * @param i index in the array to get
   * @return value of the element at index i
   */
  public String getSections(int i) {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_sections == null)
      jcasType.jcas.throwFeatMissing("sections", "edu.cmu.lti.oaqa.type.retrieval.Document");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sections), i);
    return jcasType.ll_cas.ll_getStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sections), i);}

  /** indexed setter for sections - sets an indexed value - Content of sections in the document.
   * @generated
   * @param i index in the array to set
   * @param v value to set into the array
   */
  public void setSections(int i, String v) {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_sections == null)
      jcasType.jcas.throwFeatMissing("sections", "edu.cmu.lti.oaqa.type.retrieval.Document");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sections), i);
    jcasType.ll_cas.ll_setStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sections), i, v);}

  //*--------------*
  //* Feature: sectionLabels

  /** getter for sectionLabels - gets Section labels in the document, e.g. sections.0, sections1, etc.
   * @generated
   * @return value of the feature
   */
  public StringArray getSectionLabels() {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_sectionLabels == null)
      jcasType.jcas.throwFeatMissing("sectionLabels", "edu.cmu.lti.oaqa.type.retrieval.Document");
    return (StringArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sectionLabels)));}

  /** setter for sectionLabels - sets Section labels in the document, e.g. sections.0, sections1, etc.
   * @generated
   * @param v value to set into the feature
   */
  public void setSectionLabels(StringArray v) {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_sectionLabels == null)
      jcasType.jcas.throwFeatMissing("sectionLabels", "edu.cmu.lti.oaqa.type.retrieval.Document");
    jcasType.ll_cas.ll_setRefValue(addr, ((Document_Type)jcasType).casFeatCode_sectionLabels, jcasType.ll_cas.ll_getFSRef(v));}

  /** indexed getter for sectionLabels - gets an indexed value - Section labels in the document, e.g. sections.0, sections1, etc.
   * @generated
   * @param i index in the array to get
   * @return value of the element at index i
   */
  public String getSectionLabels(int i) {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_sectionLabels == null)
      jcasType.jcas.throwFeatMissing("sectionLabels", "edu.cmu.lti.oaqa.type.retrieval.Document");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sectionLabels), i);
    return jcasType.ll_cas.ll_getStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sectionLabels), i);}

  /** indexed setter for sectionLabels - sets an indexed value - Section labels in the document, e.g. sections.0, sections1, etc.
   * @generated
   * @param i index in the array to set
   * @param v value to set into the array
   */
  public void setSectionLabels(int i, String v) {
    if (Document_Type.featOkTst && ((Document_Type)jcasType).casFeat_sectionLabels == null)
      jcasType.jcas.throwFeatMissing("sectionLabels", "edu.cmu.lti.oaqa.type.retrieval.Document");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sectionLabels), i);
    jcasType.ll_cas.ll_setStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Document_Type)jcasType).casFeatCode_sectionLabels), i, v);}
  }


/* First created by JCasGen Sat Apr 11 19:49:33 EDT 2015 */
package edu.cmu.lti.oaqa.type.kb;

import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.TOP_Type;

import org.apache.uima.jcas.cas.FSList;
import org.apache.uima.jcas.cas.TOP;
import org.apache.uima.jcas.cas.StringList;

/** A superclass for EntityConcept and RelationConcept.
 * Updated by JCasGen Sun Apr 19 19:46:50 EDT 2015
 * XML source: /home/yangzi/QA/baseqa/src/main/resources/baseqa/type/OAQATypes.xml
 * @generated */
public class Concept extends TOP {
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int typeIndexID = JCasRegistry.register(Concept.class);
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int type = typeIndexID;
  /** @generated
   * @return index of the type
   */
  @Override
  public              int getTypeIndexID() {return typeIndexID;}

  /** Never called.  Disable default constructor
   * @generated */
  protected Concept() {/* intentionally empty block */}

  /** Internal - constructor used by generator
   * @generated
   * @param addr low level Feature Structure reference
   * @param type the type of this Feature Structure
   */
  public Concept(int addr, TOP_Type type) {
    super(addr, type);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   */
  public Concept(JCas jcas) {
    super(jcas);
    readObject();
  }

  /**
   * <!-- begin-user-doc -->
   * Write your own initialization here
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  private void readObject() {/*default - does nothing empty block */}

  //*--------------*
  //* Feature: names

  /** getter for names - gets All name variants (preferred/default name, synonyms, lexicial variants, etc) of the concept.
   * @generated
   * @return value of the feature
   */
  public StringList getNames() {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_names == null)
      jcasType.jcas.throwFeatMissing("names", "edu.cmu.lti.oaqa.type.kb.Concept");
    return (StringList)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Concept_Type)jcasType).casFeatCode_names)));}

  /** setter for names - sets All name variants (preferred/default name, synonyms, lexicial variants, etc) of the concept.
   * @generated
   * @param v value to set into the feature
   */
  public void setNames(StringList v) {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_names == null)
      jcasType.jcas.throwFeatMissing("names", "edu.cmu.lti.oaqa.type.kb.Concept");
    jcasType.ll_cas.ll_setRefValue(addr, ((Concept_Type)jcasType).casFeatCode_names, jcasType.ll_cas.ll_getFSRef(v));}

  //*--------------*
  //* Feature: uris

  /** getter for uris - gets Array of uris that identify this named entity. There may be more than one uri if this named entity is ambiguous.
   * @generated
   * @return value of the feature
   */
  public StringList getUris() {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_uris == null)
      jcasType.jcas.throwFeatMissing("uris", "edu.cmu.lti.oaqa.type.kb.Concept");
    return (StringList)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Concept_Type)jcasType).casFeatCode_uris)));}

  /** setter for uris - sets Array of uris that identify this named entity. There may be more than one uri if this named entity is ambiguous.
   * @generated
   * @param v value to set into the feature
   */
  public void setUris(StringList v) {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_uris == null)
      jcasType.jcas.throwFeatMissing("uris", "edu.cmu.lti.oaqa.type.kb.Concept");
    jcasType.ll_cas.ll_setRefValue(addr, ((Concept_Type)jcasType).casFeatCode_uris, jcasType.ll_cas.ll_getFSRef(v));}

  //*--------------*
  //* Feature: ids

  /** getter for ids - gets A list of IDs (e.g. UI in UMLS) associated with this concept.
   * @generated
   * @return value of the feature
   */
  public StringList getIds() {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_ids == null)
      jcasType.jcas.throwFeatMissing("ids", "edu.cmu.lti.oaqa.type.kb.Concept");
    return (StringList)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Concept_Type)jcasType).casFeatCode_ids)));}

  /** setter for ids - sets A list of IDs (e.g. UI in UMLS) associated with this concept.
   * @generated
   * @param v value to set into the feature
   */
  public void setIds(StringList v) {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_ids == null)
      jcasType.jcas.throwFeatMissing("ids", "edu.cmu.lti.oaqa.type.kb.Concept");
    jcasType.ll_cas.ll_setRefValue(addr, ((Concept_Type)jcasType).casFeatCode_ids, jcasType.ll_cas.ll_getFSRef(v));}

  //*--------------*
  //* Feature: mentions

  /** getter for mentions - gets A list of ConceptMentions (text spans) that might be surface forms to this concept.
   * @generated
   * @return value of the feature
   */
  public FSList getMentions() {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_mentions == null)
      jcasType.jcas.throwFeatMissing("mentions", "edu.cmu.lti.oaqa.type.kb.Concept");
    return (FSList)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Concept_Type)jcasType).casFeatCode_mentions)));}

  /** setter for mentions - sets A list of ConceptMentions (text spans) that might be surface forms to this concept.
   * @generated
   * @param v value to set into the feature
   */
  public void setMentions(FSList v) {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_mentions == null)
      jcasType.jcas.throwFeatMissing("mentions", "edu.cmu.lti.oaqa.type.kb.Concept");
    jcasType.ll_cas.ll_setRefValue(addr, ((Concept_Type)jcasType).casFeatCode_mentions, jcasType.ll_cas.ll_getFSRef(v));}

  //*--------------*
  //* Feature: types

  /** getter for types - gets A list of concept types that the concept belongs to.
   * @generated
   * @return value of the feature
   */
  public FSList getTypes() {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_types == null)
      jcasType.jcas.throwFeatMissing("types", "edu.cmu.lti.oaqa.type.kb.Concept");
    return (FSList)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Concept_Type)jcasType).casFeatCode_types)));}

  /** setter for types - sets A list of concept types that the concept belongs to.
   * @generated
   * @param v value to set into the feature
   */
  public void setTypes(FSList v) {
    if (Concept_Type.featOkTst && ((Concept_Type)jcasType).casFeat_types == null)
      jcasType.jcas.throwFeatMissing("types", "edu.cmu.lti.oaqa.type.kb.Concept");
    jcasType.ll_cas.ll_setRefValue(addr, ((Concept_Type)jcasType).casFeatCode_types, jcasType.ll_cas.ll_getFSRef(v));}
  }


/* First created by JCasGen Sat Apr 11 19:49:33 EDT 2015 */
package edu.cmu.lti.oaqa.type.answer;

import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.TOP_Type;

import org.apache.uima.jcas.tcas.Annotation;

/** A Named Entity type that represents the type of the answer being sought.
 * Updated by JCasGen Sun Apr 19 19:46:49 EDT 2015
 * XML source: /home/yangzi/QA/baseqa/src/main/resources/baseqa/type/OAQATypes.xml
 * @generated */
public class AnswerType extends Annotation {
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int typeIndexID = JCasRegistry.register(AnswerType.class);
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int type = typeIndexID;
  /** @generated
   * @return index of the type
   */
  @Override
  public              int getTypeIndexID() {return typeIndexID;}

  /** Never called.  Disable default constructor
   * @generated */
  protected AnswerType() {/* intentionally empty block */}

  /** Internal - constructor used by generator
   * @generated
   * @param addr low level Feature Structure reference
   * @param type the type of this Feature Structure
   */
  public AnswerType(int addr, TOP_Type type) {
    super(addr, type);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   */
  public AnswerType(JCas jcas) {
    super(jcas);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   * @param begin offset to the begin spot in the SofA
   * @param end offset to the end spot in the SofA
  */
  public AnswerType(JCas jcas, int begin, int end) {
    super(jcas);
    setBegin(begin);
    setEnd(end);
    readObject();
  }

  /**
   * <!-- begin-user-doc -->
   * Write your own initialization here
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  private void readObject() {/*default - does nothing empty block */}

  //*--------------*
  //* Feature: label

  /** getter for label - gets An answer type identified for the question.
   * @generated
   * @return value of the feature
   */
  public String getLabel() {
    if (AnswerType_Type.featOkTst && ((AnswerType_Type)jcasType).casFeat_label == null)
      jcasType.jcas.throwFeatMissing("label", "edu.cmu.lti.oaqa.type.answer.AnswerType");
    return jcasType.ll_cas.ll_getStringValue(addr, ((AnswerType_Type)jcasType).casFeatCode_label);}

  /** setter for label - sets An answer type identified for the question.
   * @generated
   * @param v value to set into the feature
   */
  public void setLabel(String v) {
    if (AnswerType_Type.featOkTst && ((AnswerType_Type)jcasType).casFeat_label == null)
      jcasType.jcas.throwFeatMissing("label", "edu.cmu.lti.oaqa.type.answer.AnswerType");
    jcasType.ll_cas.ll_setStringValue(addr, ((AnswerType_Type)jcasType).casFeatCode_label, v);}

  //*--------------*
  //* Feature: targetType

  /** getter for targetType - gets The actual target type annotation.
   * @generated
   * @return value of the feature
   */
  public Annotation getTargetType() {
    if (AnswerType_Type.featOkTst && ((AnswerType_Type)jcasType).casFeat_targetType == null)
      jcasType.jcas.throwFeatMissing("targetType", "edu.cmu.lti.oaqa.type.answer.AnswerType");
    return (Annotation)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((AnswerType_Type)jcasType).casFeatCode_targetType)));}

  /** setter for targetType - sets The actual target type annotation.
   * @generated
   * @param v value to set into the feature
   */
  public void setTargetType(Annotation v) {
    if (AnswerType_Type.featOkTst && ((AnswerType_Type)jcasType).casFeat_targetType == null)
      jcasType.jcas.throwFeatMissing("targetType", "edu.cmu.lti.oaqa.type.answer.AnswerType");
    jcasType.ll_cas.ll_setRefValue(addr, ((AnswerType_Type)jcasType).casFeatCode_targetType, jcasType.ll_cas.ll_getFSRef(v));}
  }


/* First created by JCasGen Sat Apr 11 19:49:33 EDT 2015 */
package edu.cmu.lti.oaqa.type.retrieval;

import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.TOP_Type;

import edu.cmu.lti.oaqa.type.answer.CandidateAnswerVariant;
import org.apache.uima.jcas.cas.FSArray;
import org.apache.uima.jcas.cas.TOP;

/** A search result.
 * Updated by JCasGen Sun Apr 19 19:46:50 EDT 2015
 * XML source: /home/yangzi/QA/baseqa/src/main/resources/baseqa/type/OAQATypes.xml
 * @generated */
public class SearchResult extends TOP {
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int typeIndexID = JCasRegistry.register(SearchResult.class);
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int type = typeIndexID;
  /** @generated
   * @return index of the type
   */
  @Override
  public              int getTypeIndexID() {return typeIndexID;}

  /** Never called.  Disable default constructor
   * @generated */
  protected SearchResult() {/* intentionally empty block */}

  /** Internal - constructor used by generator
   * @generated
   * @param addr low level Feature Structure reference
   * @param type the type of this Feature Structure
   */
  public SearchResult(int addr, TOP_Type type) {
    super(addr, type);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   */
  public SearchResult(JCas jcas) {
    super(jcas);
    readObject();
  }

  /**
   * <!-- begin-user-doc -->
   * Write your own initialization here
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  private void readObject() {/*default - does nothing empty block */}

  //*--------------*
  //* Feature: uri

  /** getter for uri - gets An identifier for the source of this search result, e.g., the name of the file that this result is drawn from, which, when combined with offset and length, uniquely identifies the span of text for this result.
   * @generated
   * @return value of the feature
   */
  public String getUri() {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_uri == null)
      jcasType.jcas.throwFeatMissing("uri", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    return jcasType.ll_cas.ll_getStringValue(addr, ((SearchResult_Type)jcasType).casFeatCode_uri);}

  /** setter for uri - sets An identifier for the source of this search result, e.g., the name of the file that this result is drawn from, which, when combined with offset and length, uniquely identifies the span of text for this result.
   * @generated
   * @param v value to set into the feature
   */
  public void setUri(String v) {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_uri == null)
      jcasType.jcas.throwFeatMissing("uri", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    jcasType.ll_cas.ll_setStringValue(addr, ((SearchResult_Type)jcasType).casFeatCode_uri, v);}

  //*--------------*
  //* Feature: score

  /** getter for score - gets Relevance score associated with the search result.
   * @generated
   * @return value of the feature
   */
  public double getScore() {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_score == null)
      jcasType.jcas.throwFeatMissing("score", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    return jcasType.ll_cas.ll_getDoubleValue(addr, ((SearchResult_Type)jcasType).casFeatCode_score);}

  /** setter for score - sets Relevance score associated with the search result.
   * @generated
   * @param v value to set into the feature
   */
  public void setScore(double v) {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_score == null)
      jcasType.jcas.throwFeatMissing("score", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    jcasType.ll_cas.ll_setDoubleValue(addr, ((SearchResult_Type)jcasType).casFeatCode_score, v);}

  //*--------------*
  //* Feature: text

  /** getter for text - gets The text associated with the hit.
   * @generated
   * @return value of the feature
   */
  public String getText() {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_text == null)
      jcasType.jcas.throwFeatMissing("text", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    return jcasType.ll_cas.ll_getStringValue(addr, ((SearchResult_Type)jcasType).casFeatCode_text);}

  /** setter for text - sets The text associated with the hit.
   * @generated
   * @param v value to set into the feature
   */
  public void setText(String v) {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_text == null)
      jcasType.jcas.throwFeatMissing("text", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    jcasType.ll_cas.ll_setStringValue(addr, ((SearchResult_Type)jcasType).casFeatCode_text, v);}

  //*--------------*
  //* Feature: rank

  /** getter for rank - gets Rank of this result in the original hit-list.
   * @generated
   * @return value of the feature
   */
  public int getRank() {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_rank == null)
      jcasType.jcas.throwFeatMissing("rank", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    return jcasType.ll_cas.ll_getIntValue(addr, ((SearchResult_Type)jcasType).casFeatCode_rank);}

  /** setter for rank - sets Rank of this result in the original hit-list.
   * @generated
   * @param v value to set into the feature
   */
  public void setRank(int v) {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_rank == null)
      jcasType.jcas.throwFeatMissing("rank", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    jcasType.ll_cas.ll_setIntValue(addr, ((SearchResult_Type)jcasType).casFeatCode_rank, v);}

  //*--------------*
  //* Feature: queryString

  /** getter for queryString - gets The query string associated with the hit.
   * @generated
   * @return value of the feature
   */
  public String getQueryString() {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_queryString == null)
      jcasType.jcas.throwFeatMissing("queryString", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    return jcasType.ll_cas.ll_getStringValue(addr, ((SearchResult_Type)jcasType).casFeatCode_queryString);}

  /** setter for queryString - sets The query string associated with the hit.
   * @generated
   * @param v value to set into the feature
   */
  public void setQueryString(String v) {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_queryString == null)
      jcasType.jcas.throwFeatMissing("queryString", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    jcasType.ll_cas.ll_setStringValue(addr, ((SearchResult_Type)jcasType).casFeatCode_queryString, v);}

  //*--------------*
  //* Feature: searchId

  /** getter for searchId - gets ID of the search object to which this search result belongs (matches the searchId field in the Search object).
   * @generated
   * @return value of the feature
   */
  public String getSearchId() {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_searchId == null)
      jcasType.jcas.throwFeatMissing("searchId", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    return jcasType.ll_cas.ll_getStringValue(addr, ((SearchResult_Type)jcasType).casFeatCode_searchId);}

  /** setter for searchId - sets ID of the search object to which this search result belongs (matches the searchId field in the Search object).
   * @generated
   * @param v value to set into the feature
   */
  public void setSearchId(String v) {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_searchId == null)
      jcasType.jcas.throwFeatMissing("searchId", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    jcasType.ll_cas.ll_setStringValue(addr, ((SearchResult_Type)jcasType).casFeatCode_searchId, v);}

  //*--------------*
  //* Feature: candidateAnswers

  /** getter for candidateAnswers - gets CandidateAnswerVariants generated from this SearchResult.
   * @generated
   * @return value of the feature
   */
  public FSArray getCandidateAnswers() {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_candidateAnswers == null)
      jcasType.jcas.throwFeatMissing("candidateAnswers", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    return (FSArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((SearchResult_Type)jcasType).casFeatCode_candidateAnswers)));}

  /** setter for candidateAnswers - sets CandidateAnswerVariants generated from this SearchResult.
   * @generated
   * @param v value to set into the feature
   */
  public void setCandidateAnswers(FSArray v) {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_candidateAnswers == null)
      jcasType.jcas.throwFeatMissing("candidateAnswers", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    jcasType.ll_cas.ll_setRefValue(addr, ((SearchResult_Type)jcasType).casFeatCode_candidateAnswers, jcasType.ll_cas.ll_getFSRef(v));}

  /** indexed getter for candidateAnswers - gets an indexed value - CandidateAnswerVariants generated from this SearchResult.
   * @generated
   * @param i index in the array to get
   * @return value of the element at index i
   */
  public CandidateAnswerVariant getCandidateAnswers(int i) {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_candidateAnswers == null)
      jcasType.jcas.throwFeatMissing("candidateAnswers", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((SearchResult_Type)jcasType).casFeatCode_candidateAnswers), i);
    return (CandidateAnswerVariant)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((SearchResult_Type)jcasType).casFeatCode_candidateAnswers), i)));}

  /** indexed setter for candidateAnswers - sets an indexed value - CandidateAnswerVariants generated from this SearchResult.
   * @generated
   * @param i index in the array to set
   * @param v value to set into the array
   */
  public void setCandidateAnswers(int i, CandidateAnswerVariant v) {
    if (SearchResult_Type.featOkTst && ((SearchResult_Type)jcasType).casFeat_candidateAnswers == null)
      jcasType.jcas.throwFeatMissing("candidateAnswers", "edu.cmu.lti.oaqa.type.retrieval.SearchResult");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((SearchResult_Type)jcasType).casFeatCode_candidateAnswers), i);
    jcasType.ll_cas.ll_setRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((SearchResult_Type)jcasType).casFeatCode_candidateAnswers), i, jcasType.ll_cas.ll_getFSRef(v));}
  }


/* First created by JCasGen Sat Apr 11 19:49:33 EDT 2015 */
package edu.cmu.lti.oaqa.type.retrieval;

import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.TOP_Type;

import org.apache.uima.jcas.cas.FSArray;
import org.apache.uima.jcas.cas.TOP;

/** An object that holds a query and results for a search (text search, fact search, KB search, etc.)
 * Updated by JCasGen Sun Apr 19 19:46:50 EDT 2015
 * XML source: /home/yangzi/QA/baseqa/src/main/resources/baseqa/type/OAQATypes.xml
 * @generated */
public class Search extends TOP {
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int typeIndexID = JCasRegistry.register(Search.class);
  /** @generated
   * @ordered
   */
  @SuppressWarnings ("hiding")
  public final static int type = typeIndexID;
  /** @generated
   * @return index of the type
   */
  @Override
  public              int getTypeIndexID() {return typeIndexID;}

  /** Never called.  Disable default constructor
   * @generated */
  protected Search() {/* intentionally empty block */}

  /** Internal - constructor used by generator
   * @generated
   * @param addr low level Feature Structure reference
   * @param type the type of this Feature Structure
   */
  public Search(int addr, TOP_Type type) {
    super(addr, type);
    readObject();
  }

  /** @generated
   * @param jcas JCas to which this Feature Structure belongs
   */
  public Search(JCas jcas) {
    super(jcas);
    readObject();
  }

  /**
   * <!-- begin-user-doc -->
   * Write your own initialization here
   * <!-- end-user-doc -->
   *
   * @generated modifiable
   */
  private void readObject() {/*default - does nothing empty block */}

  //*--------------*
  //* Feature: query

  /** getter for query - gets The query in the native syntax of the corresponding search engine.
   * @generated
   * @return value of the feature
   */
  public String getQuery() {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_query == null)
      jcasType.jcas.throwFeatMissing("query", "edu.cmu.lti.oaqa.type.retrieval.Search");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Search_Type)jcasType).casFeatCode_query);}

  /** setter for query - sets The query in the native syntax of the corresponding search engine.
   * @generated
   * @param v value to set into the feature
   */
  public void setQuery(String v) {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_query == null)
      jcasType.jcas.throwFeatMissing("query", "edu.cmu.lti.oaqa.type.retrieval.Search");
    jcasType.ll_cas.ll_setStringValue(addr, ((Search_Type)jcasType).casFeatCode_query, v);}

  //*--------------*
  //* Feature: hitList

  /** getter for hitList - gets Hit list of search results, sorted in descreasing order of relevance score.
   * @generated
   * @return value of the feature
   */
  public FSArray getHitList() {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_hitList == null)
      jcasType.jcas.throwFeatMissing("hitList", "edu.cmu.lti.oaqa.type.retrieval.Search");
    return (FSArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Search_Type)jcasType).casFeatCode_hitList)));}

  /** setter for hitList - sets Hit list of search results, sorted in descreasing order of relevance score.
   * @generated
   * @param v value to set into the feature
   */
  public void setHitList(FSArray v) {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_hitList == null)
      jcasType.jcas.throwFeatMissing("hitList", "edu.cmu.lti.oaqa.type.retrieval.Search");
    jcasType.ll_cas.ll_setRefValue(addr, ((Search_Type)jcasType).casFeatCode_hitList, jcasType.ll_cas.ll_getFSRef(v));}

  /** indexed getter for hitList - gets an indexed value - Hit list of search results, sorted in descreasing order of relevance score.
   * @generated
   * @param i index in the array to get
   * @return value of the element at index i
   */
  public SearchResult getHitList(int i) {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_hitList == null)
      jcasType.jcas.throwFeatMissing("hitList", "edu.cmu.lti.oaqa.type.retrieval.Search");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Search_Type)jcasType).casFeatCode_hitList), i);
    return (SearchResult)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Search_Type)jcasType).casFeatCode_hitList), i)));}

  /** indexed setter for hitList - sets an indexed value - Hit list of search results, sorted in descreasing order of relevance score.
   * @generated
   * @param i index in the array to set
   * @param v value to set into the array
   */
  public void setHitList(int i, SearchResult v) {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_hitList == null)
      jcasType.jcas.throwFeatMissing("hitList", "edu.cmu.lti.oaqa.type.retrieval.Search");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Search_Type)jcasType).casFeatCode_hitList), i);
    jcasType.ll_cas.ll_setRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Search_Type)jcasType).casFeatCode_hitList), i, jcasType.ll_cas.ll_getFSRef(v));}

  //*--------------*
  //* Feature: abstractQuery

  /** getter for abstractQuery - gets The abstract query from which this actual query was generated.
   * @generated
   * @return value of the feature
   */
  public AbstractQuery getAbstractQuery() {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_abstractQuery == null)
      jcasType.jcas.throwFeatMissing("abstractQuery", "edu.cmu.lti.oaqa.type.retrieval.Search");
    return (AbstractQuery)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Search_Type)jcasType).casFeatCode_abstractQuery)));}

  /** setter for abstractQuery - sets The abstract query from which this actual query was generated.
   * @generated
   * @param v value to set into the feature
   */
  public void setAbstractQuery(AbstractQuery v) {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_abstractQuery == null)
      jcasType.jcas.throwFeatMissing("abstractQuery", "edu.cmu.lti.oaqa.type.retrieval.Search");
    jcasType.ll_cas.ll_setRefValue(addr, ((Search_Type)jcasType).casFeatCode_abstractQuery, jcasType.ll_cas.ll_getFSRef(v));}

  //*--------------*
  //* Feature: searchId

  /** getter for searchId - gets An identifier for this search result. Used to collect hit-list objects that belong to this search result after they've been split out for parallel processing then gathered up again.
   * @generated
   * @return value of the feature
   */
  public String getSearchId() {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_searchId == null)
      jcasType.jcas.throwFeatMissing("searchId", "edu.cmu.lti.oaqa.type.retrieval.Search");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Search_Type)jcasType).casFeatCode_searchId);}

  /** setter for searchId - sets An identifier for this search result. Used to collect hit-list objects that belong to this search result after they've been split out for parallel processing then gathered up again.
   * @generated
   * @param v value to set into the feature
   */
  public void setSearchId(String v) {
    if (Search_Type.featOkTst && ((Search_Type)jcasType).casFeat_searchId == null)
      jcasType.jcas.throwFeatMissing("searchId", "edu.cmu.lti.oaqa.type.retrieval.Search");
    jcasType.ll_cas.ll_setStringValue(addr, ((Search_Type)jcasType).casFeatCode_searchId, v);}
  }