package org.apache.uima.cas;

import java.util.HashSet;
import java.util.Set;

import org.apache.uima.util.Misc;

public class BuiltinTypeKinds {
  
  private static final Set<String> primitiveTypeNames = new HashSet<String>();

  public static final Set<String> creatableArrays = new HashSet<String>();
  
  public static final Set<String> builtinLists = new HashSet<String>();
  
  public static final Set<String> nonCreatablePrimitives = new HashSet<String>();

  /**
   *  These types can not be created with CAS.createFS().
   *    Arrays can be created using CAS.create<XYZ>Array  XYZ = Boolean, Byte, etc.
   */
  public static final Set<String> nonCreatableTypesAndBuiltinArrays = new HashSet<String>();
  
  /**
   * These types are
   *   - builtin, but could be extended by user 
   *   - creatable - so they need a generator.
   *     -- non-creatable built-in types are not generated 
   */
  public static final Set<String> creatableBuiltinJCas = new HashSet<String>();

  static {
    Misc.addAll(primitiveTypeNames, 
        CAS.TYPE_NAME_BOOLEAN,
        CAS.TYPE_NAME_BYTE,
        CAS.TYPE_NAME_SHORT,
        CAS.TYPE_NAME_INTEGER,
        CAS.TYPE_NAME_LONG,
        CAS.TYPE_NAME_FLOAT,
        CAS.TYPE_NAME_DOUBLE,
        CAS.TYPE_NAME_STRING,
        CAS.TYPE_NAME_JAVA_OBJECT
        );
    
    Misc.addAll(creatableArrays,  
        CAS.TYPE_NAME_BOOLEAN_ARRAY,
        CAS.TYPE_NAME_BYTE_ARRAY,
        CAS.TYPE_NAME_SHORT_ARRAY,
        CAS.TYPE_NAME_INTEGER_ARRAY,
        CAS.TYPE_NAME_LONG_ARRAY,
        CAS.TYPE_NAME_FLOAT_ARRAY,
        CAS.TYPE_NAME_DOUBLE_ARRAY,
        CAS.TYPE_NAME_STRING_ARRAY,
        CAS.TYPE_NAME_FS_ARRAY,
        CAS.TYPE_NAME_JAVA_OBJECT_ARRAY
        );
        
    Misc.addAll(builtinLists, 
        CAS.TYPE_NAME_EMPTY_FLOAT_LIST,
        CAS.TYPE_NAME_EMPTY_FS_LIST,
        CAS.TYPE_NAME_EMPTY_INTEGER_LIST,
        CAS.TYPE_NAME_EMPTY_STRING_LIST,
        CAS.TYPE_NAME_FLOAT_LIST,
        CAS.TYPE_NAME_FS_LIST,
        CAS.TYPE_NAME_INTEGER_LIST,
        CAS.TYPE_NAME_STRING_LIST,
        CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST,
        CAS.TYPE_NAME_NON_EMPTY_FS_LIST,
        CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST,
        CAS.TYPE_NAME_NON_EMPTY_STRING_LIST
    );    
 
    Misc.addAll(nonCreatablePrimitives, 
        CAS.TYPE_NAME_BOOLEAN,
        CAS.TYPE_NAME_BYTE,
        CAS.TYPE_NAME_SHORT,
        CAS.TYPE_NAME_INTEGER,
        CAS.TYPE_NAME_LONG,
        CAS.TYPE_NAME_FLOAT,
        CAS.TYPE_NAME_DOUBLE,
        CAS.TYPE_NAME_STRING,
        CAS.TYPE_NAME_JAVA_OBJECT
        );

    nonCreatableTypesAndBuiltinArrays.addAll(nonCreatablePrimitives);
    nonCreatableTypesAndBuiltinArrays.addAll(creatableArrays);
    Misc.addAll(nonCreatableTypesAndBuiltinArrays, CAS.TYPE_NAME_SOFA);
    
    creatableBuiltinJCas.addAll(creatableArrays);
    creatableBuiltinJCas.addAll(builtinLists);
    Misc.addAll(creatableBuiltinJCas, 
        CAS.TYPE_NAME_TOP,
        CAS.TYPE_NAME_ANNOTATION_BASE,
        CAS.TYPE_NAME_ANNOTATION      
        );    
  }
  
  /*****************  public getters and predicates *****************/
    
  public static boolean primitiveTypeNames_contains(String name) {
    return primitiveTypeNames.contains(name);
  }
  
  public static boolean nonCreatableTypesAndBuiltinArrays_contains(String name) {
    return nonCreatableTypesAndBuiltinArrays.contains(name);
  }
  
}

@@ -315,84 +315,8 @@
 %0D%0A  
-%0D%0A  public static final Set%3CString%3E builtinLists = new HashSet%3CString%3E();%0D%0A 
  %0D%0A 
@@ -1720,27 +1720,35 @@
 .addAll(
-b
+creatableB
 uiltin
-List
+JCa
 s, %0D%0A   
@@ -1912,148 +1912,8 @@
 T,%0D%0A
-        CAS.TYPE_NAME_FLOAT_LIST,%0D%0A        CAS.TYPE_NAME_FS_LIST,%0D%0A        CAS.TYPE_NAME_INTEGER_LIST,%0D%0A        CAS.TYPE_NAME_STRING_LIST,%0D%0A
     
@@ -2706,56 +2706,8 @@
 );%0D%0A
-    creatableBuiltinJCas.addAll(builtinLists);%0D%0A
     

remove built-in kind for lists, add the creatible list kinds to the built-in creatables.