public static SlotType1 addSlot(RegistryObjectType ro, String name, String type, String...values) { SlotType1 slot = createSlot(name, type, values); ro.getSlot().add(slot); return slot; } public static SlotType1 setSlot(RegistryObjectType ro, String name, String type, Collection<String> values) {
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; }
public static SlotType1 removeSlot(RegistryObjectType ro, String name) { List<SlotType1> slots = ro.getSlot(); for (int i = 0, len = slots.size() ; i < len ; i++) { if (name.equals(slots.get(i).getName())) { return slots.remove(i); } } return null; }
public static SlotType1 addOrOverwriteSlot(RegistryObjectType ro, SlotType1 slot) { List<SlotType1> slots = ro.getSlot(); String name = slot.getName(); SlotType1 oldSlot = null; for (int i = 0, len = slots.size() ; i < len ; i++) { if (slots.get(i).getName().equals(name)) { oldSlot = slots.remove(i); break; } } slots.add(slot); return oldSlot; }
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); }
public static SlotType1 setSlot(RegistryObjectType ro, String name, String type, Collection<String> values) { SlotType1 slot = createSlot(name, type); if (values != null && values.size() > 0) slot.getValueList().getValue().addAll(values); List<SlotType1> slots = ro.getSlot(); for (int i = 0, len = slots.size() ; i < len ; i++) { if (slots.get(i).getName().equals(name)) { slots.remove(i); break; } } slots.add(slot); return slot; }
private void copySlotType(List<Slot> slots, RegistryObjectType roType) { if (slots != null) { SlotType1 slotType; HashMap<String, SlotType1> slotTypeMap = new HashMap<String, SlotType1>(); for (Slot slot : slots) { slotType = slotTypeMap.get(slot.getName()); if (log.isDebugEnabled()) log.debug("########add slot name:"+slot.getName()+" value:"+slot.getValue()+" parent.pk:"+slot.getParent().getPk()+" pk:"+slot.getPk()); if (slotType == null) { slotType = factory.createSlotType1(); slotType.setName(slot.getName()); slotType.setSlotType(slot.getType()); slotType.setValueList(factory.createValueListType()); slotTypeMap.put(slot.getName(), slotType); } slotType.getValueList().getValue().add(slot.getValue()); } roType.getSlot().addAll(slotTypeMap.values()); } }