public <T> T lookup(Class<T> clazz) { for (Iterator i = allItems.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof AbstractLookup.Pair) { AbstractLookup.Pair<?> p = (AbstractLookup.Pair<?>)o; if (p.instanceOf(clazz)) { Object ret = p.getInstance(); if (clazz.isInstance(ret)) { return clazz.cast(ret); } } } } return null; }
@Override public String getMessage() { java.io.ByteArrayOutputStream bs = new java.io.ByteArrayOutputStream(); java.io.PrintStream ps = new java.io.PrintStream(bs); ps.println( "Duplicate pair in tree" + // NOI18N "Pair1: " + i1 + " pair2: " + i2 + " index1: " + i1.getIndex() + " index2: " + i2.getIndex() // NOI18N + " item1: " + i1.getInstance() + " item2: " + i2.getInstance() // NOI18N + " id1: " + Integer.toHexString(System.identityHashCode(i1)) // NOI18N + " id2: " + Integer.toHexString(System.identityHashCode(i2)) // NOI18N ); // print (ps, false); ps.close(); return bs.toString(); } }
out.print(" I: " + p.getInstance());
out.print (p.getIndex()); if (instances) { out.print (" I: " + p.getInstance ());
out.print(" I: " + p.getInstance());
out.print(" I: " + p.getInstance());
out.print (p.getIndex()); if (instances) { out.print (" I: " + p.getInstance ());
/** Compares two items. */ public int compare(Object obj, Object obj1) { AbstractLookup.Pair i1 = (AbstractLookup.Pair)obj; AbstractLookup.Pair i2 = (AbstractLookup.Pair)obj1; int result = i1.getIndex() - i2.getIndex(); if (result == 0) { if (i1 != i2) { java.io.ByteArrayOutputStream bs = new java.io.ByteArrayOutputStream (); java.io.PrintStream ps = new java.io.PrintStream (bs); ps.println ( "Please report this exception as issue http://www.netbeans.org/issues/show_bug.cgi?id=13779 " + // NOI18N "Pair1: " + i1 + " pair2: " + i2 + " index1: " + i1.getIndex() + " index2: " + i2.getIndex() // NOI18N + " item1: " + i1.getInstance () + " item2: " + i2.getInstance () // NOI18N + " id1: " + Integer.toHexString (System.identityHashCode (i1)) // NOI18N + " id2: " + Integer.toHexString (System.identityHashCode (i2)) // NOI18N ); //print (ps, false); ps.close (); throw new IllegalStateException (bs.toString ()); } return 0; } return result; }
/** Compares two items. */ public int compare(Object obj, Object obj1) { AbstractLookup.Pair i1 = (AbstractLookup.Pair)obj; AbstractLookup.Pair i2 = (AbstractLookup.Pair)obj1; int result = i1.getIndex() - i2.getIndex(); if (result == 0) { if (i1 != i2) { java.io.ByteArrayOutputStream bs = new java.io.ByteArrayOutputStream (); java.io.PrintStream ps = new java.io.PrintStream (bs); ps.println ( "Please report this exception as issue http://www.netbeans.org/issues/show_bug.cgi?id=13779 " + // NOI18N "Pair1: " + i1 + " pair2: " + i2 + " index1: " + i1.getIndex() + " index2: " + i2.getIndex() // NOI18N + " item1: " + i1.getInstance () + " item2: " + i2.getInstance () // NOI18N + " id1: " + Integer.toHexString (System.identityHashCode (i1)) // NOI18N + " id2: " + Integer.toHexString (System.identityHashCode (i2)) // NOI18N ); //print (ps, false); ps.close (); throw new IllegalStateException (bs.toString ()); } return 0; } return result; }
"Duplicate pair in tree" + // NOI18N "Pair1: " + i1 + " pair2: " + i2 + " index1: " + i1.getIndex() + " index2: " + i2.getIndex() // NOI18N + " item1: " + i1.getInstance () + " item2: " + i2.getInstance () // NOI18N + " id1: " + Integer.toHexString (System.identityHashCode (i1)) // NOI18N + " id2: " + Integer.toHexString (System.identityHashCode (i2)) // NOI18N
"Duplicate pair in tree" + // NOI18N "Pair1: " + i1 + " pair2: " + i2 + " index1: " + i1.getIndex() + " index2: " + i2.getIndex() // NOI18N + " item1: " + i1.getInstance () + " item2: " + i2.getInstance () // NOI18N + " id1: " + Integer.toHexString (System.identityHashCode (i1)) // NOI18N + " id2: " + Integer.toHexString (System.identityHashCode (i2)) // NOI18N
protected Collection<T> allInstances(boolean callBeforeLookup) { if (callBeforeLookup) { reference.lookup.beforeLookup(reference.template); } Collection<T> s = getInstancesCache(); if (s != null) { return s; } Collection<Pair<T>> items = allItemsWithoutBeforeLookup(); ArrayList<T> list = new ArrayList<T>(items.size()); Iterator<Pair<T>> it = items.iterator(); while (it.hasNext()) { Pair<T> item = it.next(); T obj = item.getInstance(); if (reference.template.getType().isInstance(obj)) { list.add(obj); } } s = Collections.unmodifiableList(list); setInstancesCache(s); return s; }
"Pair1: " + i1 + " pair2: " + i2 + " index1: " + i1.getIndex() + " index2: " + +" item1: " + i1.getInstance() + " item2: " + i2.getInstance() // NOI18N +" id1: " + Integer.toHexString(System.identityHashCode(i1)) // NOI18N +" id2: " + Integer.toHexString(System.identityHashCode(i2)) // NOI18N
public Collection<T> allInstances() { reference.lookup.beforeLookup(reference.template); Collection<T> s = getInstancesCache(); if (s != null) { return s; } Collection<Pair<T>> items = allItemsWithoutBeforeLookup(); ArrayList<T> list = new ArrayList<T>(items.size()); Iterator<Pair<T>> it = items.iterator(); while (it.hasNext()) { Pair<T> item = it.next(); T obj = item.getInstance(); if (reference.template.getType().isInstance(obj)) { list.add(obj); } } s = Collections.unmodifiableList(list); setInstancesCache(s); return s; }
@Override public String getMessage() { java.io.ByteArrayOutputStream bs = new java.io.ByteArrayOutputStream(); java.io.PrintStream ps = new java.io.PrintStream(bs); ps.println( "Duplicate pair in tree" + // NOI18N "Pair1: " + i1 + " pair2: " + i2 + " index1: " + i1.getIndex() + " index2: " + i2.getIndex() // NOI18N + " item1: " + i1.getInstance() + " item2: " + i2.getInstance() // NOI18N + " id1: " + Integer.toHexString(System.identityHashCode(i1)) // NOI18N + " id2: " + Integer.toHexString(System.identityHashCode(i2)) // NOI18N ); // print (ps, false); ps.close(); return bs.toString(); } }
public <T> T lookup(Class<T> clazz) { for (Iterator i = allItems.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof AbstractLookup.Pair) { AbstractLookup.Pair<?> p = (AbstractLookup.Pair<?>)o; if (p.instanceOf(clazz)) { Object ret = p.getInstance(); if (clazz.isInstance(ret)) { return clazz.cast(ret); } } } } return null; }
public <T> T lookup(Class<T> clazz) { for (Iterator i = allItems.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof AbstractLookup.Pair) { AbstractLookup.Pair<?> p = (AbstractLookup.Pair<?>)o; if (p.instanceOf(clazz)) { Object ret = p.getInstance(); if (clazz.isInstance(ret)) { return clazz.cast(ret); } } } } return null; }
protected Collection<T> allInstances(boolean callBeforeLookup) { if (callBeforeLookup) { reference.lookup.beforeLookup(reference.template); } Collection<T> s = getInstancesCache(); if (s != null) { return s; } Collection<Pair<T>> items = allItemsWithoutBeforeLookup(); ArrayList<T> list = new ArrayList<T>(items.size()); Iterator<Pair<T>> it = items.iterator(); while (it.hasNext()) { Pair<T> item = it.next(); T obj = item.getInstance(); if (reference.template.getType().isInstance(obj)) { list.add(obj); } } s = Collections.unmodifiableList(list); setInstancesCache(s); return s; }