Convenience method for reading rows in the database.

@param dto row in database
@return T object
@throws Exception on error
332071
@Override
    public synchronized T read(T dto) throws Exception {
        Cursor cursor = db.query(transformer.getTableName(), transformer.getFields(), transformer.getWhereClause(dto),null, null,null,null);
        T object = null;
        if (cursor.moveToFirst()){
            object = transformer.transform(cursor);
        }
        return object;
    }
910257
private void readObject(final java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException {
     timeStamp = in.readLong();
   }
1066913
@Override
    public <T extends IChemObject> T read(T object) throws CDKException {
        if (object instanceof IChemFile) {
            try {
                return (T) readChemFile((IChemFile) object);
            } catch (IOException e) {
                logger.error("Input/Output error while reading from input: " + e.getMessage());
                throw new CDKException(e.getMessage(), e);
            }
        } else if (object instanceof ICrystal) {
            try {
                return (T) readCrystal((ICrystal) object);
            } catch (IOException e) {
                logger.error("Input/Output error while reading from input: " + e.getMessage());
                throw new CDKException(e.getMessage(), e);
            }
        } else {
            throw new CDKException("Only supported is reading of ChemFile.");
        }
    }
1368573
public Object read(Object object) {
        if(object == null) {
            String msg = "Can not evaluate the identifier \"" + _identifier + "\" on a null object.";
            LOGGER.error(msg);
            throw new RuntimeException(msg);
        }

        if(TRACE_ENABLED)
            LOGGER.trace("Read property " + _identifier + " on object of type " + object.getClass().getName());

        if(object instanceof Map)
            return mapLookup((Map)object, _identifier);
        else if(object instanceof List) {
            int i = parseIndex(_identifier);
            return listLookup((List)object, i);
        }
        else if(object.getClass().isArray()) {
            int i = parseIndex(_identifier);
            return arrayLookup(object, i);
        }
        else return beanLookup(object, _identifier);
    }
97543
public T read(final K key) throws DataAccessException {
        return
            jdbcTemplate.execute(new ConnectionCallback<T>() {
                @Override
                public T doInConnection(Connection connection) throws SQLException, DataAccessException {
                    return crud.read(connection, key);
                }
            });
    }
652482
public void readData(FieldTable table) throws DBException
    {
        if (this.getLookupKey() instanceof String)
        {
            FieldList record = table.getRecord();
            String strTableName = (String)this.getLookupKey();
            String strDBName = null;
            if (strTableName != null)
            {
                if (strTableName.lastIndexOf('/') != -1)
                {
                    strDBName = strTableName.substring(0, strTableName.lastIndexOf('/'));
                    if (strDBName.lastIndexOf('/') != -1)
                        strDBName = strDBName.substring(strDBName.lastIndexOf('/') + 1);
                    strTableName = strTableName.substring(strTableName.lastIndexOf('/') + 1);
                    if (strTableName.indexOf('.') != -1)
                        strTableName = strTableName.substring(0, strTableName.indexOf('.'));
                }
            }

            String strThickRecordClass = record.getClass().getName();
            
            RecordOwner recordOwner = ((Record)record).getRecordOwner();
            BaseDatabase database = (BaseDatabase)recordOwner.getDatabase(record.getDatabaseName(), record.getDatabaseType(), null);
            Record recSource = Record.makeRecordFromClassName(strThickRecordClass, recordOwner, false, true);
            if (recSource == null)
                return;
            if (strTableName != null)
                if (strTableName.length() > 0)
                    if ((!strTableName.equalsIgnoreCase(recSource.getTableNames(false))))
                        if ((recSource.getDatabaseType() & DBConstants.MAPPED) != 0)
                            recSource.setTableNames(strTableName);
            recSource.setTable(database.makeTable(recSource));
            recSource.init(recordOwner);

            recSource.populateThinTable(record, true);
            
            recSource.free();
        }
    }
864537
protected boolean readRow(PersistentStore store,
                              Table t) throws IOException {

        boolean more = readRow(rowIn, 0);

        if (!more) {
            return false;
        }

        Object[] data = rowIn.readData(t.getColumnTypes());

        t.insertFromScript(store, data);

        return true;
    }
1327951
public Object readObject(Object pId, Class pObjClass, Hashtable pMapping)
        throws SQLException {
        return readObject(pId, pObjClass, pMapping, null);
    }
264421
protected <T> T readResponse(Response response,JavaType javaType)
    {
        try
        {
            return objectMapper.readValue(response.body().byteStream(), javaType);
        }
        catch (IOException e)
        {
            throw new ClientMarshallingException("Error reading results.",e);
        }
    }
789785
public T read() throws IOException {
        
        if(readRow()) {
            
            final T bean = instantiateBean(beanMappingCache.getOriginal().getType());
            final CsvBindingErrors bindingErrors = new CsvBindingErrors(beanMappingCache.getOriginal().getType());
            
            final CsvContext context = new CsvContext(getLineNumber(), getRowNumber(), 1);
            context.setRowSource(new ArrayList<Object>(processedColumns));
            
            Optional<SuperCsvRowException> rowException = Optional.empty();
            try {
                executeCellProcessor(processedColumns, getColumns(), beanMappingCache.getCellProcessorsForReading(), context);
                
            } catch(SuperCsvRowException e) {
                /*
                 * カラムごとのCellProcessorのエラーの場合、別なValidatorで値を検証するために、
                 * 後から判定を行うようにする。
                 */
                rowException = Optional.of(e);
                
                final List<CsvError> errors = exceptionConverter.convert(e, beanMappingCache.getOriginal());
                bindingErrors.addAllErrors(errors);
                
            } catch(SuperCsvException e) {
                errorMessages.addAll(exceptionConverter.convertAndFormat(e, beanMappingCache.getOriginal()));
                throw e;
            }
            
            // コールバックメソッドの実行（読み込み前）
            for(CallbackMethod callback : beanMappingCache.getOriginal().getPreReadMethods()) {
                callback.invoke(bean, context, bindingErrors, beanMappingCache.getOriginal());
            }
            
            // beanへのマッピング
            populateBean(bean, beanMappingCache.getNameMapping(), bindingErrors);
            
            // Bean(レコード)の入力値検証
            for(CsvValidator<T> recordValidator : validators) {
                recordValidator.validate(bean, bindingErrors, new ValidationContext<>(context, beanMappingCache.getOriginal()));
            }
            
            // コールバックメソッドの実行（読み込み後）
            for(CallbackMethod callback : beanMappingCache.getOriginal().getPostReadMethods()) {
                callback.invoke(bean, context, bindingErrors, beanMappingCache.getOriginal());
            }
            
            // エラーメッセージの変換
            processErrors(bindingErrors, context, rowException);
            
            return bean;
            
        }
        
        return null; // EOF
        
        
    }
686379
public TransactionChangesLog read(ObjectReader in) throws UnknownClassIdException, IOException
   {

      // read id
      int key;
      if ((key = in.readInt()) != SerializationConstants.TRANSACTION_CHANGES_LOG)
      {
         throw new UnknownClassIdException("There is unexpected class [" + key + "]");
      }

      TransactionChangesLog log = new TransactionChangesLog();
      if (in.readByte() == SerializationConstants.NOT_NULL_DATA)
      {
         log.setSystemId(in.readString());
      }

      while (in.readByte() == SerializationConstants.NOT_NULL_DATA)
      {
         PlainChangesLogReader rdr = new PlainChangesLogReader(holder, spoolConfig);
         PlainChangesLog pl = rdr.read(in);
         log.addLog(pl);
      }

      return log;
   }
1143901
static DataModelDto toDataModelDto(final IDataModel dataModel) {

        Map<String, Object> names = dataModel.getNamedAddresses()
                .entrySet()
                .stream()
                .collect(Collectors.toMap(
                            e -> e.getKey(),
                            e -> e.getValue().address()));

        dataModel.getNamedValues().forEach( (k,v) -> names.put(k, v.get()) );

        Map<String, Object> table = new HashMap<>();
        Map<String, Object> result = new HashMap<>();
        
        for (IDmRow r : dataModel) {
            for (IDmCell c : r) {
                ICellAddress address = c.getAddress();
                
                table.put(address.a1Address().address(), c.getContent().get());

                if (c.getValue().isPresent()) {
                    result.put(address.a1Address().address(), c.getValue().get().get());
                }
            }
        }

        DataModelDto dto = new DataModelDto();
        
        dto.names = names;
        dto.table = table;
        dto.result = result;
        
        dto.dataModelId = dataModel.getDataModelId().toString();
        dto.name = dataModel.getName();
        
        return dto;
    }
968321
@Override
    public synchronized T create(T dto) throws Exception {
        long rowid = db.insert(transformer.getTableName(),null,transformer.transform(dto));
        Log.i(this.getClass().getName(), "ROW ID: " + rowid);

        if (rowid == -1) throw new SQLiteException("Error inserting "+dto.getClass().toString());

        return transformer.setId(dto, (int)rowid);
    }
295872
public Object[] readObjects(Class pObjClass, Hashtable pMapping)
        throws SQLException {
        return readObjects(pObjClass, pMapping, null);
    }
261576
@Override
	public long getObjectClass(long oid) {
		FilePos oie = oidIndex.findOid(oid);
		if (oie == null) {
			throw DBLogger.newObjectNotFoundException("OID not found: " + Util.oidToString(oid));
		}
		
		try {
			fileInAP.seekPage(PAGE_TYPE.DATA, oie.getPage(), oie.getOffs());
			return DataDeSerializerNoClass.getClassOid(fileInAP);
		} catch (Exception e) {
			throw DBLogger.newObjectNotFoundException(
					"ERROR reading object: " + Util.oidToString(oid));
		}
	}
785546
@SuppressWarnings("unchecked")
	public static final <T> T deepCopy(T object) throws Exception {
        ObjectOutputStream output = null;
        ObjectInputStream input = null;

        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            output = new ObjectOutputStream(bos);

            // serialize and pass the object
            output.writeObject(object);
            output.flush();

            ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray());
            input = new ObjectInputStream(bin);

            // return the new object
            return (T) input.readObject();
        } catch (Exception e) {
            throw(e);
        } finally {
            close(output);
            close(input);
        }
    }
1029660
protected String readTableInit() throws IOException {

        boolean more = readRow(rowIn, 0);

        if (!more) {
            return null;
        }

        String s = rowIn.readString();

        // operation is always INSERT
        int checkOp = rowIn.readInt();

        if (checkOp == ScriptWriterBase.INSERT_WITH_SCHEMA) {
            currentSchema = rowIn.readString();
        } else {
            currentSchema = null;
        }

        if (checkOp != ScriptWriterBase.INSERT
                && checkOp != ScriptWriterBase.INSERT_WITH_SCHEMA) {
            throw Error.error(ErrorCode.ERROR_IN_SCRIPT_FILE,
                              ErrorCode.M_ERROR_IN_BINARY_SCRIPT_2);
        }

        return s;
    }