コード例 #1
0
 public String getAttribute(String name) {
   List<NvPair> list = getNvPairs();
   if (list == null) {
     return null;
   }
   for (NvPair nv : list) {
     if (nv.getName().equals(name)) {
       return nv.getPropValue();
     }
   }
   return null;
 }
コード例 #2
0
 public void delete(Session session) {
   if (getBranches() != null) {
     for (Branch b : getBranches()) {
       b.delete(session);
     }
     setBranches(null);
   }
   if (getNvPairs() != null) {
     for (NvPair p : getNvPairs()) {
       p.delete(session);
     }
     setNvPairs(null);
   }
   session.delete(this);
 }
コード例 #3
0
 public Repository setAttribute(String name, String value, Session session) {
   if (value != null) {
     value = value.trim();
     if (value.length() == 0) {
       value = null;
     }
   }
   List<NvPair> list = getNvPairs();
   if (list == null) {
     list = new ArrayList<>();
     setNvPairs(list);
   }
   if (value == null) {
     Iterator<NvPair> it = list.iterator();
     while (it.hasNext()) {
       NvPair nv = it.next();
       if (nv.getName().equals(name)) {
         session.delete(nv);
         it.remove();
       }
     }
   } else {
     NvPair found = null;
     for (NvPair nv : list) {
       if (nv.getName().equals(name)) {
         found = nv;
         break;
       }
     }
     if (found == null) {
       found = new NvPair();
       found.setRepository(this);
       found.setName(name);
       list.add(found);
     }
     found.setPropValue(value);
     session.save(found);
   }
   return this;
 }