public ShapePoint getShapePointForId(int id) { if (packShapePoints) { return shapePoints.get(id); } return getEntityForId(ShapePoint.class, id); }
@Override public void clear() { size = 0; setLength(0); }
@Override public <T> void clearAllEntitiesForType(Class<T> type) { if (packStopTimes && type.equals(StopTime.class)) { stopTimes.clear(); return; } else if (packShapePoints && type.equals(ShapePoint.class)) { shapePoints.clear(); return; } super.clearAllEntitiesForType(type); }
@Override public void close() { if (packStopTimes) { stopTimes.trimToSize(); } if (packShapePoints) { shapePoints.trimToSize(); } super.close(); }
@Override public void saveEntity(Object entity) { if (packStopTimes && entity.getClass().equals(StopTime.class)) { stopTimes.add((StopTime) entity); return; } else if (packShapePoints && entity.getClass().equals(ShapePoint.class)) { shapePoints.add((ShapePoint) entity); return; } super.saveEntity(entity); }
/**** * {@link List} Interface ****/ @Override public boolean add(ShapePoint shapePoint) { int index = size; size++; ensureCapacity(size); shapeIds[index] = shapePoint.getShapeId(); sequences[index] = shapePoint.getSequence(); lats[index] = shapePoint.getLat(); lons[index] = shapePoint.getLon(); distTraveled[index] = shapePoint.getDistTraveled(); return true; }
@Override public <T> void clearAllEntitiesForType(Class<T> type) { if (packStopTimes && type.equals(StopTime.class)) { stopTimes.clear(); return; } else if (packShapePoints && type.equals(ShapePoint.class)) { shapePoints.clear(); return; } super.clearAllEntitiesForType(type); }
@Override public void close() { if (packStopTimes) { stopTimes.trimToSize(); } if (packShapePoints) { shapePoints.trimToSize(); } super.close(); }
@Override public void saveEntity(Object entity) { if (packStopTimes && entity.getClass().equals(StopTime.class)) { stopTimes.add((StopTime) entity); return; } else if (packShapePoints && entity.getClass().equals(ShapePoint.class)) { shapePoints.add((ShapePoint) entity); return; } super.saveEntity(entity); }
/**** * {@link List} Interface ****/ @Override public boolean add(ShapePoint shapePoint) { int index = size; size++; ensureCapacity(size); shapeIds[index] = shapePoint.getShapeId(); sequences[index] = shapePoint.getSequence(); lats[index] = shapePoint.getLat(); lons[index] = shapePoint.getLon(); distTraveled[index] = shapePoint.getDistTraveled(); return true; }
@Override public void clear() { size = 0; setLength(0); }
public ShapePoint getShapePointForId(int id) { if (packShapePoints) { return shapePoints.get(id); } return getEntityForId(ShapePoint.class, id); }
public void trimToSize() { setLength(size); }
@SuppressWarnings("unchecked") @Override public <T> T getEntityForId(Class<T> type, Serializable id) { if (packStopTimes && type.equals(StopTime.class)) { return (T) stopTimes.get((Integer) id); } else if (packShapePoints && type.equals(ShapePoint.class)) { return (T) shapePoints.get((Integer) id); } return super.getEntityForId(type, id); }
public void trimToSize() { setLength(size); }
@SuppressWarnings("unchecked") @Override public <T> T getEntityForId(Class<T> type, Serializable id) { if (packStopTimes && type.equals(StopTime.class)) { return (T) stopTimes.get((Integer) id); } else if (packShapePoints && type.equals(ShapePoint.class)) { return (T) shapePoints.get((Integer) id); } return super.getEntityForId(type, id); }
/**** * Private Methods ****/ private void ensureCapacity(int capacity) { if (shapeIds.length < capacity) { int newLength = Math.max(8, shapeIds.length << 2); setLength(newLength); } }
/**** * Private Methods ****/ private void ensureCapacity(int capacity) { if (shapeIds.length < capacity) { int newLength = Math.max(8, shapeIds.length << 2); setLength(newLength); } }