/** * Helper for {@link #UniformListItem}, which returns the alignment * requirement implied by the given list. See the header comment for * more details. * * @param items {@code non-null;} list of items being represented * @return {@code >= 4;} the alignment requirement */ private static int getAlignment(List<? extends OffsettedItem> items) { try { // Since they all must have the same alignment, any one will do. return Math.max(HEADER_SIZE, items.get(0).getAlignment()); } catch (IndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("items.size() == 0"); } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("items == null"); } }
/** * Helper for {@link #UniformListItem}, which returns the alignment * requirement implied by the given list. See the header comment for * more details. * * @param items {@code non-null;} list of items being represented * @return {@code >= 4;} the alignment requirement */ private static int getAlignment(List<? extends OffsettedItem> items) { try { // Since they all must have the same alignment, any one will do. return Math.max(HEADER_SIZE, items.get(0).getAlignment()); } catch (IndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("items.size() == 0"); } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("items == null"); } }
/** * Helper for {@link #UniformListItem}, which returns the alignment * requirement implied by the given list. See the header comment for * more details. * * @param items {@code non-null;} list of items being represented * @return {@code >= 4;} the alignment requirement */ private static int getAlignment(List<? extends OffsettedItem> items) { try { // Since they all must have the same alignment, any one will do. return Math.max(HEADER_SIZE, items.get(0).getAlignment()); } catch (IndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("items.size() == 0"); } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("items == null"); } }
/** * Helper for {@link #UniformListItem}, which returns the alignment * requirement implied by the given list. See the header comment for * more details. * * @param items {@code non-null;} list of items being represented * @return {@code >= 4;} the alignment requirement */ private static int getAlignment(List<? extends OffsettedItem> items) { try { // Since they all must have the same alignment, any one will do. return Math.max(HEADER_SIZE, items.get(0).getAlignment()); } catch (IndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("items.size() == 0"); } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("items == null"); } }
/** * Helper for {@link #UniformListItem}, which returns the alignment * requirement implied by the given list. See the header comment for * more details. * * @param items {@code non-null;} list of items being represented * @return {@code >= 4;} the alignment requirement */ private static int getAlignment(List<? extends OffsettedItem> items) { try { // Since they all must have the same alignment, any one will do. return Math.max(HEADER_SIZE, items.get(0).getAlignment()); } catch (IndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("items.size() == 0"); } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("items == null"); } }
/** * Helper for {@link #UniformListItem}, which returns the alignment * requirement implied by the given list. See the header comment for * more details. * * @param items {@code non-null;} list of items being represented * @return {@code >= 4;} the alignment requirement */ private static int getAlignment(List<? extends OffsettedItem> items) { try { // Since they all must have the same alignment, any one will do. return Math.max(HEADER_SIZE, items.get(0).getAlignment()); } catch (IndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("items.size() == 0"); } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("items == null"); } }
/** * Helper for {@link #UniformListItem}, which returns the alignment * requirement implied by the given list. See the header comment for * more details. * * @param items {@code non-null;} list of items being represented * @return {@code >= 4;} the alignment requirement */ private static int getAlignment(List<? extends OffsettedItem> items) { try { // Since they all must have the same alignment, any one will do. return Math.max(HEADER_SIZE, items.get(0).getAlignment()); } catch (IndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("items.size() == 0"); } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("items == null"); } }
/** * Helper for {@link #UniformListItem}, which returns the alignment * requirement implied by the given list. See the header comment for * more details. * * @param items {@code non-null;} list of items being represented * @return {@code >= 4;} the alignment requirement */ private static int getAlignment(List<? extends OffsettedItem> items) { try { // Since they all must have the same alignment, any one will do. return Math.max(HEADER_SIZE, items.get(0).getAlignment()); } catch (IndexOutOfBoundsException ex) { // Translate the exception. throw new IllegalArgumentException("items.size() == 0"); } catch (NullPointerException ex) { // Translate the exception. throw new NullPointerException("items == null"); } }
/** * Adds an item to this instance. This will in turn tell the given item * that it has been added to this instance. It is invalid to add the * same item to more than one instance, nor to add the same items * multiple times to a single instance. * * @param item {@code non-null;} the item to add */ public void add(OffsettedItem item) { throwIfPrepared(); try { if (item.getAlignment() > getAlignment()) { throw new IllegalArgumentException( "incompatible item alignment"); } } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("item == null"); } items.add(item); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { offset += headerSize(); boolean first = true; int theSize = -1; int theAlignment = -1; for (OffsettedItem i : items) { int size = i.writeSize(); if (first) { theSize = size; theAlignment = i.getAlignment(); first = false; } else { if (size != theSize) { throw new UnsupportedOperationException( "item size mismatch"); } if (i.getAlignment() != theAlignment) { throw new UnsupportedOperationException( "item alignment mismatch"); } } offset = i.place(addedTo, offset) + size; } }
/** * Adds an item to this instance. This will in turn tell the given item * that it has been added to this instance. It is invalid to add the * same item to more than one instance, nor to add the same items * multiple times to a single instance. * * @param item {@code non-null;} the item to add */ public void add(OffsettedItem item) { throwIfPrepared(); try { if (item.getAlignment() > getAlignment()) { throw new IllegalArgumentException( "incompatible item alignment"); } } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("item == null"); } items.add(item); }
/** * Adds an item to this instance. This will in turn tell the given item * that it has been added to this instance. It is invalid to add the * same item to more than one instance, nor to add the same items * multiple times to a single instance. * * @param item {@code non-null;} the item to add */ public void add(OffsettedItem item) { throwIfPrepared(); try { if (item.getAlignment() > getAlignment()) { throw new IllegalArgumentException( "incompatible item alignment"); } } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("item == null"); } items.add(item); }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { offset += headerSize(); boolean first = true; int theSize = -1; int theAlignment = -1; for (OffsettedItem i : items) { int size = i.writeSize(); if (first) { theSize = size; theAlignment = i.getAlignment(); first = false; } else { if (size != theSize) { throw new UnsupportedOperationException( "item size mismatch"); } if (i.getAlignment() != theAlignment) { throw new UnsupportedOperationException( "item alignment mismatch"); } } offset = i.place(addedTo, offset) + size; } }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { offset += headerSize(); boolean first = true; int theSize = -1; int theAlignment = -1; for (OffsettedItem i : items) { int size = i.writeSize(); if (first) { theSize = size; theAlignment = i.getAlignment(); first = false; } else { if (size != theSize) { throw new UnsupportedOperationException( "item size mismatch"); } if (i.getAlignment() != theAlignment) { throw new UnsupportedOperationException( "item alignment mismatch"); } } offset = i.place(addedTo, offset) + size; } }
/** {@inheritDoc} */ @Override protected void place0(Section addedTo, int offset) { offset += headerSize(); boolean first = true; int theSize = -1; int theAlignment = -1; for (OffsettedItem i : items) { int size = i.writeSize(); if (first) { theSize = size; theAlignment = i.getAlignment(); first = false; } else { if (size != theSize) { throw new UnsupportedOperationException( "item size mismatch"); } if (i.getAlignment() != theAlignment) { throw new UnsupportedOperationException( "item alignment mismatch"); } } offset = i.place(addedTo, offset) + size; } }
/** * Adds an item to this instance. This will in turn tell the given item * that it has been added to this instance. It is invalid to add the * same item to more than one instance, nor to add the same items * multiple times to a single instance. * * @param item {@code non-null;} the item to add */ public void add(OffsettedItem item) { throwIfPrepared(); try { if (item.getAlignment() > getAlignment()) { throw new IllegalArgumentException( "incompatible item alignment"); } } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("item == null"); } items.add(item); }
/** * Adds an item to this instance. This will in turn tell the given item * that it has been added to this instance. It is invalid to add the * same item to more than one instance, nor to add the same items * multiple times to a single instance. * * @param item {@code non-null;} the item to add */ public void add(OffsettedItem item) { throwIfPrepared(); try { if (item.getAlignment() > getAlignment()) { throw new IllegalArgumentException( "incompatible item alignment"); } } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("item == null"); } items.add(item); }
/** * Adds an item to this instance. This will in turn tell the given item * that it has been added to this instance. It is invalid to add the * same item to more than one instance, nor to add the same items * multiple times to a single instance. * * @param item {@code non-null;} the item to add */ public void add(OffsettedItem item) { throwIfPrepared(); try { if (item.getAlignment() > getAlignment()) { throw new IllegalArgumentException( "incompatible item alignment"); } } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("item == null"); } items.add(item); }
/** * Adds an item to this instance. This will in turn tell the given item * that it has been added to this instance. It is invalid to add the * same item to more than one instance, nor to add the same items * multiple times to a single instance. * * @param item {@code non-null;} the item to add */ public void add(OffsettedItem item) { throwIfPrepared(); try { if (item.getAlignment() > getAlignment()) { throw new IllegalArgumentException( "incompatible item alignment"); } } catch (NullPointerException ex) { // Elucidate the exception. throw new NullPointerException("item == null"); } items.add(item); }
int alignMask = one.getAlignment() - 1; int writeAt = (at + alignMask) & ~alignMask;