// @Override
        public Row getSubSelection(DataSetHeader header)
        {
            int size = header.size();

            Object[] values = new Object[size];
            Style[]  styles = new Style[size];
            for (int i = 0; i < size; i++)
            {
                SelectItem selectItem = header.getSelectItem(i);

                if (selectItem.getSubQuerySelectItem() != null)
                {
                    values[i] = getValue(selectItem.getSubQuerySelectItem());
                    styles[i] = getStyle(selectItem.getSubQuerySelectItem());
                    if (values[i] == null)
                    {
                        values[i] = getValue(selectItem);
                        styles[i] = getStyle(selectItem);
                    }
                }
                else
                {
                    values[i] = getValue(selectItem);
                    styles[i] = getStyle(selectItem);
                }
            }
            return(new DefaultRow(header, values, styles));
        }
 // @Override
 public Row convert(Document document, DataSetHeader header)
 {
     Debug.Assert(header.size() == 1);
     Object[] values = new Object[1];
     values[0] = document.getValues();
     return(new DefaultRow(header, values));
 }
 // @Override
 public Row convert(amm_data.Document document, DataSetHeader header)
 {
     Object[] values = new Object[header.size()];
     for (int i = 0; i < values.Length; i++)
     {
         String columnName = header.getSelectItem(i).getColumn().getName();
         values[i] = get(document, columnName);
     }
     return(new DefaultRow(header, values));
 }
Пример #4
0
        /**
         * Constructs a row.
         *
         * @param header
         * @param values
         * @param styles
         */
        public DefaultRow(DataSetHeader header, Object[] values, Style[] styles)
        {
            if (header == null)
            {
                throw new ArgumentException("DataSet header cannot be null");
            }
            if (values == null)
            {
                throw new ArgumentException("Values cannot be null");
            }
            if (header.size() != values.Length)
            {
                throw new ArgumentException("Header size and values length must be equal. " + header.size()
                                            + " select items present in header and encountered these values: "
                                            + values.ToString());
            }
            if (styles != null)
            {
                if (values.Length != styles.Length)
                {
                    throw new ArgumentException("Values length and styles length must be equal. " + values.Length
                                                + " values present and encountered these styles: " + styles.ToString());
                }
                bool entirelyNoStyle = true;
                for (int i = 0; i < styles.Length; i++)
                {
                    if (styles[i] == null)
                    {
                        throw new ArgumentException("Elements in the style array cannot be null");
                    }
                    if (entirelyNoStyle && !StyleConstants.NO_STYLE.Equals(styles[i]))
                    {
                        entirelyNoStyle = false;
                    }
                }

                if (entirelyNoStyle)
                {
                    // no need to reference any styles
                    styles = null;
                }
            }
            _header = header;
            _values = values;
            _styles = styles;
        }