Search in sources :

Example 1 with Record

use of jp.ossc.nimbus.beans.dataset.Record in project nimbus by nimbus-org.

the class DataSetHtmlConverterTest method testConvertToObject.

public void testConvertToObject() {
    DataSet inputDataSet = new DataSetHtmlConverterTestDataSet();
    DataSetHtmlConverter converter = new DataSetHtmlConverter();
    converter.setCharacterEncodingToObject("Windows-31J");
    DataSetHtmlConverterTestDataSet dataSet = (DataSetHtmlConverterTestDataSet) converter.convertToObject(createTestData(), inputDataSet);
    Header header = dataSet.getHeader();
    RecordList recordList = dataSet.getRecordList();
    Assert.assertEquals("タイトル", header.get(DataSetHtmlConverterTestDataSet.PROPERTY1));
    Assert.assertEquals("テキスト", header.get(DataSetHtmlConverterTestDataSet.PROPERTY2));
    for (int i = 0; i < recordList.size(); i++) {
        Record record = (Record) recordList.get(i);
        Assert.assertEquals("テキスト" + (i + 1) + "-1", record.get(DataSetHtmlConverterTestDataSet.PROPERTY3));
        Assert.assertEquals("テキスト" + (i + 1) + "-2", record.get(DataSetHtmlConverterTestDataSet.PROPERTY4));
        Assert.assertEquals("テキスト" + (i + 1) + "-3", record.get(DataSetHtmlConverterTestDataSet.PROPERTY5));
    }
}
Also used : Header(jp.ossc.nimbus.beans.dataset.Header) RecordList(jp.ossc.nimbus.beans.dataset.RecordList) DataSet(jp.ossc.nimbus.beans.dataset.DataSet) Record(jp.ossc.nimbus.beans.dataset.Record)

Example 2 with Record

use of jp.ossc.nimbus.beans.dataset.Record in project nimbus by nimbus-org.

the class BeanTableView method sort.

protected static Comparator sort(Class elementClass, List list, String[] propNames, boolean[] isAsc) throws IndexPropertyAccessException {
    if (list.size() <= 1) {
        return Record.class.isAssignableFrom(elementClass) ? (Comparator) new RecordList.RecordComparator(propNames, isAsc) : (Comparator) new BeanComparator(elementClass, propNames, isAsc);
    }
    Comparator c = Record.class.isAssignableFrom(elementClass) ? (Comparator) new RecordList.RecordComparator(((Record) list.get(0)).getRecordSchema(), propNames, isAsc) : (Comparator) new BeanComparator(elementClass, propNames, isAsc);
    Collections.sort(list, c);
    return c;
}
Also used : Record(jp.ossc.nimbus.beans.dataset.Record) Comparator(java.util.Comparator)

Example 3 with Record

use of jp.ossc.nimbus.beans.dataset.Record in project nimbus by nimbus-org.

the class CSVRecordReader method readRecord.

/**
 * CSV行を1行、レコードとして読み込む。<p>
 * CSV要素の値を格納するレコードを再利用するためのメソッドである。<br>
 *
 * @param record CSV要素の値を格納するレコード
 * @return CSV要素を格納したレコード
 * @exception IOException 入出力エラーが発生した場合
 * @exception PropertySetException CSV形式の要素文字列のパースに失敗した場合
 */
public Record readRecord(Record record) throws IOException, PropertySetException {
    if (workList == null) {
        workList = new ArrayList();
    }
    List csv = readCSVLineList(workList);
    if (csv == null) {
        return null;
    }
    if (record == null) {
        record = new Record(getRecordSchema());
    } else {
        record.clear();
    }
    for (int i = 0, imax = Math.min(csv.size(), record.size()); i < imax; i++) {
        String element = (String) csv.get(i);
        record.setParseProperty(i, element);
    }
    return record;
}
Also used : Record(jp.ossc.nimbus.beans.dataset.Record)

Example 4 with Record

use of jp.ossc.nimbus.beans.dataset.Record in project nimbus by nimbus-org.

the class FLVRecordReader method readRecord.

/**
 * FLV行を1行、レコードとして読み込む。<p>
 * FLV要素の値を格納するレコードを再利用するためのメソッドである。<br>
 *
 * @param record FLV要素の値を格納するレコード
 * @return FLV要素を格納したレコード
 * @exception IOException 入出力エラーが発生した場合
 * @exception PropertySetException FLV形式の要素文字列のパースに失敗した場合
 */
public Record readRecord(Record record) throws IOException, PropertySetException {
    if (workList == null) {
        workList = new ArrayList();
    }
    List flv = readFLVLineList(workList);
    if (flv == null) {
        return null;
    }
    if (record == null) {
        record = new Record(getRecordSchema());
    } else {
        record.clear();
    }
    for (int i = 0, imax = Math.min(flv.size(), record.size()); i < imax; i++) {
        String element = (String) flv.get(i);
        record.setParseProperty(i, element);
    }
    return record;
}
Also used : Record(jp.ossc.nimbus.beans.dataset.Record)

Example 5 with Record

use of jp.ossc.nimbus.beans.dataset.Record in project nimbus by nimbus-org.

the class DataSetServletRequestParameterConverter method setRecordListProperty.

protected void setRecordListProperty(RecordList recList, String name, String[] vals) throws PropertySetException {
    for (int i = 0; i < vals.length; i++) {
        Record rec = null;
        if (recList.size() > i) {
            rec = recList.getRecord(i);
        } else {
            rec = recList.createRecord();
            recList.addRecord(rec);
        }
        rec.setParseProperty(name, vals[i]);
    }
}
Also used : Record(jp.ossc.nimbus.beans.dataset.Record)

Aggregations

Record (jp.ossc.nimbus.beans.dataset.Record)17 RecordList (jp.ossc.nimbus.beans.dataset.RecordList)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 DataSet (jp.ossc.nimbus.beans.dataset.DataSet)6 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 List (java.util.List)4 Map (java.util.Map)4 NoSuchPropertyException (jp.ossc.nimbus.beans.NoSuchPropertyException)4 Property (jp.ossc.nimbus.beans.Property)3 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 NestedProperty (jp.ossc.nimbus.beans.NestedProperty)2 Header (jp.ossc.nimbus.beans.dataset.Header)2 RecordSchema (jp.ossc.nimbus.beans.dataset.RecordSchema)2 RecordSet (jp.ossc.nimbus.recset.RecordSet)2 ConnectionFactoryException (jp.ossc.nimbus.service.connection.ConnectionFactoryException)2 PersistentException (jp.ossc.nimbus.service.connection.PersistentException)2 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1