litesoft
@ 811
litesoft / trunk / Java / PoVoGenerator / Generator / src / org / litesoft / generator / GenerateVOGO.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.generator; import org.litesoft.aokeyhole.objects.*; import org.litesoft.bo.attributes.*; import org.litesoft.codegen.*; import org.litesoft.core.typeutils.*; public class GenerateVOGO extends AbstractVOFileGenerator { private String mVoAttributeGenericType = "XXX"; public GenerateVOGO( ErrorSinc pErrorSinc, ObjectMetaData pObjectMetaData, DerivedObjectTuple pDerivedFromObject, ObjectRef pObjectRef, ObjectRef pParentObjectRef ) { super( pErrorSinc, pObjectMetaData, pDerivedFromObject, pObjectRef, "GO", pParentObjectRef ); } @Override protected void LLaddImports() { addImports( // "org.litesoft.bo.views.*", // null ); } @Override protected void LLaddClassDefinition() { String zClassName = mClassName; String zExtendsName = getExtends( "ViewObject" ); if ( mIsParent ) { zClassName += "<T extends " + mObjectName + "<T>>"; mVoAttributeGenericType = "T"; } else { mVoAttributeGenericType = mObjectName; } addNotes( mObjectMetaData.getNotes() ); makeClassAbstract(); addClassDefinition( zClassName, zExtendsName + "<" + mVoAttributeGenericType + ">", mObjectName + "Names" ); } @Override protected void LLaddClassBody() { constructors(); for ( AttributeProxy zAttribute : getAttributes() ) { attribute( zAttribute ); } } private void constructors() { if ( mIsParent ) { addConstructorProtected( mClassName, mObjectName + "MetaData<T> pMetaData" ); addLine( "super( pMetaData );" ); addMethodEnd(); addConstructorProtected( mClassName, mObjectName + "MetaData<T> pMetaData", "boolean pNew", "TransactionSet pTransactionSet" ); addLine( "super( pMetaData, pNew, pTransactionSet );" ); addBlockEnd(); } else { addLine( "@Deprecated" ); addConstructorProtected( mClassName ); addLine( "super( " + mObjectName + "MetaData.getInstance() );" ); addMethodEnd(); addConstructorProtected( mClassName, "boolean pNew", "TransactionSet pTransactionSet" ); addLine( "super( " + mObjectName + "MetaData.getInstance(), pNew, pTransactionSet );" ); addBlockEnd(); } } private void attribute( AttributeProxy pAttribute ) { Class zSimpleDataTypeClass = pAttribute.getSimpleDataType(); if ( zSimpleDataTypeClass == null ) { mErrorSinc.addError( "CurrentlyUnsupportedAttributeType", pAttribute.toString(), mObjectMetaData.toStringForError() ); return; } String zSimpleDataType = Objects.justClassNameIfPackage( zSimpleDataTypeClass, JAVA_LANG_PACKAGE ); addBlankLine(); String zNotes = pAttribute.getNotes(); String zName = pAttribute.getName(); if ( pAttribute.isVirtual() ) { addNotes( zNotes ); addAbstractMethodPublic( zSimpleDataType, "get" + zName ); Mutability zMutability = pAttribute.getMutability(); if ( !Mutability.RO.equals( zMutability ) ) { addBlankLine(); addNotes( zNotes ); addMethodPublic( "void", "set" + zName, zSimpleDataType + " p" + zName ); addLine( "VoAttribute<" + mVoAttributeGenericType + "> zAttribute = getVoAttribute( a" + zName + " );" ); addLine( "if ( verifyMutabilityOnChange( zAttribute, get" + zName + "(), p" + zName + " = zAttribute.normalize( p" + zName + ", zAttribute.isRequired() ) ) )" ); addBlockStart(); addLine( "LLset" + zName + "( p" + zName + " );" ); addBlockEnd(); addMethodEnd(); addNotes( zNotes ); addAbstractMethodProtected( "void", "LLset" + zName, zSimpleDataType + " p" + zName ); } } else { addLine( "private " + zSimpleDataType + " m" + zName + ";" ); addBlankLine(); addNotes( zNotes ); if ( "ID".equals( zName ) ) { addLine( "@Override" ); } addMethodPublic( zSimpleDataType, "get" + zName ); addLine( "return m" + zName + ";" ); addMethodEnd(); addNotes( zNotes ); if ( "ID".equals( zName ) ) { addLine( "@Override" ); } addMethodPublic( "void", "set" + zName, zSimpleDataType + " p" + zName ); addLine( "VoAttribute<" + mVoAttributeGenericType + "> zAttribute = getVoAttribute( a" + zName + " );" ); addLine( "if ( verifyMutabilityOnChange( zAttribute, get" + zName + "(), p" + zName + " = zAttribute.normalize( p" + zName + ", zAttribute.isRequired() ) ) )" ); addBlockStart(); addLine( "LLset" + zName + "( p" + zName + " );" ); addBlockEnd(); addMethodEnd(); addNotes( zNotes ); addMethodProtected( "void", "LLset" + zName, zSimpleDataType + " p" + zName ); addLine( "m" + zName + " = p" + zName + ";" ); addBlockEnd(); } } } |
Commits for litesoft/trunk/Java/PoVoGenerator/Generator/src/org/litesoft/generator/GenerateVOGO.java
Revision | Author | Commited | Message |
---|---|---|---|
811 Diff | GeorgeS | Sat 18 Aug, 2012 13:45:18 +0000 | |
243 Diff | GeorgeS | Sun 05 Jun, 2011 20:29:12 +0000 | |
223 Diff | GeorgeS | Fri 20 May, 2011 19:25:35 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
22 Diff | GeorgeS | Tue 23 Feb, 2010 21:23:42 +0000 | |
21 Diff | GeorgeS | Tue 23 Feb, 2010 21:11:25 +0000 | |
18 Diff | GeorgeS | Fri 19 Feb, 2010 00:27:34 +0000 | |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |