本文整理汇总了Java中org.olap4j.Cell类的典型用法代码示例。如果您正苦于以下问题:Java Cell类的具体用法?Java Cell怎么用?Java Cell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Cell类属于org.olap4j包,在下文中一共展示了Cell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCellInternal
import org.olap4j.Cell; //导入依赖的package包/类
private Cell getCellInternal(int[] pos) {
RolapCell cell;
try {
cell = (RolapCell) result.getCell(pos);
} catch (MondrianException e) {
if (e.getMessage().indexOf("coordinates out of range") >= 0) {
int[] dimensions = new int[getAxes().size()];
for (int i = 0; i < axisList.size(); i++) {
dimensions[i] = axisList.get(i).getPositions().size();
}
throw new IndexOutOfBoundsException(
"Cell coordinates (" + getCoordsAsString(pos)
+ ") fall outside CellSet bounds ("
+ getCoordsAsString(dimensions) + ")");
} else if (e.getMessage().indexOf(
"coordinates should have dimension") >= 0)
{
throw new IllegalArgumentException(
"Cell coordinates should have dimension "
+ axisList.size());
} else {
throw e;
}
}
return new MondrianOlap4jCell(pos, this, cell);
}
示例2: emitCell
import org.olap4j.Cell; //导入依赖的package包/类
private void emitCell(SaxWriter writer, Cell cell) throws OlapException {
++cellOrdinal;
Util.discard(cellOrdinal);
// Ignore empty cells.
final Object cellValue = cell.getValue();
if (cellValue == null) {
return;
}
writer.startElement("row");
for (ColumnHandler columnHandler : columnHandlers) {
columnHandler.write(writer, cell, members);
}
writer.endElement();
}
示例3: getCellInternal
import org.olap4j.Cell; //导入依赖的package包/类
private Cell getCellInternal(int[] pos) {
mondrian.olap.Cell cell;
try {
cell = result.getCell(pos);
} catch (MondrianException e) {
if (e.getMessage().indexOf("coordinates out of range") >= 0) {
int[] dimensions = new int[getAxes().size()];
for (int i = 0; i < axisList.size(); i++) {
dimensions[i] = axisList.get(i).getPositions().size();
}
throw new IndexOutOfBoundsException(
"Cell coordinates (" + getCoordsAsString(pos)
+ ") fall outside CellSet bounds ("
+ getCoordsAsString(dimensions) + ")");
} else if (e.getMessage().indexOf(
"coordinates should have dimension") >= 0)
{
throw new IllegalArgumentException(
"Cell coordinates should have dimension "
+ axisList.size());
} else {
throw e;
}
}
return new MondrianOlap4jCell(pos, this, cell);
}
示例4: getCell
import org.olap4j.Cell; //导入依赖的package包/类
@Override
public Cell getCell(List<Integer> coordinates) {
String skey = getKeyFromInts(coordinates);
Cell cell = cells.get(skey);
if(cell==null){
cell = new ServerCell(this, coordinates, null, null);
cells.put(skey, cell);
}
return cell;
}
示例5: addCell
import org.olap4j.Cell; //导入依赖的package包/类
public Cell addCell(Integer[] integers, Number value, DecimalFormat format) {
List<Integer> positions = Arrays.asList(integers);
ServerCell cell = new ServerCell(this, positions, value, format);
String skey = getKeyFromInts(positions);
cells.put(skey, cell);
return cell;
}
示例6: getCell
import org.olap4j.Cell; //导入依赖的package包/类
@Override
public JROlapCell getCell(int[] axisPositions)
{
List<Integer> positions = new ArrayList<Integer>(axisPositions.length);
for (int index = 0; index < axisPositions.length; index++)
{
positions.add(axisPositions[index]);
}
Cell dataCell = cellSet.getCell(positions);
return new Olap4jCell(dataCell);
}
示例7: next
import org.olap4j.Cell; //导入依赖的package包/类
@Override
public List<?> next() throws TranslatorException {
if (!rowPositionIterator.hasNext()) {
return null;
}
Position rowPosition = rowPositionIterator.next();
Object[] result = new Object[colWidth];
int i = 0;
// add in rows axis
List<Member> members = rowPosition.getMembers();
for (Member member:members) {
String columnName = member.getName();
result[i++] = columnName;
}
// add col axis
for (Position colPos : columnsAxis) {
Cell cell = cellSet.getCell(colPos, rowPosition);
result[i++] = cell.getValue();
}
if (returnsArray) {
ArrayList<Object[]> results = new ArrayList<Object[]>(1);
results.add(result);
return results;
}
return Arrays.asList(result);
}
示例8: getCell
import org.olap4j.Cell; //导入依赖的package包/类
public Cell getCell(List<Integer> coordinates) {
int[] coords = new int[coordinates.size()];
for (int i = 0; i < coords.length; i++) {
coords[i] = coordinates.get(i);
}
return getCellInternal(coords);
}
示例9: testCellProperties
import org.olap4j.Cell; //导入依赖的package包/类
public void testCellProperties() throws SQLException {
final OlapConnection connection =
getTestContext().getOlap4jConnection();
final CellSet cellSet =
connection.createStatement().executeOlapQuery(
"with member [Customers].[USA].[CA WA] as\n"
+ " Aggregate({[Customers].[USA].[CA], [Customers].[USA].[WA]})\n"
+ "select [Measures].[Unit Sales] on 0,\n"
+ " {[Customers].[USA].[CA], [Customers].[USA].[CA WA]} on 1\n"
+ "from [Sales]\n"
+ "cell properties ACTION_TYPE, DRILLTHROUGH_COUNT");
final CellSetMetaData metaData = cellSet.getMetaData();
final Property actionTypeProperty =
metaData.getCellProperties().get("ACTION_TYPE");
final Property drillthroughCountProperty =
metaData.getCellProperties().get("DRILLTHROUGH_COUNT");
// Cell [0, 0] is drillable
final Cell cell0 = cellSet.getCell(0);
final int actionType0 =
(Integer) cell0.getPropertyValue(actionTypeProperty);
assertEquals(0x100, actionType0); // MDACTION_TYPE_DRILLTHROUGH
final int drill0 =
(Integer) cell0.getPropertyValue(drillthroughCountProperty);
assertEquals(24442, drill0);
// Cell [0, 1] is not drillable
final Cell cell1 = cellSet.getCell(1);
final int actionType1 =
(Integer) cell1.getPropertyValue(actionTypeProperty);
assertEquals(0x0, actionType1);
final int drill1 =
(Integer) cell1.getPropertyValue(drillthroughCountProperty);
assertEquals(-1, drill1);
}
示例10: cellIter
import org.olap4j.Cell; //导入依赖的package包/类
/**
* Returns an iterator over cells in a result.
*/
private static Iterable<Cell> cellIter(final int[] pageCoords, final CellSet cellSet) {
return new Iterable<Cell>() {
public Iterator<Cell> iterator() {
final int[] axisDimensions = new int[cellSet.getAxes().size() - pageCoords.length];
assert pageCoords.length <= axisDimensions.length;
for (int i = 0; i < axisDimensions.length; i++) {
final CellSetAxis axis = cellSet.getAxes().get(i);
axisDimensions[i] = axis.getPositions().size();
}
final CoordinateIterator coordIter = new CoordinateIterator(axisDimensions, true);
return new Iterator<Cell>() {
public boolean hasNext() {
return coordIter.hasNext();
}
public Cell next() {
final int[] ints = coordIter.next();
final AbstractList<Integer> intList = new AbstractList<Integer>() {
@Override
public Integer get(final int index) {
return index < ints.length ? ints[index] : pageCoords[index - ints.length];
}
@Override
public int size() {
return pageCoords.length + ints.length;
}
};
return cellSet.getCell(intList);
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
示例11: cellIter
import org.olap4j.Cell; //导入依赖的package包/类
/**
* Returns an iterator over cells in a result.
*/
private static Iterable<Cell> cellIter( final int[] pageCoords, final CellSet cellSet ) {
return new Iterable<Cell>() {
public Iterator<Cell> iterator() {
final int[] axisDimensions = new int[cellSet.getAxes().size() - pageCoords.length];
assert pageCoords.length <= axisDimensions.length;
for ( int i = 0; i < axisDimensions.length; i++ ) {
final CellSetAxis axis = cellSet.getAxes().get( i );
axisDimensions[i] = axis.getPositions().size();
}
final CoordinateIterator coordIter = new CoordinateIterator( axisDimensions, true );
return new Iterator<Cell>() {
public boolean hasNext() {
return coordIter.hasNext();
}
public Cell next() {
final int[] ints = coordIter.next();
final AbstractList<Integer> intList = new AbstractList<Integer>() {
@Override
public Integer get( final int index ) {
return index < ints.length ? ints[index] : pageCoords[index - ints.length];
}
@Override
public int size() {
return pageCoords.length + ints.length;
}
};
return cellSet.getCell( intList );
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
示例12: parseCellDataElement
import org.olap4j.Cell; //导入依赖的package包/类
protected void parseCellDataElement(CellSet result) throws JRException
{
if (log.isDebugEnabled())
{
log.debug("COLUMNS axis size: " + result.getAxes().get(Axis.COLUMNS.axisOrdinal())
.getPositions().size());
log.debug("ROWS axis size: " + result.getAxes().get(Axis.ROWS.axisOrdinal())
.getPositions().size());
}
for (Position axis_1 : result.getAxes().get(Axis.ROWS.axisOrdinal()).getPositions())
{
for (Position axis_0 : result.getAxes().get(Axis.COLUMNS.axisOrdinal()).getPositions())
{
Cell currentCell = result.getCell(axis_0, axis_1);
if (currentCell.isError())
{
handleCellErrors(currentCell);
}
else
{
int cellOrdinal = currentCell.getOrdinal();
Object value = currentCell.getValue();
if (value instanceof Number)
{
try
{
value = currentCell.getDoubleValue();
}
catch (OlapException e)
{
throw new JRException(e);
}
}
String fmtValue = currentCell.getFormattedValue();
JRXmlaCell cell = new JRXmlaCell(value, fmtValue);
if (log.isDebugEnabled())
{
log.debug("Cell: " + cellOrdinal + ", at axis 0 pos: " + axis_0.getOrdinal() + ", axis 1 pos: " + axis_1.getOrdinal());
}
xmlaResult.setCell(cell, cellOrdinal);
}
}
}
}
示例13: handleCellErrors
import org.olap4j.Cell; //导入依赖的package包/类
protected void handleCellErrors(Cell currentCell) throws JRException
{
log.error(currentCell.getValue());
throw new JRException((OlapException) currentCell.getValue());
}
示例14: Olap4jCell
import org.olap4j.Cell; //导入依赖的package包/类
public Olap4jCell(Cell cell)
{
this.value = cell.getValue();
this.formattedValue = cell.getFormattedValue();
}
示例15: printBody
import org.olap4j.Cell; //导入依赖的package包/类
/**
* Prints the body in the CellSetRenderer
*/
private boolean printBody(Graphics2D g, int maxRowHeight, int numRows,
int firstRecord, double rowHeaderWidth, int colHeaderSumHeight,
int[] columnWidthList, Color oldForeground) {
g.setBackground(oldForeground);
CellSetAxis columnsAxis = getCellSet().getAxes().get(0);
CellSetAxis rowsAxis = getCellSet().getAxes().get(1);
g.setFont(getBodyFont());
for (int row = firstRecord; row < rowsAxis.getPositionCount(); row++) {
if (row == numRows + firstRecord) {
return true;
}
int colPosition = 0;
for (int col = 0; col < columnsAxis.getPositionCount(); col++) {
String formattedValue;
Cell cell = getCellSet().getCell(
columnsAxis.getPositions().get(col),
rowsAxis.getPositions().get(row));
if (bodyFormat != null) {
try {
formattedValue = bodyFormat.format(cell.getDoubleValue());
} catch (OlapException e) {
throw new RuntimeException(e);
}
} else {
formattedValue = cell.getFormattedValue();
}
double alignmentShift = 0;
int columnWidth = columnWidthList[col];
//final int columnWidth = tableAsModel.getColumnModel().getColumn(col).getWidth();
final double textWidthInContext = getBodyFont().getStringBounds(formattedValue, g.getFontRenderContext()).getWidth();
switch (bodyAlignment) {
case RIGHT:
alignmentShift = columnWidth - textWidthInContext;
break;
case LEFT:
break;
case CENTER:
alignmentShift = (columnWidth - textWidthInContext) / 2;
break;
default:
throw new IllegalStateException("Unknown alignment of type " + bodyAlignment);
}
// g.setBackground(Color.decode((String) cell.getPropertyValue(Property.StandardCellProperty.BACK_COLOR)));
if (logger.isDebugEnabled()) {
logger.debug("");
logger.debug("Value: " + cell.getPropertyValue(Property.StandardCellProperty.VALUE));
logger.debug("Cell evaluation list: " + cell.getPropertyValue(Property.StandardCellProperty.CELL_EVALUATION_LIST));
logger.debug("Font flags: " + cell.getPropertyValue(Property.StandardCellProperty.FONT_FLAGS));
logger.debug("Fore Color: " + cell.getPropertyValue(Property.StandardCellProperty.FORE_COLOR));
logger.debug("Back Color " + cell.getPropertyValue(Property.StandardCellProperty.BACK_COLOR));
logger.debug("Formatted Value " + cell.getPropertyValue(Property.StandardCellProperty.FORMATTED_VALUE));
logger.debug("Non empty behaviour" + cell.getPropertyValue(Property.StandardCellProperty.NON_EMPTY_BEHAVIOR));
}
// g.setColor((Color) cell.getPropertyValue(Property.StandardCellProperty.FORE_COLOR));
g.drawString(formattedValue, (int) (rowHeaderWidth + colPosition + alignmentShift), (int) (colHeaderSumHeight + ((row - firstRecord) * maxRowHeight) + maxRowHeight));
colPosition += columnWidth;
}
}
return false;
}