litesoft
@ 950
litesoft / trunk / Java / PoVoGenerator / Generator / src / org / litesoft / generator / GeneratePONamesGO.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 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.generator; import org.litesoft.aokeyhole.objects.*; import org.litesoft.codegen.*; public class GeneratePONamesGO extends AbstractPOFileGenerator { public GeneratePONamesGO( ErrorSinc pErrorSinc, ObjectMetaData pObjectMetaData, ObjectRef pObjectRef, ObjectRef pParentObjectRef, boolean pIsParent ) { super( pErrorSinc, pObjectMetaData, pObjectRef, "NamesGO", pParentObjectRef, pIsParent ); } @Override protected void LLaddImports() { addImports( // "org.litesoft.orsup.nonpublic.*", // null ); } @Override protected void LLaddClassDefinition() { makeClassAbstract(); addClassDefinition( mClassName, getExtends( "AbstractPO" ) + "Names" ); } @Override protected void LLaddClassBody() { if ( mIsParent ) { constructorParent(); } else { addPSFS( "OBJECT_NAME", mObjectName ); addBlankLine(); addPSFS( "DATASTORE_NAME", mPackage + "." + mObjectName ); addBlankLine(); constructorRegular(); } LLaddAttributes( false ); if ( !mIsParent ) { addCollectionOf(); addFactory(); addBlankLine(); addLine( "public static final " + mObjectName + "Names INSTANCE = new " + mObjectName + "Names( null, \"\" );" ); } } private void constructorParent() { addConstructorProtected( mClassName, "AbstractPONames pBuiltBy", "String pObjectName", "String pDatastoreName", "String pParentPath" ); addLine( "super( pBuiltBy, pObjectName, pDatastoreName, pParentPath );" ); addMethodEnd(); } private void constructorRegular() { addConstructorProtected( mClassName, "AbstractPONames pBuiltBy", "String pParentPath" ); addLine( "super( pBuiltBy, OBJECT_NAME, DATASTORE_NAME, pParentPath );" ); addMethodEnd(); } @Override protected void LLaddAttribute( AttributeProxy pAttribute ) { String zName = pAttribute.getName(); add_aRef( zName, pAttribute.getAttributeSetType().toString() ); String zToMany = pAttribute.getToManyFullyQualifiedName(); if ( (zToMany != null) && pAttribute.isToManyInstantiable() ) { add_rRef( zName, zToMany ); add_cRef( zName, zToMany ); } String zToOne = pAttribute.getToOneFullyQualifiedName(); if ( (zToOne != null) && pAttribute.isToOneInstantiable() ) { add_rRef( zName, zToOne ); } addPSFSattributeValidOptions( pAttribute, "po" ); } private void add_aRef( String pName, String pWhatType ) { addNotes( pWhatType ); addLine( "public final String a" + pName + " = mParentPath + " + quote( pName ) + ";" ); } private void add_rRef( String pOurAttributeName, String pToOneFullyQualifiedName ) { addBlankLine(); String zThem = removePackageIfPossible( pToOneFullyQualifiedName ) + "Names"; addMethodPublic( zThem, "r" + pOurAttributeName ); addLine( "return (" + zThem + ") toOne( this, a" + pOurAttributeName + ", " + zThem + ".Factory.INSTANCE );" ); addBlockEnd(); } private void add_cRef( String pOurAttributeName, String pToManyFullyQualifiedName ) { addBlankLine(); String zThem = removePackageIfPossible( pToManyFullyQualifiedName ) + "Names"; addMethodPublic( zThem, "c" + pOurAttributeName ); addLine( "return (" + zThem + ") toMany( this, a" + pOurAttributeName + ", " + zThem + ".Factory.INSTANCE );" ); addBlockEnd(); } private void addCollectionOf() { addBlankLine(); makeClassStatic(); addClassDefinition( "CollectionOf", mObjectName + "Names", "CollectionOfPONamesAccessor" ); addLine( "private String mCollectionPath;" ); addBlankLine(); addConstructorPublic( "CollectionOf", "String pCollectionPath" ); addLine( "super( null, \"\" );" ); addBlankLine(); addLine( "mCollectionPath = pCollectionPath;" ); addMethodEnd(); addLine( "@Override" ); addMethodPublic( "String", "getCollectionPath" ); addLine( "return mCollectionPath;" ); addMethodEnd(); addLine( "@Override" ); addMethodPublic( "String", "toString" ); addLine( "return \"c\" + super.toString();" ); addBlockEnd(); addClassEnd(); } private void addFactory() { addBlankLine(); makeClassStatic(); addClassDefinition( "Factory", null, "IFactory" ); addLine( "public static final IFactory INSTANCE = new Factory();" ); addBlankLine(); addLine( "@Override" ); addMethodPublic( "AbstractPONames", "createToOne", "AbstractPONames pBuiltBy", "String pParentPath" ); addLine( "return new " + mObjectName + "Names( pBuiltBy, pParentPath );" ); addMethodEnd(); addLine( "@Override" ); addMethodPublic( "AbstractPONames", "createToMany", "String pCollectionPath" ); addLine( "return new " + mObjectName + "Names.CollectionOf( pCollectionPath );" ); addBlockEnd(); addClassEnd(); } } |
Commits for litesoft/trunk/Java/PoVoGenerator/Generator/src/org/litesoft/generator/GeneratePONamesGO.java
Revision | Author | Commited | Message |
---|---|---|---|
950 Diff | GeorgeS | Thu 19 Jun, 2014 17:57:04 +0000 | New Lines |
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
193 Diff | GeorgeS | Wed 04 May, 2011 00:59:58 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
19 Diff | GeorgeS | Mon 22 Feb, 2010 17:17:17 +0000 | |
18 Diff | GeorgeS | Fri 19 Feb, 2010 00:27:34 +0000 | |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |