Example usage for java.lang IndexOutOfBoundsException getClass

List of usage examples for java.lang IndexOutOfBoundsException getClass

Introduction

In this page you can find the example usage for java.lang IndexOutOfBoundsException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.bt.aloha.eventing.EventDispatcher.java

protected List<?> filterListeners(final List<?> rawListenerList, Object event) {
    if (rawListenerList == null || rawListenerList.size() == 0) {
        log.debug(String.format("NO listeners found for %s", event.getClass().getSimpleName()));
        return new ArrayList<Object>();
    }//w  ww.ja  v  a2 s  . com

    log.debug(String.format("Filtering %d listeners for event %s", rawListenerList.size(),
            event.getClass().getSimpleName()));
    List<Object> matchingListeners = new ArrayList<Object>();
    for (int i = 0; i < rawListenerList.size(); i++) {
        Object listener = null;
        try {
            listener = rawListenerList.get(i);
        } catch (IndexOutOfBoundsException e) {
            log.debug(String.format("%s: size changed whilst processing listener list",
                    e.getClass().getSimpleName()));
            continue;
        }
        if (listener instanceof EventFilter) {
            EventFilter filteringListener = (EventFilter) listener;
            if (filteringListener.shouldDeliverEvent(event)) {
                matchingListeners.add(listener);
            } else {
                log.info(String.format("Listener %s does NOT want event %s",
                        filteringListener.getClass().getSimpleName(), event.getClass().getSimpleName()));
            }
        } else {
            matchingListeners.add(listener);
        }
    }
    log.debug(String.format("Returning %d listeners found for %s", matchingListeners.size(),
            event.getClass().getSimpleName()));
    return matchingListeners;
}

From source file:org.entrystore.repository.impl.ListImpl.java

public void loadChildren() {
    try {/*w  w w  .j  ava 2 s  . c o  m*/
        synchronized (this.entry.repository) {
            if (children != null) {
                return;
            }
            children = new Vector<URI>();

            RepositoryConnection rc = entry.repository.getConnection();
            try {
                RepositoryResult<Statement> statements = rc.getStatements(null, null, null, false,
                        this.resourceURI);
                while (statements.hasNext()) {
                    Statement statement = statements.next();
                    org.openrdf.model.URI predicate = statement.getPredicate();
                    if (!predicate.toString().startsWith(RDF.NAMESPACE.toString() + "_")) {
                        continue;
                    }

                    try {
                        //                     children.add(URI.create(statement.getObject().stringValue())); 
                        String value = predicate.toString().substring(RDF.NAMESPACE.length());
                        int index = Integer.parseInt(value.substring(value.lastIndexOf("_") + 1));
                        //                     children.ensureCapacity(index);

                        if (index > children.size()) {
                            children.setSize(index);
                        }

                        children.set(index - 1, URI.create(statement.getObject().stringValue()));
                    } catch (IndexOutOfBoundsException iobe) {
                        log.error(
                                "loadChildren() " + iobe.getClass().getSimpleName() + ": " + iobe.getMessage());
                    } catch (NumberFormatException nfe) {
                        log.error("loadChildren() " + nfe.getClass().getSimpleName() + ": " + nfe.getMessage());
                        log.error("Causing statement: " + statement);
                    }
                }
                children.trimToSize();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                rc.close();
            }
        }
    } catch (RepositoryException e) {
        e.printStackTrace();
    }
}