View Javadoc

1   /*
2    * Copyright (C) The MetaClass Group. All rights reserved.
3    *
4    * This software is published under the terms of the Spice
5    * Software License version 1.1, a copy of which has been included
6    * with this distribution in the LICENSE.txt file.
7    */
8   package org.codehaus.metaclass.tools.tasks;
9   
10  import org.apache.tools.ant.types.EnumeratedAttribute;
11  
12  /***
13   * This is an enumeration that gives the option of either outputting as xml or
14   * as a serialized format.
15   *
16   * @author <a href="mailto:peter at apache.org">Peter Donald</a>
17   * @version $Revision: 1.6 $ $Date: 2003/12/11 08:41:50 $
18   */
19  public class FormatEnum
20      extends EnumeratedAttribute
21  {
22      /***
23       * Return type code for format.
24       *
25       * @return the typecode
26       */
27      public int getTypeCode()
28      {
29          final String value = super.getValue();
30          if( value.equals( "class" ) )
31          {
32              return GenerateClassDescriptorsTask.CLASS_TYPE;
33          }
34          else if( value.equals( "binary" ) )
35          {
36              return GenerateClassDescriptorsTask.BINARY_TYPE;
37          }
38          else
39          {
40              return GenerateClassDescriptorsTask.XML_TYPE;
41          }
42      }
43  
44      /***
45       * Return the set of valid values.
46       *
47       * @return the set of valid values.
48       */
49      public String[] getValues()
50      {
51          return new String[]{"xml", "binary", "class"};
52      }
53  }