X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.history%2Fsrc%2Forg%2Fsimantics%2Fhistory%2FHistory.java;h=96b9368947ac307876232c84d10f44804acc3eb3;hb=d9d830062a16b727c65d9bbd04f519235c5ece01;hp=cfcaf6609a59bb019114955eee899dd09a12ddb7;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.history/src/org/simantics/history/History.java b/bundles/org.simantics.history/src/org/simantics/history/History.java index cfcaf6609..96b936894 100644 --- a/bundles/org.simantics.history/src/org/simantics/history/History.java +++ b/bundles/org.simantics.history/src/org/simantics/history/History.java @@ -1,117 +1,117 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.history; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.simantics.databoard.binding.Binding; -import org.simantics.history.impl.CollectorImpl; -import org.simantics.history.impl.FileHistory; -import org.simantics.history.impl.FlushPolicy; -import org.simantics.history.impl.MemoryHistory; -import org.simantics.history.util.HistoryExportUtil; - -/** - * Facade-class for History Services. - * - * There are two main services HistoryManager and Collector. - * There are two main implementations file and memory. - * - * @author toni.kalajainen - */ -public class History { - - /** - * Open a file based history manager. - * (Note, Trend does not need flush policy) - * - * @param workarea - * @return history manager - */ - public static HistoryManager openFileHistory(File workarea) - { - return new FileHistory(workarea); - } - - /** - * Create a transient memory history - * - * @return no history - */ - public static HistoryManager createMemoryHistory() - { - return new MemoryHistory(); - } - - /** - * Create collector - * - * @param historyManager - * @return collector - */ - public static Collector createCollector(HistoryManager historyManager) - { - CollectorImpl result = new CollectorImpl(historyManager); - return result; - } - - /** - * Create collector - * - * @param historyManager - * @param flushPolicy - * @return collector - */ - public static Collector createCollector(HistoryManager historyManager, FlushPolicy flushPolicy) - { - CollectorImpl result = new CollectorImpl(historyManager); - result.setFlushPolicy(flushPolicy); - return result; - } - - /** - * Export whole history manager to an output stream. - * - * @param history - * @param timeBinding - * @param from - * @param end - * @param os - * @throws IOException - * @throws HistoryException - */ - public static void exportHistory( HistoryManager history, Binding timeBinding, Double from, Double end, OutputStream os ) - throws IOException, HistoryException - { - HistoryExportUtil eu = new HistoryExportUtil(); - eu.exportHistory(history, timeBinding, from, end, os); - } - - /** - * Import a history manager from an input stream - * - * @param history - * @param is - * @throws IOException - * @throws HistoryException - */ - public static void importHistory( HistoryManager history, InputStream is ) - throws IOException, HistoryException - { - HistoryExportUtil eu = new HistoryExportUtil(); - eu.importHistory(history, is); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.history; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.simantics.databoard.binding.Binding; +import org.simantics.history.impl.CollectorImpl; +import org.simantics.history.impl.FileHistory; +import org.simantics.history.impl.FlushPolicy; +import org.simantics.history.impl.MemoryHistory; +import org.simantics.history.util.HistoryExportUtil; + +/** + * Facade-class for History Services. + * + * There are two main services HistoryManager and Collector. + * There are two main implementations file and memory. + * + * @author toni.kalajainen + */ +public class History { + + /** + * Open a file based history manager. + * (Note, Trend does not need flush policy) + * + * @param workarea + * @return history manager + */ + public static HistoryManager openFileHistory(File workarea) + { + return new FileHistory(workarea); + } + + /** + * Create a transient memory history + * + * @return no history + */ + public static HistoryManager createMemoryHistory() + { + return new MemoryHistory(); + } + + /** + * Create collector + * + * @param historyManager + * @return collector + */ + public static Collector createCollector(HistoryManager historyManager) + { + CollectorImpl result = new CollectorImpl(historyManager); + return result; + } + + /** + * Create collector + * + * @param historyManager + * @param flushPolicy + * @return collector + */ + public static Collector createCollector(HistoryManager historyManager, FlushPolicy flushPolicy) + { + CollectorImpl result = new CollectorImpl(historyManager); + result.setFlushPolicy(flushPolicy); + return result; + } + + /** + * Export whole history manager to an output stream. + * + * @param history + * @param timeBinding + * @param from + * @param end + * @param os + * @throws IOException + * @throws HistoryException + */ + public static void exportHistory( HistoryManager history, Binding timeBinding, Double from, Double end, OutputStream os ) + throws IOException, HistoryException + { + HistoryExportUtil eu = new HistoryExportUtil(); + eu.exportHistory(history, timeBinding, from, end, os); + } + + /** + * Import a history manager from an input stream + * + * @param history + * @param is + * @throws IOException + * @throws HistoryException + */ + public static void importHistory( HistoryManager history, InputStream is ) + throws IOException, HistoryException + { + HistoryExportUtil eu = new HistoryExportUtil(); + eu.importHistory(history, is); + } + +}