001/* 002 $Id: InstrumentConfiguration.java 3207 2009-04-09 06:48:11Z gregory $ 003 004 Copyright (C) 2006 Gregory Vincic, Olle Mansson 005 Copyright (C) 2007 Gregory Vincic 006 007 This file is part of Proteios. 008 Available at http://www.proteios.org/ 009 010 Proteios is free software; you can redistribute it and/or modify it 011 under the terms of the GNU General Public License as published by 012 the Free Software Foundation; either version 2 of the License, or 013 (at your option) any later version. 014 015 Proteios is distributed in the hope that it will be useful, but 016 WITHOUT ANY WARRANTY; without even the implied warranty of 017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 018 General Public License for more details. 019 020 You should have received a copy of the GNU General Public License 021 along with this program; if not, write to the Free Software 022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 023 02111-1307, USA. 024*/ 025 026package org.proteios.core; 027 028import org.proteios.core.data.InstrumentConfigurationData; 029 030/** 031 This is the base class for for the two types of 032 instrumentconfigurations: 033 {@link HardwareConfiguration} and {@link SoftwareConfiguration}. 034 035 @author Olle 036 @version 2.0 037 @see AnnotatedItem 038 @proteios.modified $Date: 2006-05-31 12:33:12Z $ 039*/ 040public abstract class InstrumentConfiguration<D extends InstrumentConfigurationData> 041 extends AnnotatedItem<D> 042 implements FileAttachable 043{ 044 InstrumentConfiguration(D instrumentConfigurationData) 045 { 046 super(instrumentConfigurationData); 047 } 048 049 /** 050 The maximum length of the dateTime string that can be stored 051 in the database. 052 @see #setDateTime(String) 053 */ 054 public static final int MAX_DATETIME_LENGTH = InstrumentConfigurationData.MAX_DATETIME_LENGTH; 055 056 /** 057 Get the dateTime string of the instrumentconfiguration. 058 @return The dateTime string for the instrumentconfiguration 059 */ 060 public String getDateTime() 061 { 062 return getData().getDateTime(); 063 } 064 065 /** 066 Set the dateTime string of the instrumentconfiguration. 067 The value may be null but must not be longer than 068 the value specified by the {@link #MAX_DATETIME_LENGTH} 069 constant. 070 @param dateTime The new value for the date and time 071 @throws InvalidDataException If the string is too long 072 */ 073 public void setDateTime(String dateTime) 074 throws InvalidDataException 075 { 076 getData().setDateTime(StringUtil.setNullableString(dateTime, "dateTime", MAX_DATETIME_LENGTH)); 077 } 078 079 /* 080 The AnnotatedItem class already supports a 'name' attribute. 081 @see getName() 082 @see setName(String) 083 */ 084 085 // ------------------------------------------- 086 /* 087 From the FileAttachable interface 088 ------------------------------------------- 089 */ 090 091 /** 092 Get the protocol {@link File} for the configuration. 093 @return A <code>File</code> object 094 @throws BaseException If there is another error 095 */ 096 public File getFile() 097 throws BaseException 098 { 099 return getDbControl().getItem(File.class, getData().getFile()); 100 } 101 102 /** 103 Set the protocol {@link File} for the configuration. 104 @param file The new <code>File</code> item 105 @throws InvalidDataException If the file is null 106 @throws BaseException If there is another error 107 */ 108 public void setFile(File file) 109 throws InvalidDataException 110 { 111 if (file == null) throw new InvalidUseOfNullException("file"); 112 getData().setFile(file.getData()); 113 } 114 // ------------------------------------------- 115}