/** * Add <code>box</code> to the container and sets the parent correctly. If <code>box</code> is <code>null</code> * nochange will be performed and no error thrown. * * @param box will be added to the container */ public void addBox(Box box) { if (box != null) { boxes = new ArrayList<Box>(getBoxes()); boxes.add(box); } }
protected long getContainerSize() { long contentSize = 0; for (int i = 0; i < getBoxes().size(); i++) { // it's quicker to iterate an array list like that since no iterator // needs to be instantiated contentSize += boxes.get(i).getSize(); } return contentSize; }
public final void writeContainer(WritableByteChannel bb) throws IOException { for (Box box : getBoxes()) { box.getBox(bb); } } }
@SuppressWarnings("unchecked") public <T extends Box> List<T> getBoxes(Class<T> clazz, boolean recursive) { List<T> boxesToBeReturned = new ArrayList<T>(2); List<Box> boxes = getBoxes(); for (int i = 0; i < boxes.size(); i++) { Box boxe = boxes.get(i); //clazz.isInstance(boxe) / clazz == boxe.getClass()? // I hereby finally decide to use isInstance if (clazz.isInstance(boxe)) { boxesToBeReturned.add((T) boxe); } if (recursive && boxe instanceof Container) { boxesToBeReturned.addAll(((Container) boxe).getBoxes(clazz, recursive)); } } return boxesToBeReturned; }
@SuppressWarnings("unchecked") public <T extends Box> List<T> getBoxes(Class<T> clazz) { List<T> boxesToBeReturned = null; T oneBox = null; List<Box> boxes = getBoxes(); for (Box boxe : boxes) { //clazz.isInstance(boxe) / clazz == boxe.getClass()? // I hereby finally decide to use isInstance if (clazz.isInstance(boxe)) { if (oneBox == null) { oneBox = (T) boxe; } else { if (boxesToBeReturned == null) { boxesToBeReturned = new ArrayList<T>(2); boxesToBeReturned.add(oneBox); } boxesToBeReturned.add((T) boxe); } } } if (boxesToBeReturned != null) { return boxesToBeReturned; } else if (oneBox != null) { return Collections.singletonList(oneBox); } else { return Collections.emptyList(); } }
for (Box lightBox : isoFile.getBoxes()) { dataOffset += lightBox.getSize();
/** * Add <code>box</code> to the container and sets the parent correctly. If <code>box</code> is <code>null</code> * nochange will be performed and no error thrown. * * @param box will be added to the container */ public void addBox(Box box) { if (box != null) { boxes = new ArrayList<Box>(getBoxes()); boxes.add(box); } }
protected long getContainerSize() { long contentSize = 0; for (int i = 0; i < getBoxes().size(); i++) { // it's quicker to iterate an array list like that since no iterator // needs to be instantiated contentSize += boxes.get(i).getSize(); } return contentSize; }
public final void writeContainer(WritableByteChannel bb) throws IOException { for (Box box : getBoxes()) { box.getBox(bb); } } }
@SuppressWarnings("unchecked") public <T extends Box> List<T> getBoxes(Class<T> clazz, boolean recursive) { List<T> boxesToBeReturned = new ArrayList<T>(2); List<Box> boxes = getBoxes(); for (int i = 0; i < boxes.size(); i++) { Box boxe = boxes.get(i); //clazz.isInstance(boxe) / clazz == boxe.getClass()? // I hereby finally decide to use isInstance if (clazz.isInstance(boxe)) { boxesToBeReturned.add((T) boxe); } if (recursive && boxe instanceof Container) { boxesToBeReturned.addAll(((Container) boxe).getBoxes(clazz, recursive)); } } return boxesToBeReturned; }
@SuppressWarnings("unchecked") public <T extends Box> List<T> getBoxes(Class<T> clazz) { List<T> boxesToBeReturned = null; T oneBox = null; List<Box> boxes = getBoxes(); for (Box boxe : boxes) { //clazz.isInstance(boxe) / clazz == boxe.getClass()? // I hereby finally decide to use isInstance if (clazz.isInstance(boxe)) { if (oneBox == null) { oneBox = (T) boxe; } else { if (boxesToBeReturned == null) { boxesToBeReturned = new ArrayList<T>(2); boxesToBeReturned.add(oneBox); } boxesToBeReturned.add((T) boxe); } } } if (boxesToBeReturned != null) { return boxesToBeReturned; } else if (oneBox != null) { return Collections.singletonList(oneBox); } else { return Collections.emptyList(); } }
for (Box lightBox : isoFile.getBoxes()) { dataOffset += lightBox.getSize();