/** Finds whether a line equal to provided is already registered. * @param line the line to register * @return the registered line equal to line or null */ final Line findLine(Line line) { Map<Line,Reference<Line>> lines = findWeakHashMap(); synchronized (lines) { Reference<Line> r = lines.get(line); Line in = r != null ? r.get() : null; return in; } }
/** Finds whether a line equal to provided is already registered. * @param line the line to register * @return the registered line equal to line or null */ final Line findLine (Line line) { WeakHashMap lines = findWeakHashMap (); synchronized (lines) { Reference r = (Reference)lines.get(line); Line in = (r != null ? (Line)r.get() : null); return in; } }
/** Finds whether a line equal to provided is already registered. * @param line the line to register * @return the registered line equal to line or null */ final Line findLine (Line line) { WeakHashMap lines = findWeakHashMap (); synchronized (lines) { Reference r = (Reference)lines.get(line); Line in = (r != null ? (Line)r.get() : null); return in; } }
/** Registers the line to this <code>Line.Set</code>. * @param line <code>Line</code> to register * @return registered <code>Line</code>. <em>Note:</em> the retruned * <code>Line</code> could be different (identityHashCode not equal) * from the one passed in */ final Line registerLine(Line line) { // beware of null argument if (line == null) throw new NullPointerException(); WeakHashMap lines = findWeakHashMap (); synchronized(lines) { Reference r = (Reference)lines.get(line); Line in = (r != null ? (Line)r.get() : null); if(in == null) { if(line instanceof DocumentLine) { ((DocumentLine)line).init(); } lines.put(line, new WeakReference(line)); in = line; } return in; } }
/** Registers the line to this <code>Line.Set</code>. * @param line <code>Line</code> to register * @return registered <code>Line</code>. <em>Note:</em> the retruned * <code>Line</code> could be different (identityHashCode not equal) * from the one passed in */ final Line registerLine(Line line) { // beware of null argument if (line == null) throw new NullPointerException(); WeakHashMap lines = findWeakHashMap (); synchronized(lines) { Reference r = (Reference)lines.get(line); Line in = (r != null ? (Line)r.get() : null); if(in == null) { if(line instanceof DocumentLine) { ((DocumentLine)line).init(); } lines.put(line, new WeakReference(line)); in = line; } return in; } }
/** Registers the line to this <code>Line.Set</code>. * @param line <code>Line</code> to register * @return registered <code>Line</code>. <em>Note:</em> the retruned * <code>Line</code> could be different (identityHashCode not equal) * from the one passed in */ final Line registerLine(Line line) { // beware of null argument if (line == null) { throw new NullPointerException(); } Map<Line,Reference<Line>> lines = findWeakHashMap(); synchronized (lines) { Reference<Line> r = lines.get(line); Line in = r != null ? r.get() : null; if (in == null) { if (line instanceof DocumentLine) { ((DocumentLine) line).init(); } lines.put(line, new WeakReference<Line>(line)); in = line; } return in; } }