예제 #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);
   }
 }
 private static void cartPr(Set<Long> keys, List<Pointer> t) throws JWNLException {
   for (int i = 0; i < t.size(); i++) {
     Pointer ps = t.get(i);
     long sourceOffset = ps.getTargetSynset().getOffset();
     for (int j = i + 1; j < t.size(); j++) {
       Pointer pt = t.get(j);
       long targetOffset = pt.getTargetSynset().getOffset();
       if (sourceOffset != targetOffset) {
         long key;
         if (targetOffset > sourceOffset) {
           key = (targetOffset << 32) + sourceOffset;
         } else {
           key = (sourceOffset << 32) + targetOffset;
         }
         keys.add(key);
       }
     }
   }
 }
예제 #3
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;
 }
예제 #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;
 }