1 18 package org.apache.beehive.netui.compiler.genmodel; 19 20 import org.apache.beehive.netui.compiler.model.ActionOutputModel; 21 import org.apache.beehive.netui.compiler.JpfLanguageConstants; 22 import org.apache.beehive.netui.compiler.CompilerUtils; 23 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance; 24 import org.apache.beehive.netui.compiler.typesystem.declaration.ClassDeclaration; 25 import org.apache.beehive.netui.compiler.typesystem.type.ArrayType; 26 import org.apache.beehive.netui.compiler.typesystem.type.TypeInstance; 27 import org.apache.beehive.netui.compiler.typesystem.type.DeclaredType; 28 import org.apache.beehive.netui.compiler.typesystem.type.PrimitiveType; 29 30 31 public class GenActionOutputModel 32 extends ActionOutputModel 33 implements JpfLanguageConstants 34 { 35 public GenActionOutputModel( AnnotationInstance annotation, ClassDeclaration jclass ) 36 { 37 setName( CompilerUtils.getString( annotation, NAME_ATTR, true ) ); 38 39 Boolean required = CompilerUtils.getBoolean( annotation, REQUIRED_ATTR, false ); 40 boolean nullable = ! required.booleanValue(); 41 setNullable( nullable ); 42 43 TypeInstance baseType = CompilerUtils.getReferenceType( annotation, TYPE_ATTR, true ); 47 StringBuffer arrayDimensions = new StringBuffer (); 48 while ( baseType instanceof ArrayType ) 49 { 50 arrayDimensions.append( ARRAY_TYPE_SUFFIX ); 51 baseType = ( ( ArrayType ) baseType ).getComponentType(); 52 } 53 54 String baseTypeName; 55 if ( baseType instanceof PrimitiveType ) 56 { 57 baseTypeName = ( ( PrimitiveType ) baseType ).getKind().toString().toLowerCase(); 58 } 59 else 60 { 61 assert baseType instanceof DeclaredType : baseType.getClass().getName(); baseTypeName = CompilerUtils.getLoadableName( ( DeclaredType ) baseType ); 63 } 64 65 setType( baseTypeName + arrayDimensions.toString() ); 66 } 67 } 68 | Popular Tags |