Package org.pentaho.reporting.libraries.formula.lvalues

Examples of org.pentaho.reporting.libraries.formula.lvalues.DefaultDataTable


                // should we check here for column count equality to the first row column count?
                // or do we give this responsability to a DefaultDataTable constructor?
                        rows.add(row);
    }
                LValue[][] table = (LValue[][])rows.toArray(new LValue[rows.size()][]);
                {if (true) return new DefaultDataTable(table);}
    throw new Error("Missing return statement in function");
  }
View Full Code Here


      return (ArrayCallback) value;
    }

    if (value == null)
    {
      return new DefaultDataTable().getAsArray();
    }

    final Class valueType = value.getClass();
    if (valueType.isArray() == false)
    {
      if (value instanceof Collection)
      {
        final Collection colVal = (Collection) value;
        final DefaultDataTable table = new DefaultDataTable();
        final Iterator iterator = colVal.iterator();
        int i = 0;
        while (iterator.hasNext())
        {
          table.setObject(i, 0, new StaticValue(iterator.next()));
          i += 1;
        }
        return table.getAsArray();
      }
      return new ArrayConverterCallback(value, type);
    }

    final Class componentType = valueType.getComponentType();
    if (componentType.isArray())
    {
      final DefaultDataTable table = new DefaultDataTable();
      final int length = Array.getLength(value);
      for (int row = 0; row < length; row++)
      {
        final Object innerArray = Array.get(value, row);
        final int innerLength = Array.getLength(innerArray);
        for (int col = 0; col < innerLength; col++)
        {
          table.setObject(row, col, new StaticValue(Array.get(innerArray, col)));
        }
      }
      return table.getAsArray();
    }

    final DefaultDataTable table = new DefaultDataTable();
    final int length = Array.getLength(value);
    for (int i = 0; i < length; i++)
    {
      table.setObject(i, 0, new StaticValue(Array.get(value, i)));
    }
    return table.getAsArray();
  }
View Full Code Here

    final AnySequence singleValueSequence = new AnySequence(new StaticValue("test"), formulaContext);
    assertTrue(singleValueSequence.hasNext());
    assertEquals("test", singleValueSequence.next());
    assertFalse(singleValueSequence.hasNext());

    final DefaultDataTable rowTable = new DefaultDataTable();
    rowTable.setObject(0, 0, new StaticValue("Test"));
    rowTable.setObject(1, 0, new StaticValue("Test2"));
    final AnySequence rowArraySequence = new AnySequence(rowTable.getAsArray(), formulaContext);
    assertTrue(rowArraySequence.hasNext());
    assertEquals("Test", rowArraySequence.next());
    assertTrue(rowArraySequence.hasNext());
    assertEquals("Test2", rowArraySequence.next());
    assertFalse(rowArraySequence.hasNext());

    final DefaultDataTable colTable = new DefaultDataTable();
    colTable.setObject(0, 0, new StaticValue("Test"));
    colTable.setObject(0, 1, new StaticValue("Test2"));
    final AnySequence colArraySequence = new AnySequence(colTable.getAsArray(), formulaContext);
    assertTrue(colArraySequence.hasNext());
    assertEquals("Test", colArraySequence.next());
    assertTrue(colArraySequence.hasNext());
    assertEquals("Test2", colArraySequence.next());
    assertFalse(colArraySequence.hasNext());

    final DefaultDataTable colRowTable = new DefaultDataTable();
    colRowTable.setObject(0, 0, new StaticValue("Test"));
    colRowTable.setObject(0, 1, new StaticValue("Test2"));
    colRowTable.setObject(1, 0, new StaticValue("Test3"));
    colRowTable.setObject(1, 1, new StaticValue("Test4"));
    final AnySequence colRowArraySequence = new AnySequence(colRowTable.getAsArray(), formulaContext);
    assertTrue(colRowArraySequence.hasNext());
    assertEquals("Test", colRowArraySequence.next());
    assertTrue(colRowArraySequence.hasNext());
    assertEquals("Test2", colRowArraySequence.next());
    assertTrue(colRowArraySequence.hasNext());
View Full Code Here

                // should we check here for column count equality to the first row column count?
                // or do we give this responsability to a DefaultDataTable constructor?
                        rows.add(row);
    }
                LValue[][] table = (LValue[][])rows.toArray(new LValue[rows.size()][]);
                {if (true) return new DefaultDataTable(table);}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.formula.lvalues.DefaultDataTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.