/** * Constructor. * * @param spec data specification * @param rseq row sequence from spec's source table */ SimpleTupleSequence(DataSpec spec, RowSequence rseq) { spec_ = spec; reader_ = spec.createUserDataReader(); baseSeq_ = rseq; int nc = spec.getCoordCount(); mappers_ = new DomainMapper[nc][]; for (int ic = 0; ic < nc; ic++) { mappers_[ic] = getUserCoordMappers(spec, ic); } }
public TupleSequence getTupleSequence(DataSpec spec) { try { RowSequence rseq = spec.getSourceTable().getRowSequence(); return new SimpleTupleSequence(spec, rseq); } catch (IOException e) { logger_.log(Level.WARNING, "Error reading plot data", e); return PlotUtil.EMPTY_TUPLE_SEQUENCE; } }
/** * Utility method to work out the domain mappers for a given coordinate of a DataSpec. For the * requested coord, it returns a mapper array with elements filled, in with any mapper known for * the given user coordinates that has the sub-type appropriate for that coordinate. * * @param dataSpec data specification object * @param icoord index of coordinate in <code>dataSpec</code> * @return mapper array for decoding values of one coordinate of a data spec */ public static DomainMapper[] getUserCoordMappers(DataSpec dataSpec, int icoord) { List<Class<? extends DomainMapper>> userDomains = dataSpec.getCoord(icoord).getUserDomains(); ValueInfo[] userInfos = dataSpec.getUserCoordInfos(icoord); int nu = userDomains.size(); DomainMapper[] mappers = new DomainMapper[nu]; for (int iu = 0; iu < nu; iu++) { Class reqClazz = userDomains.get(iu); if (reqClazz != null) { DomainMapper[] infoMappers = userInfos[iu].getDomainMappers(); for (int im = 0; im < infoMappers.length && mappers[iu] == null; im++) { if (reqClazz.isInstance(infoMappers[im])) { mappers[iu] = infoMappers[im]; } } } } return mappers; }
public Object getObjectValue(int icol) { try { Object[] userCoords = reader_.getUserCoordValues(baseSeq_, irow_, icol); Object value = spec_.getCoord(icol).userToStorage(userCoords, mappers_[icol]); assert value != null; return value; } catch (IOException e) { logError(e); return null; } }