001    /*
002     * Copyright 2005 Stephen J. McConnell.
003     *
004     * Licensed  under the  Apache License,  Version 2.0  (the "License");
005     * you may not use  this file  except in  compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *   http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed  under the  License is distributed on an "AS IS" BASIS,
012     * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
013     * implied.
014     *
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    
019    package net.dpml.test;
020    
021    import java.awt.Color;
022    import java.io.File;
023    import java.net.URI;
024    
025    /**
026     * Component used for context entry testing. The main purpose of this 
027     * class is to exercise the spectrum of content access operations.
028     *
029     * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
030     * @version 1.2.0
031     */
032    public class ContextTestComponent
033    {
034        //------------------------------------------------------------------
035        // concerns
036        //------------------------------------------------------------------
037    
038       /**
039        * Component driven context criteria.
040        */
041        public interface Context
042        {
043           /**
044            * Return the assigned color.
045            * @return the required color value
046            */
047            Color getColor();
048            
049           /**
050            * Return the assigned color.
051            * @param color the default color value
052            * @return the color value 
053            */
054            Color getOptionalColor( Color color );
055            
056           /**
057            * Return as assigned non-optional integer value.
058            * @return the integer value
059            */
060            int getInteger();
061            
062           /**
063            * Return as resolved optional integer value.
064            * @param value the default value
065            * @return the integer value
066            */
067            int getOptionalInteger( int value );
068            
069           /**
070            * Return as assigned non-optional short value.
071            * @return the short value
072            */
073            short getShort();
074            
075           /**
076            * Return as resolved optional short value.
077            * @param value the default value
078            * @return the short value
079            */
080            short getOptionalShort( short value );
081            
082           /**
083            * Return as assigned non-optional long value.
084            * @return the long value
085            */
086            long getLong();
087            
088           /**
089            * Return as resolved optional long value.
090            * @param value the default value
091            * @return the long value
092            */
093            long getOptionalLong( long value );
094            
095           /**
096            * Return as assigned non-optional byte value.
097            * @return the byte value
098            */
099            byte getByte();
100            
101           /**
102            * Return as resolved optional byte value.
103            * @param value the default value
104            * @return the byte value
105            */
106            byte getOptionalByte( byte value );
107            
108           /**
109            * Return as assigned non-optional double value.
110            * @return the double value
111            */
112            double getDouble();
113            
114           /**
115            * Return as resolved optional double value.
116            * @param value the default value
117            * @return the double value
118            */
119            double getOptionalDouble( double value );
120            
121           /**
122            * Return as assigned non-optional float value.
123            * @return the float value
124            */
125            float getFloat();
126            
127           /**
128            * Return as resolved optional float value.
129            * @param value the default value
130            * @return the float value
131            */
132            float getOptionalFloat( float value );
133            
134           /**
135            * Return as assigned non-optional char value.
136            * @return the char value
137            */
138            char getChar();
139            
140           /**
141            * Return as resolved optional char value.
142            * @param value the default value
143            * @return the char value
144            */
145            char getOptionalChar( char value );
146            
147           /**
148            * Return as assigned non-optional boolean value.
149            * @return the boolean value
150            */
151            boolean getBoolean();
152            
153           /**
154            * Return as resolved optional boolean value.
155            * @param flag the default value
156            * @return the boolean value
157            */
158            boolean getOptionalBoolean( boolean flag );
159            
160           /**
161            * Return as assigned non-optional file value.
162            * @return the file value
163            */
164            File getFile();
165            
166           /**
167            * Return as resolved optional file value.
168            * @param value the default value
169            * @return the file value
170            */
171            File getFile( File value );
172            
173           /**
174            * Return as resolved optional file value.
175            * @param value the default value
176            * @return the file value
177            */
178            File getOptionalFile( File value );
179            
180           /**
181            * Return a non-optional temporary file value.
182            * @return the temp file value
183            */
184            File getTempFile();
185            
186           /**
187            * Return as assigned non-optional uri value.
188            * @return the uri value
189            */
190            URI getURI();
191            
192           /**
193            * Return a optional uri value.
194            * @param value the default value
195            * @return the uri value
196            */
197            URI getOptionalURI( URI value );
198            
199           /**
200            * Return as assigned non-optional name.
201            * @return the name
202            */
203            String getName();
204            
205           /**
206            * Return as assigned non-optional path.
207            * @return the path
208            */
209            String getPath();
210        }
211    
212        private final Context m_context;
213        
214        //------------------------------------------------------------------
215        // constructor
216        //------------------------------------------------------------------
217    
218       /**
219        * Creation of a new context test component.
220        * @param context the component direven context criteria
221        */
222        public ContextTestComponent( final Context context )
223        {
224            m_context = context;
225        }
226        
227       /**
228        * Return the container assigned context instance.
229        * @return the assigned context 
230        */
231        public Context getContext() // for testcase
232        {
233            return m_context;
234        }
235    }