private void checkPointers() { if (null != dictionary && dictionary.getCheckAlienPointers() && !checkingPointers) { synchronized (this) { checkingPointers = true; if (null != dictionary && dictionary.isEditable()) { List<Pointer> toDelete = null; for (int i = 0; i < super.size(); i++) { Pointer pointer = super.get(i); if (dictionary != pointer.getSource().getDictionary() || null == pointer.getTarget() || dictionary != pointer.getTarget().getDictionary()) { if (null == toDelete) { toDelete = new ArrayList<Pointer>(); } toDelete.add(pointer); } } if (null != toDelete) { if (log.isWarnEnabled() && 0 < toDelete.size()) { log.warn(JWNL.resolveMessage("DICTIONARY_WARN_002", Synset.this.getOffset())); } for (Pointer pointer : toDelete) { remove(pointer); } } } checkingPointers = false; } } }
@Override public void add(int index, Pointer pointer) { if (null == pointer) { throw new IllegalArgumentException(JWNL.resolveMessage("DICTIONARY_EXCEPTION_043")); } super.add(index, pointer); if (null != dictionary && dictionary.isEditable() && dictionary.getManageSymmetricPointers()) { if (null != pointer.getType().getSymmetricType()) { Pointer symmetric = new Pointer( pointer.getType().getSymmetricType(), pointer.getTarget(), pointer.getSource()); if (!pointer.getTarget().getSynset().getPointers().contains(symmetric)) { pointer.getTarget().getSynset().getPointers().add(symmetric); } } } }