src/org/tiefaces/components/websheet/utility/CommandUtility.java
@SuppressWarnings({ "rawtypes" })
	public static int addRow(final ConfigBuildRef configBuildRef,
			final int rowIndex, final Map<String, Object> dataContext) {

		// replace the lastCollection.
		// since here's add one row.
		// Then we should insert one empty object in the list.
		// The collection must be a list to support add/delete function.
		// and the object must support empty constructor.

		String fullName = ConfigurationUtility.getFullNameFromRow(
				configBuildRef.getSheet().getRow(rowIndex));
		String[] parts = fullName.split(":");
		configBuildRef.getCellHelper().restoreDataContext(fullName);
		CollectionObject collect = configBuildRef.getCellHelper()
				.getLastCollect(fullName);

		Collection lastCollection = collect.getLastCollection();
		int lastCollectionIndex = collect.getLastCollectionIndex();
		EachCommand eachCommand = collect.getEachCommand();
		if (lastCollectionIndex < 0) {
			// no each command in the loop.
			throw new AddRowException("No each command found.");
		}
		String unitFullName = CommandUtility.insertEmptyObjectInContext(
				fullName, lastCollection, eachCommand, lastCollectionIndex,
				dataContext);
		RowsMapping unitRowsMapping = new RowsMapping();
		ConfigRangeAttrs savedRangeAttrs = configBuildRef.getShiftMap()
				.get(fullName);
		int insertPosition = savedRangeAttrs.getFirstRowRef().getRowIndex()
				+ savedRangeAttrs.getFinalLength();
		configBuildRef.setInsertPosition(insertPosition);
		CommandUtility.insertEachTemplate(eachCommand.getConfigRange(),
				configBuildRef, lastCollectionIndex + 1, insertPosition,
				unitRowsMapping);
		ConfigRange currentRange = ConfigurationUtility.buildCurrentRange(
				eachCommand.getConfigRange(), configBuildRef.getSheet(),
				insertPosition);
		List<RowsMapping> currentRowsMappingList = ConfigurationUtility
				.findParentRowsMappingFromShiftMap(parts,
						configBuildRef.getShiftMap());
		currentRowsMappingList.add(unitRowsMapping);
		currentRange.getAttrs().setAllowAdd(true);
		configBuildRef.setBodyAllowAdd(true);
		// reverse order of changeMap.
		Map<String, String> changeMap = new TreeMap<>(
				Collections.reverseOrder());
		ConfigurationUtility.changeIndexNumberInHiddenColumn(configBuildRef,
				currentRange.getAttrs().getLastRowPlusRef().getRowIndex(),
				fullName, changeMap, 1);
		ConfigurationUtility.changeIndexNumberInShiftMap(
				configBuildRef.getShiftMap(), changeMap);
		configBuildRef.putShiftAttrs(unitFullName, currentRange.getAttrs(),
				unitRowsMapping);
		int length = currentRange.buildAt(unitFullName, configBuildRef,
				insertPosition, dataContext, currentRowsMappingList);
		currentRange.getAttrs().setFinalLength(length);

		ConfigurationUtility.reBuildUpperLevelFormula(configBuildRef,
				fullName);
		ConfigurationUtility.changeUpperLevelFinalLength(
				configBuildRef.getShiftMap(), fullName, length);
		currentRowsMappingList.remove(unitRowsMapping);
		dataContext.remove(eachCommand.getVar());

		return length;

	}
@SuppressWarnings({ "rawtypes" })
	public static int addRow(final ConfigBuildRef configBuildRef,
			final int rowIndex, final Map<String, Object> dataContext) {

		// replace the lastCollection.
		// since here's add one row.
		// Then we should insert one empty object in the list.
		// The collection must be a list to support add/delete function.
		// and the object must support empty constructor.

		String fullName = ConfigurationUtility.getFullNameFromRow(
				configBuildRef.getSheet().getRow(rowIndex));
		String[] parts = fullName.split(":");
		configBuildRef.getCellHelper().restoreDataContext(fullName);
		CollectionObject collect = configBuildRef.getCellHelper()
				.getLastCollect(fullName);

		Collection lastCollection = collect.getLastCollection();
		int lastCollectionIndex = collect.getLastCollectionIndex();
		EachCommand eachCommand = collect.getEachCommand();
		if (lastCollectionIndex < 0) {
			// no each command in the loop.
			throw new AddRowException("No each command found.");
		}
		String unitFullName = CommandUtility.insertEmptyObjectInContext(
				fullName, lastCollection, eachCommand, lastCollectionIndex,
				dataContext);
		RowsMapping unitRowsMapping = new RowsMapping();
		ConfigRangeAttrs savedRangeAttrs = configBuildRef.getShiftMap()
				.get(fullName);
		int insertPosition = savedRangeAttrs.getFirstRowRef().getRowIndex()
				+ savedRangeAttrs.getFinalLength();
		configBuildRef.setInsertPosition(insertPosition);
		CommandUtility.insertEachTemplate(eachCommand.getConfigRange(),
				configBuildRef, lastCollectionIndex + 1, insertPosition,
				unitRowsMapping);
		ConfigRange currentRange = ConfigurationUtility.buildCurrentRange(
				eachCommand.getConfigRange(), configBuildRef.getSheet(),
				insertPosition);
		List<RowsMapping> currentRowsMappingList = ConfigurationUtility
				.findParentRowsMappingFromShiftMap(parts,
						configBuildRef.getShiftMap());
		currentRowsMappingList.add(unitRowsMapping);
		currentRange.getAttrs().setAllowAdd(true);
		configBuildRef.setBodyAllowAdd(true);
		// reverse order of changeMap.
		Map<String, String> changeMap = new TreeMap<>(
				Collections.reverseOrder());
		ConfigurationUtility.changeIndexNumberInHiddenColumn(configBuildRef,
				currentRange.getAttrs().getLastRowPlusRef().getRowIndex(),
				fullName, changeMap, 1);
		ConfigurationUtility.changeIndexNumberInShiftMap(
				configBuildRef.getShiftMap(), changeMap);
		configBuildRef.putShiftAttrs(unitFullName, currentRange.getAttrs(),
				unitRowsMapping);
		int length = currentRange.buildAt(unitFullName, configBuildRef,
				insertPosition, dataContext, currentRowsMappingList);
		currentRange.getAttrs().setFinalLength(length);

		ConfigurationUtility.reBuildUpperLevelFormula(configBuildRef,
				fullName);
		ConfigurationUtility.changeUpperLevelFinalLength(
				configBuildRef.getShiftMap(), fullName, length);
		currentRowsMappingList.remove(unitRowsMapping);
		dataContext.remove(eachCommand.getVar());

		return length;

	}
@ SuppressWarnings ( { "rawtypes" } ) public static int addRow ( final ConfigBuildRef configBuildRef , final int rowIndex , final Map < String , Object > dataContext ) { // replace the lastCollection.
 // since here's add one row.
 // Then we should insert one empty object in the list.
 // The collection must be a list to support add/delete function.
 // and the object must support empty constructor.
 String fullName = ConfigurationUtility . getFullNameFromRow ( configBuildRef . getSheet ( ) . getRow ( rowIndex ) ) ; String [ ] parts = fullName . split ( ":" ) ; configBuildRef . getCellHelper ( ) . restoreDataContext ( fullName ) ; CollectionObject collect = configBuildRef . getCellHelper ( ) . getLastCollect ( fullName ) ; Collection lastCollection = collect . getLastCollection ( ) ; int lastCollectionIndex = collect . getLastCollectionIndex ( ) ; EachCommand eachCommand = collect . getEachCommand ( ) ; if ( lastCollectionIndex < 0 ) { // no each command in the loop.
 throw new AddRowException ( "No each command found." ) ; } String unitFullName = CommandUtility . insertEmptyObjectInContext ( fullName , lastCollection , eachCommand , lastCollectionIndex , dataContext ) ; RowsMapping unitRowsMapping = new RowsMapping ( ) ; ConfigRangeAttrs savedRangeAttrs = configBuildRef . getShiftMap ( ) . get ( fullName ) ; int insertPosition = savedRangeAttrs . getFirstRowRef ( ) . getRowIndex ( ) + savedRangeAttrs . getFinalLength ( ) ; configBuildRef . setInsertPosition ( insertPosition ) ; CommandUtility . insertEachTemplate ( eachCommand . getConfigRange ( ) , configBuildRef , lastCollectionIndex + 1 , insertPosition , unitRowsMapping ) ; ConfigRange currentRange = ConfigurationUtility . buildCurrentRange ( eachCommand . getConfigRange ( ) , configBuildRef . getSheet ( ) , insertPosition ) ; List < RowsMapping > currentRowsMappingList = ConfigurationUtility . findParentRowsMappingFromShiftMap ( parts , configBuildRef . getShiftMap ( ) ) ; currentRowsMappingList . add ( unitRowsMapping ) ; currentRange . getAttrs ( ) . setAllowAdd ( true ) ; configBuildRef . setBodyAllowAdd ( true ) ; // reverse order of changeMap.
 Map < String , String > changeMap = new TreeMap <> ( Collections . reverseOrder ( ) ) ; ConfigurationUtility . changeIndexNumberInHiddenColumn ( configBuildRef , currentRange . getAttrs ( ) . getLastRowPlusRef ( ) . getRowIndex ( ) , fullName , changeMap , 1 ) ; ConfigurationUtility . changeIndexNumberInShiftMap ( configBuildRef . getShiftMap ( ) , changeMap ) ; configBuildRef . putShiftAttrs ( unitFullName , currentRange . getAttrs ( ) , unitRowsMapping ) ; int length = currentRange . buildAt ( unitFullName , configBuildRef , insertPosition , dataContext , currentRowsMappingList ) ; currentRange . getAttrs ( ) . setFinalLength ( length ) ; ConfigurationUtility . reBuildUpperLevelFormula ( configBuildRef , fullName ) ; ConfigurationUtility . changeUpperLevelFinalLength ( configBuildRef . getShiftMap ( ) , fullName , length ) ; currentRowsMappingList . remove ( unitRowsMapping ) ; dataContext . remove ( eachCommand . getVar ( ) ) ; return length ; }
Adds the row.

@param configBuildRef
the config build ref
@param rowIndex
the row index
@param dataContext
the data context
@return the int
Adds the row .