All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.tablesAssociations.stg Maven / Gradle / Ivy

There is a newer version: 1.6.2
Show newest version

expandMethod(roleName,toMany,className,otherClassName) ::=
<<
   public Table expand(String... rowName)
   {
      Table result = new Table();
      result.setColumnMap(this.columnMap);
      result.setTable(table);
      int newColumnNumber = this.table.size() > 0 ? this.table.get(0).size() : 0;

      String newColumnName = rowName != null && rowName.length > 0 ? rowName[0] : "" + ((char)('A' + newColumnNumber));
      result.setColumnName(newColumnName);
      columnMap.put(newColumnName, newColumnNumber);

      ArrayList\ > oldTable = (ArrayList\ >) this.table.clone();
      this.table.clear();
      for (ArrayList\ row : oldTable)
      {
      
          start = () row.get(columnMap.get(this.getColumnName()));
         for ( current : start.get())
         {
            ArrayList\ newRow = (ArrayList\) row.clone();
            newRow.add(current);
            this.table.add(newRow);
         }
      
          start = () row.get(columnMap.get(this.getColumnName()));
         ArrayList\ newRow = (ArrayList\) row.clone();
         newRow.add(start.get());
         this.table.add(newRow);
      
      }
      return result;
   }
>>



hasMethod(roleName,toMany,className,otherClassName) ::=
<<
   public Table has(Table rowName)
   {
      ArrayList\ > oldTable = (ArrayList\ >) this.table.clone();
      this.table.clear();
      for (ArrayList\ row : oldTable)
      {
          start = () row.get(columnMap.get(this.getColumnName()));
          other = () row.get(columnMap.get(rowName.getColumnName()));
      
         if (start.get().contains(other))
      
         if (start.get() == other)
      
         {
            this.table.add(row);
         }
      }
      return this;
   }
>>


cap(n) ::=
<%

%>