Esempio n. 1
0
 public static String getSlotValue(List<SlotType1> slots, String slotName, String def) {
   for (SlotType1 slot : slots) {
     if (slot.getName().equals(slotName)) {
       List<String> l = slot.getValueList().getValue();
       return l.isEmpty() ? def : l.get(0);
     }
   }
   return def;
 }
Esempio n. 2
0
 public static Map<String, SlotType1> getSlotsFromRegistryObject(RegistryObjectType ro)
     throws JAXBException {
   List<SlotType1> slots = ro.getSlot();
   Map<String, SlotType1> slotByName =
       new HashMap<String, SlotType1>(slots == null ? 0 : slots.size());
   if (slots != null) {
     SlotType1 slot;
     for (int i = 0, len = slots.size(); i < len; i++) {
       slot = slots.get(i);
       slotByName.put(slot.getName(), slot);
     }
   }
   return slotByName;
 }
Esempio n. 3
0
 public static void addOrOverwriteSlot(
     RegistryObjectType ro, Map<String, SlotType1> slots, String slotName, String... val)
     throws JAXBException {
   if (slots.containsKey(slotName)) {
     SlotType1 oldSlot = (SlotType1) slots.get(slotName);
     ro.getSlot().remove(oldSlot);
   }
   SlotType1 slot = objFac.createSlotType1();
   slot.setName(slotName);
   ValueListType valueList = objFac.createValueListType();
   for (int i = 0; i < val.length; i++) {
     valueList.getValue().add(val[i]);
   }
   slot.setValueList(valueList);
   ro.getSlot().add(slot);
 }
Esempio n. 4
0
 /*
  * Return null if slot has not exist or contains the same value, the old value if values are different.
  */
 public static String addOrCheckedOverwriteSlot(
     RegistryObjectType ro,
     Map<String, SlotType1> slots,
     String slotName,
     String val,
     boolean ignoreCase)
     throws JAXBException {
   if (slots == null) slots = getSlotsFromRegistryObject(ro);
   SlotType1 oldSlot = (SlotType1) slots.get(slotName);
   if (oldSlot != null) {
     List<String> values = oldSlot.getValueList().getValue();
     if (values != null
         && values.size() > 0
         && !(ignoreCase ? val.equalsIgnoreCase(values.get(0)) : val.equals(values.get(0)))) {
       return values.get(0);
     }
   }
   addOrOverwriteSlot(ro, slots, slotName, val);
   return null;
 }