Example #1
0
 /**
  * replace element that has specified attribute within descendant element of oneself. you can't
  * replace oneself. It will be replaced by deep copy of "replacement"
  *
  * @param target
  * @param replacement
  * @return if success to replace, return true. if no hit, return false.
  * @throws TagTypeUnmatchException
  */
 public <T extends AbstractJaxb> boolean replace(T target, T replacement)
     throws TagTypeUnmatchException {
   String id = target.getId();
   if (id == null) {
     for (int i = 0; i < 256; i++) {
       id = UUID.randomUUID().toString();
       if (this.getById(id) == null && replacement.getById(id) == null) {
         target.setId(id);
         break;
       }
     }
   }
   return ReplaceByIdUtil.replaceById(id, this, replacement);
 }
Example #2
0
 /**
  * replace element by string. you can't replace oneself.
  *
  * @param id
  * @param replacement
  * @return if success to replace, return true. if no hit, return false.
  * @throws TagTypeUnmatchException
  */
 public <T extends AbstractJaxb> boolean replaceById(String id, String replacement)
     throws TagTypeUnmatchException {
   return ReplaceByIdUtil.replaceById(id, this, replacement);
 }