@Override
    public Datastream GetDatastream(String datastreamID, Date versDateTime) {
        // get the one with the closest creation date
        // without going over
        Datastream result = null;
        long bestTimeDifference = Long.MAX_VALUE;
        long latestCreateTime = -1;
        long vTime = -1;
        if (versDateTime != null) {
            vTime = versDateTime.getTime();
        }
        for (Datastream ds : m_obj.datastreams(datastreamID)) {
            if (versDateTime == null) {
                if (ds.DSCreateDT == null || ds.DSCreateDT.getTime() > latestCreateTime || result == null) {
                    result = ds;
                    if (ds.DSCreateDT != null) latestCreateTime = ds.DSCreateDT.getTime();
                }
            } else {
                //TODO If none of the versions have a create date, what should behavior be?
                long diff = (ds.DSCreateDT == null)? vTime : vTime - ds.DSCreateDT.getTime();
                if (diff >= 0) {
                    if (diff < bestTimeDifference) {
                        bestTimeDifference = diff;
                        result = ds;
                    }
                }
            }
        }
        return result;
    }
@ Override public Datastream GetDatastream ( String datastreamID , Date versDateTime ) { Datastream result = null ; long bestTimeDifference = Long . MAX_VALUE ; long latestCreateTime = - 1 ; long vTime = - 1 ; if ( versDateTime != null ) { vTime = versDateTime . getTime ( ) ; } for ( Datastream ds : m_obj . datastreams ( datastreamID ) ) { if ( versDateTime == null ) { if ( ds . DSCreateDT == null || ds . DSCreateDT . getTime ( ) > latestCreateTime || result == null ) { result = ds ; if ( ds . DSCreateDT != null ) latestCreateTime = ds . DSCreateDT . getTime ( ) ; } } else { long diff = ( ds . DSCreateDT == null ) ? vTime : vTime - ds . DSCreateDT . getTime ( ) ; if ( diff >= 0 ) { if ( diff < bestTimeDifference ) { bestTimeDifference = diff ; result = ds ; } } } } return result ; }
{@inheritDoc}