long pColId,
int pColIndex,
ContinuousMatrixJDBC pMatrixJDBC,
List<ContinuousMatrixElementJDBC> pElements) {
ContinuousData continuousData = (ContinuousData) pMatrixJDBC.getMesquiteCharacterData();
//int numChars = continuousData.getNumChars();
int numItems = continuousData.getNumItems();
long[] rowIds = pMatrixJDBC.getRowIDs();
//String gapSymbol = pMatrixJDBC.getCharacterMatrix().getGapSymbol();
//String missingSymbol = pMatrixJDBC.getCharacterMatrix().getMissingSymbol();
//FIXME: worry about symbols string for continuous matrix??
if (numItems > 1) {
// multiple item definitions, use single element as a place holder, add an entry
// to the matrix compoundElement list:
// add elements for the column
for (int rowIndex = 0; rowIndex < rowIds.length; rowIndex++) {
// place holder:
ContinuousMatrixElementJDBC element = new ContinuousMatrixElementJDBC();
// the compound element to be added later:
CompoundElementJDBC compoundElement = new CompoundElementJDBC();
//Set<ContinuousMatrixElement> elements = new HashSet<ContinuousMatrixElement>();
// pre calculate the compound values and cache it in compoundElement.
StringBuilder compoundValues = new StringBuilder();
compoundValues.append('(');
for (int j = 0; j < numItems; j++) {
Double2DArray anItem = getItemDefinitions()[j];
double elementValue = anItem.getValue(pColIndex, rowIndex);
compoundElement.getValues().add(elementValue);
String itemName = getItemDefinitionNames()[j];
// This can be null, means the default definition 'AVG' is used.
Long itemDefId = pMatrixJDBC.getItemDefNameToIDMap().get(itemName);
if (itemDefId == null) {
itemDefId = -1L;
}
compoundElement.getItemDefinitionIDs().add(itemDefId);
compoundValues.append(elementValue);
if (j < numItems - 1) {
compoundValues.append(' ');
}
}
compoundValues.append(')');
compoundElement.setCompoundValue(compoundValues.toString());
compoundElement.setColIndex(pColIndex);
compoundElement.setRowIndex(rowIndex);
pMatrixJDBC.getCompoundElements().add(compoundElement);
element.setElementOrder(pColIndex);
element.setMatrixRowID(rowIds[rowIndex]);
element.setMatrixColID(pColId);
pElements.add(element);
}
} else {
// single item definition, use single element:
// add elements for the column
for (int rowIndex = 0; rowIndex < rowIds.length; rowIndex++) {
ContinuousMatrixElementJDBC element = new ContinuousMatrixElementJDBC();
if (continuousData.isInapplicable(pColIndex, rowIndex)) {
// gap:
element.setGap((short)1);
} else if (!continuousData.isUnassigned(pColIndex, rowIndex)) {
double elementValue = continuousData.getState(pColIndex, rowIndex, 0);
element.setValue(elementValue);
}
element.setElementOrder(pColIndex);
element.setMatrixRowID(rowIds[rowIndex]);