public static Memory[] getMemoriesOfGroup(Memories cfg, String groupName) { ArrayList<Memory> res = new ArrayList<Memory>(); for (Memory g : cfg.getMemory()) if (groupName == null && g.getGroup() == null || groupName != null && groupName.equals(g.getGroup())) res.add(g); return (Memory[]) res.toArray(new Memory[res.size()]); }
public static Memory getMemory(Memories cfg, String groupName, String instName) { if (cfg == null) return null; for (Memory g : cfg.getMemory()) if ((groupName == null && g.getGroup() == null || groupName != null && groupName.equals(g.getGroup())) && (instName.equals(g.getInstanceName()))) return g; return null; }
public Memories clone(Memories cfg) { if (cfg == null) return null; Memories newMemories = new Memories(); if (cfg.getInstanceName() != null) newMemories.setInstanceName(cfg.getInstanceName()); for (Memory m : cfg.getMemory()) { newMemories.getMemory().add(clone(m)); } for (MemoryGroup mg : cfg.getMemoryGroup()) { newMemories.getMemoryGroup().add(clone(mg)); } return newMemories; }
public static boolean existGroup(Memories cfg, String groupName) { for (MemoryGroup g : cfg.getMemoryGroup()) { if (groupName.equals(g.getName())) return true; } return false; }
/** * checks if a memData object still exists in the memory specification * * @param cfg * @param memData * @return */ public static boolean existMemDataObject(Memories cfg, Memory memData) { for (Memory g : cfg.getMemory()) { if (g == memData) return true; } return false; }
public static MemoryGroup getMemoryGroup(Memories cfg, String groupName) { for (MemoryGroup g : cfg.getMemoryGroup()) if (groupName.equals(g.getName())) return g; return null; }