예제 #1
0
 @Override
 public boolean retainAll(Collection<?> c) {
   if (null != dictionary && dictionary.isEditable()) {
     List<Pointer> copy = new ArrayList<Pointer>(this);
     boolean result = super.retainAll(c);
     for (Object object : c) {
       if (object instanceof Pointer) {
         Pointer pointer = (Pointer) object;
         if (!copy.contains(pointer)) {
           // delete symmetric pointer from the target
           if (null != pointer.getType().getSymmetricType()
               && dictionary.getManageSymmetricPointers()) {
             for (Pointer p : pointer.getTargetSynset().getPointers()) {
               if (offset == p.getTargetOffset()
                   && pointer.getType().getSymmetricType().equals(p.getType())) {
                 pointer.getTargetSynset().getPointers().remove(p);
                 break;
               }
             }
           }
         }
       }
     }
     return result;
   } else {
     return super.retainAll(c);
   }
 }
예제 #2
0
 @Override
 public Pointer remove(int index) {
   Pointer result = super.remove(index);
   if (null != dictionary
       && dictionary.isEditable()
       && dictionary.getManageSymmetricPointers()) {
     // delete symmetric pointer from the target
     Pointer pointer = get(index);
     if (null != pointer.getType().getSymmetricType()) {
       for (Pointer p : pointer.getTargetSynset().getPointers()) {
         if (offset == p.getTargetOffset()
             && pointer.getType().getSymmetricType().equals(p.getType())) {
           pointer.getTargetSynset().getPointers().remove(p);
           break;
         }
       }
     }
   }
   return result;
 }
예제 #3
0
    @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);
          }
        }
      }
    }
예제 #4
0
 @Override
 protected void removeRange(int fromIndex, int toIndex) {
   if (null != dictionary && dictionary.isEditable()) {
     List<Pointer> copy = new ArrayList<Pointer>(super.subList(fromIndex, toIndex));
     super.removeRange(fromIndex, toIndex);
     for (Pointer pointer : copy) {
       // delete symmetric pointer from the target
       if (null != pointer.getType().getSymmetricType()
           && dictionary.getManageSymmetricPointers()) {
         for (Pointer p : pointer.getTargetSynset().getPointers()) {
           if (offset == p.getTargetOffset()
               && pointer.getType().getSymmetricType().equals(p.getType())) {
             pointer.getTargetSynset().getPointers().remove(p);
             break;
           }
         }
       }
     }
   } else {
     super.removeRange(fromIndex, toIndex);
   }
 }
예제 #5
0
 @Override
 public void clear() {
   if (null != dictionary && dictionary.isEditable()) {
     List<Pointer> copy = new ArrayList<Pointer>(this);
     super.clear();
     for (Pointer pointer : copy) {
       // delete symmetric pointer from the target
       if (null != pointer.getType().getSymmetricType()
           && dictionary.getManageSymmetricPointers()) {
         for (Pointer p : pointer.getTargetSynset().getPointers()) {
           if (offset == p.getTargetOffset()
               && pointer.getType().getSymmetricType().equals(p.getType())) {
             pointer.getTargetSynset().getPointers().remove(p);
             break;
           }
         }
       }
     }
   } else {
     super.clear();
   }
 }
예제 #6
0
 @Override
 public boolean remove(Object o) {
   boolean result = super.remove(o);
   if (null != dictionary
       && dictionary.isEditable()
       && dictionary.getManageSymmetricPointers()
       && o instanceof Pointer) {
     Pointer pointer = (Pointer) o;
     // delete symmetric pointer from the target
     if (null != pointer.getType().getSymmetricType()) {
       if (null != pointer.getTargetSynset()) {
         for (Pointer p : pointer.getTargetSynset().getPointers()) {
           if (offset == p.getTargetOffset()
               && pointer.getType().getSymmetricType().equals(p.getType())) {
             pointer.getTargetSynset().getPointers().remove(p);
             break;
           }
         }
       }
     }
   }
   return result;
 }