File |
Line |
org\djutils\event\util\EventProducingCollection.java |
179 |
org\djutils\event\util\EventProducingSet.java |
180 |
EventProducingIterator<T> iterator = new EventProducingIterator<T>(this.parent.iterator(), this.sourceIdProvider);
// WEAK reference as an iterator is usually local and should be eligible for garbage collection
iterator.addListener(this, EventProducingIterator.OBJECT_REMOVED_EVENT, ReferenceType.WEAK);
return iterator;
}
/** {@inheritDoc} */
@Override
public void notify(final EventInterface event) throws RemoteException
{
// pass through the OBJECT_REMOVED_EVENT from the iterator
if (event.getType().equals(EventProducingIterator.OBJECT_REMOVED_EVENT))
{
this.fireEvent(OBJECT_REMOVED_EVENT, this.parent.size());
}
}
/** {@inheritDoc} */
@Override
public boolean remove(final Object o)
{
boolean changed = this.parent.remove(o);
if (changed)
{
this.fireEvent(OBJECT_REMOVED_EVENT, this.parent.size());
}
return changed;
}
/** {@inheritDoc} */
@Override
public boolean removeAll(final Collection<?> c)
{
boolean changed = this.parent.removeAll(c);
if (changed)
{
this.fireEvent(OBJECT_REMOVED_EVENT, this.parent.size());
}
return changed;
}
/** {@inheritDoc} */
@Override
public boolean retainAll(final Collection<?> c)
{
boolean changed = this.parent.retainAll(c);
if (changed)
{
this.fireEvent(OBJECT_REMOVED_EVENT, this.parent.size());
}
return changed;
}
/** {@inheritDoc} */
@Override
public Object[] toArray()
{
return this.parent.toArray();
}
/** {@inheritDoc} */
@Override
public <E> E[] toArray(final E[] a) |
File |
Line |
org\djutils\event\util\EventProducingCollection.java |
85 |
org\djutils\event\util\EventProducingSet.java |
86 |
public EventProducingCollection(final Collection<T> parent, final IdProvider sourceIdProvider)
{
Throw.whenNull(parent, "parent cannot be null");
Throw.whenNull(sourceIdProvider, "sourceIdprovider cannot be null");
this.parent = parent;
this.sourceIdProvider = sourceIdProvider;
}
/** {@inheritDoc} */
@Override
public Serializable getSourceId()
{
return this.sourceIdProvider.id();
}
/** {@inheritDoc} */
@Override
public int size()
{
return this.parent.size();
}
/** {@inheritDoc} */
@Override
public boolean isEmpty()
{
return this.parent.isEmpty();
}
/** {@inheritDoc} */
@Override
public void clear()
{
int nr = this.parent.size();
this.parent.clear();
if (nr != this.parent.size())
{
this.fireEvent(OBJECT_REMOVED_EVENT, this.parent.size());
}
}
/** {@inheritDoc} */
@Override
public boolean add(final T o) |
File |
Line |
org\djutils\event\util\EventProducingList.java |
86 |
org\djutils\event\util\EventProducingSet.java |
86 |
public EventProducingList(final List<E> parent, final IdProvider sourceIdProvider)
{
Throw.whenNull(parent, "parent cannot be null");
Throw.whenNull(sourceIdProvider, "sourceIdprovider cannot be null");
this.parent = parent;
this.sourceIdProvider = sourceIdProvider;
}
/** {@inheritDoc} */
@Override
public Serializable getSourceId()
{
return this.sourceIdProvider.id();
}
/** {@inheritDoc} */
@Override
public int size()
{
return this.parent.size();
}
/** {@inheritDoc} */
@Override
public boolean isEmpty()
{
return this.parent.isEmpty();
}
/** {@inheritDoc} */
@Override
public void clear()
{
int nr = this.parent.size();
this.parent.clear();
if (nr != this.parent.size())
{
this.fireEvent(OBJECT_REMOVED_EVENT, this.parent.size());
}
}
/** {@inheritDoc} */
@Override
public void add(final int index, final E element) |
File |
Line |
org\djutils\event\util\EventProducingCollection.java |
85 |
org\djutils\event\util\EventProducingList.java |
86 |
public EventProducingCollection(final Collection<T> parent, final IdProvider sourceIdProvider)
{
Throw.whenNull(parent, "parent cannot be null");
Throw.whenNull(sourceIdProvider, "sourceIdprovider cannot be null");
this.parent = parent;
this.sourceIdProvider = sourceIdProvider;
}
/** {@inheritDoc} */
@Override
public Serializable getSourceId()
{
return this.sourceIdProvider.id();
}
/** {@inheritDoc} */
@Override
public int size()
{
return this.parent.size();
}
/** {@inheritDoc} */
@Override
public boolean isEmpty()
{
return this.parent.isEmpty();
}
/** {@inheritDoc} */
@Override
public void clear()
{
int nr = this.parent.size();
this.parent.clear();
if (nr != this.parent.size())
{
this.fireEvent(OBJECT_REMOVED_EVENT, this.parent.size());
}
}
/** {@inheritDoc} */
@Override
public boolean add(final T o) |
File |
Line |
org\djutils\decoderdumper\CharDecoder.java |
34 |
org\djutils\decoderdumper\HexDecoder.java |
37 |
String format = String.format("%%%ds", fieldsPerLine + (fieldsPerLine - 1) / this.extraSpaceAfterEvery);
this.prototypeLine = String.format(format, "");
}
/** String builder for current output line. */
private StringBuilder buffer = new StringBuilder();
/** {@inheritDoc} */
@Override
public String getResult()
{
String result = this.buffer.toString();
this.buffer.setLength(0);
return result;
}
/** {@inheritDoc} */
@Override
public int getMaximumWidth()
{
return this.prototypeLine.length();
}
/** {@inheritDoc} */
@Override
public boolean append(final int address, final byte theByte) throws IOException
{
if (this.buffer.length() == 0)
{
this.buffer.append(this.prototypeLine);
}
int lineByte = address % this.fieldsPerLine;
int index = lineByte + lineByte / this.extraSpaceAfterEvery; |
File |
Line |
org\djutils\exceptions\Throw.java |
211 |
org\djutils\exceptions\Try.java |
608 |
StackTraceElement[] ste = steList.toArray(new StackTraceElement[steList.size()]);
String where = ste[0].getClassName() + "." + ste[0].getMethodName() + " (" + ste[0].getLineNumber() + "): ";
Object[] args = argList.toArray();
String formattedMessage;
try
{
formattedMessage = where + String.format(message, args);
}
catch (IllegalFormatException exception)
{
formattedMessage = where + message + " [FormatException; args=" + argList + "]";
}
// throw all other exceptions through reflection
T exception;
try
{
Constructor<T> constructor = ClassUtil.resolveConstructor(throwableClass, new Class<?>[] {String.class}); |
File |
Line |
org\djutils\event\util\EventProducingCollection.java |
144 |
org\djutils\event\util\EventProducingSet.java |
145 |
public boolean addAll(final Collection<? extends T> c)
{
boolean changed = this.parent.addAll(c);
if (changed)
{
this.fireEvent(OBJECT_ADDED_EVENT, this.parent.size());
}
else
{
if (!c.isEmpty())
{
this.fireEvent(OBJECT_CHANGED_EVENT, this.parent.size());
}
}
return changed;
}
/** {@inheritDoc} */
@Override
public boolean contains(final Object o)
{
return this.parent.contains(o);
}
/** {@inheritDoc} */
@Override
public boolean containsAll(final Collection<?> c)
{
return this.parent.containsAll(c);
}
/** {@inheritDoc} */
@Override
public EventProducingIterator<T> iterator() |