/*
This file is part of the software framework JStatCom,
a library for building applications for data based analysis.
Copyright (C) 2000-2005 Markus Kraetzig
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
package com.jstatcom.ts;
import javolution37.javolution.xml.XmlElement;
import javolution37.javolution.xml.XmlFormat;
import com.jstatcom.model.JSCDRange;
import com.jstatcom.model.JSCNArray;
/**
* Represents a selection of the the TSSel component that is XML
* serializable.
*
* @author Markus Kraetzig
*/
public final class Selection {
private JSCNArray selectedIndices = new JSCNArray("indices");
private JSCDRange selectedRange = new JSCDRange("range");
private JSCDRange enclosingRange = new JSCDRange("enclosing");
/**
* XML format field for (de)serialization.
*/
public static final XmlFormat Selection_XML = new XmlFormat(
Selection.class) {
public void format(Selection data, XmlElement xml) {
xml.add(data.selectedIndices);
xml.add(data.enclosingRange);
xml.add(data.selectedRange);
}
public Selection parse(XmlElement xml) {
Selection selection = new Selection();
if (!xml.hasNext())
return selection;
JSCNArray indices = (JSCNArray) xml.getNext();
JSCDRange enrange = (JSCDRange) xml.getNext();
JSCDRange range = (JSCDRange) xml.getNext();
selection.setSelectedIndices(indices);
selection.setEnclosingRange(enrange);
selection.setSelectedRange(range);
return selection;
}
};
/**
* Gets the array with the selected indices in the correct order.
*
* @return array with selected indices
*/
public JSCNArray getSelectedIndices() {
return selectedIndices;
}
/**
* Sets the array with the selected indices.
*
* @param selectedIndices
* array with selected indices
* @throws IllegalArgumentException
* if (selectedIndices == null)
*/
public void setSelectedIndices(JSCNArray selectedIndices) {
if (selectedIndices == null)
throw new IllegalArgumentException("Argument was null.");
this.selectedIndices = selectedIndices;
}
/**
* Gets the selected date range object.
*
* @return the selected range
*/
public JSCDRange getSelectedRange() {
return selectedRange;
}
/**
* Sets the selected date range.
*
* @param selectedRange
* date range
* @throws IllegalArgumentException
* if (selectedRange == null)
*/
public void setSelectedRange(JSCDRange selectedRange) {
if (selectedRange == null)
throw new IllegalArgumentException("Argument was null.");
this.selectedRange = selectedRange;
}
/**
* Gets the enclosing date range object.
*
* @return the enclosing range
*/
public JSCDRange getEnclosingRange() {
return enclosingRange;
}
/**
* Sets the enclosing date range.
*
* @param enclosingRange
* date range
* @throws IllegalArgumentException
* if (enclosingRange == null)
*/
public void setEnclosingRange(JSCDRange enclosingRange) {
if (enclosingRange == null)
throw new IllegalArgumentException("Argument was null.");
this.enclosingRange = enclosingRange;
}
}
Ads help maintain this website.