001/*
002 $Id: DigestParameter.java 3207 2009-04-09 06:48:11Z gregory $
003
004 Copyright (C) 2006 Fredrik Levander
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 */
025package org.proteios.core;
026
027import org.proteios.core.data.DigestParameterData;
028import java.util.Set;
029
030/**
031 * This class represent spectrumsearch.
032 * 
033 * @author Fredrik
034 * @version 2.0
035 * @proteios.modified $Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $
036 */
037public class DigestParameter
038                extends CommonItem<DigestParameterData>
039{
040        DigestParameter(DigestParameterData digestParameterData)
041        {
042                super(digestParameterData);
043        }
044
045        /**
046         * The type of item represented by this class.
047         * 
048         * @see Item#PROTEIOS_SPECTRUMSEARCH
049         * @see #getType()
050         */
051        public static final Item TYPE = Item.PROTEIOS_DIGESTPARAMETER;
052
053
054        /**
055         * Get a query that returns spectrumsearchset items.
056         * 
057         * @return An {@link ItemQuery} object.
058         */
059        public static ItemQuery<DigestParameter> getQuery()
060        {
061                return new ItemQuery<DigestParameter>(DigestParameter.class);
062        }
063
064
065        // -------------------------------------------
066        /*
067         * From the Identifiable interface
068         * -------------------------------------------
069         */
070        public Item getType()
071        {
072                return TYPE;
073        }
074
075
076        /**
077         * Always null.
078         */
079        public Set<Annotatable> getAnnotatableParents()
080                        throws BaseException
081        {
082                return null;
083        }
084
085
086        /*
087         * From the BasicItem class
088         */
089        /**
090         * Check that:
091         * <ul>
092         * <li>no item has been created from this peaklistset
093         * </ul>
094         */
095        @Override
096        public boolean isUsed()
097                        throws BaseException
098        {
099                return false;
100        }
101
102
103        /**
104         * Get the {@link SpectrumSearch} this digestParameter is associated with.
105         * 
106         * @return The <code>SpectrumSearch</code> item or null if not known
107         * @throws BaseException If there is another error
108         */
109        public SpectrumSearch getSpectrumSearch()
110                        throws BaseException
111        {
112                return getDbControl().getItem(SpectrumSearch.class,
113                        getData().getSpectrumSearch());
114        }
115
116        /**
117         * Set the {@link SpectrumSearch} this DigestParameter is associated with.
118         * 
119         * @param spectrumSearch The new <code>SpectrumSearch</code> item
120         * @throws BaseException If there is another error
121         */
122        public void setSpectrumSearch(SpectrumSearch spectrumSearch)
123                        throws BaseException
124        {
125                getData().setSpectrumSearch(
126                        spectrumSearch.getData());
127        }
128
129        
130        /**
131         * @return Returns the maxNumMissedCleavages.
132         */
133        public int getMaxNumMissedCleavages()
134        {
135                return getData().getMaxNumMissedCleavages();
136        }
137
138
139        /**
140         * @param maxNumMissedCleavages The maxNumMissedCleavages to set.
141         */
142        public void setMaxNumMissedCleavages(int maxNumMissedCleavages)
143        {
144                getData().setMaxNumMissedCleavages(maxNumMissedCleavages);
145        }
146
147        /**
148         * The maximum length of the name string that can be stored in the database.
149         * 
150         * @see #setName(String)
151         */
152        public static final int MAX_NAME_LENGTH = DigestParameterData.MAX_NAME_LENGTH;
153
154
155        /**
156         * Get the Name of this <code>DigestParameter</code>.
157         * 
158         * @return the name of this digest parameter
159         */
160        @Override
161        public String getName()
162        {
163                return getData().getName();
164        }
165
166
167        /**
168         * Set the name for this <code>DigrestParameter</code> item. The value may
169         * be null but must not be longer than the value specified by the
170         * {@link #MAX_NAME_LENGTH} constant.
171         * 
172         * @param name The new name for this item
173         * @throws InvalidDataException If the name is longer than
174         *         {@link #MAX_NAME_LENGTH}
175         */
176        @Override
177        public void setName(String name)
178                        throws InvalidDataException
179        {
180                getData().setName(
181                        StringUtil.setNullableString(name, "name", MAX_NAME_LENGTH));
182        }
183
184        /**
185         * The maximum length of the specificity string that can be stored in the
186         * database.
187         * 
188         * @see #setSpecificity(String)
189         */
190        public static final int MAX_SPECIFICITY_LENGTH = DigestParameterData.MAX_SPECIFICITY_LENGTH;
191
192
193        /**
194         * Get the description of this <code>DigestParameter</code>.
195         * 
196         * @return the description of this digest parameter
197         */
198        public String getSpecificity()
199        {
200                return getData().getSpecificity();
201        }
202
203
204        /**
205         * Set the specificity for this <code>DigrestParameter</code> item. The
206         * value may be null but must not be longer than the value specified by the
207         * {@link #MAX_SPECIFICITY_LENGTH} constant.
208         * 
209         * @param specificity The new specificity for this item
210         * @throws InvalidDataException If the specificity is longer than
211         *         {@link #MAX_SPECIFICITY_LENGTH}
212         */
213        public void setSpecificity(String specificity)
214                        throws InvalidDataException
215        {
216                getData().setSpecificity(
217                        StringUtil.setNullableString(specificity, "specificity",
218                                MAX_SPECIFICITY_LENGTH));
219        }
220}