|
| 1 | +import java.util.List; |
| 2 | +import java.util.Vector; |
| 3 | + |
| 4 | +/****************************** |
| 5 | +* Copyright (c) 2003,2019 Kevin Lano |
| 6 | +* This program and the accompanying materials are made available under the |
| 7 | +* terms of the Eclipse Public License 2.0 which is available at |
| 8 | +* http://www.eclipse.org/legal/epl-2.0 |
| 9 | +* |
| 10 | +* SPDX-License-Identifier: EPL-2.0 |
| 11 | +* *****************************/ |
| 12 | + |
| 13 | +public class ClassDiagram |
| 14 | +{ private List entities = new Vector(); |
| 15 | + private List associations = new Vector(); |
| 16 | + private List constraints = new Vector(); |
| 17 | + private List types = new Vector(); |
| 18 | + private List generalisations = new Vector(); |
| 19 | + private List visuals = new Vector(); // VisualData |
| 20 | + |
| 21 | + public ClassDiagram(List es, List as, List cs, |
| 22 | + List ts, List gs, List vs) |
| 23 | + { entities = es; |
| 24 | + associations = as; |
| 25 | + constraints = cs; |
| 26 | + types = ts; |
| 27 | + generalisations = gs; |
| 28 | + visuals = vs; |
| 29 | + } |
| 30 | + |
| 31 | + public Association getAssociation(String nme) |
| 32 | + { return (Association) |
| 33 | + ModelElement.lookupByName(nme,(Vector) associations); |
| 34 | + } |
| 35 | + |
| 36 | + public Entity getEntity(String nme) |
| 37 | + { return (Entity) |
| 38 | + ModelElement.lookupByName(nme,(Vector) entities); |
| 39 | + } |
| 40 | + |
| 41 | + public VisualData getVisualDataOf(ModelElement m) |
| 42 | + { for (int i = 0; i < visuals.size(); i++) |
| 43 | + { VisualData vd = (VisualData) visuals.get(i); |
| 44 | + if (vd.getModelElement() == m) // equals ?? |
| 45 | + { return vd; } |
| 46 | + } |
| 47 | + return null; |
| 48 | + } |
| 49 | + |
| 50 | + public void addEntity(Entity e) |
| 51 | + { entities.add(e); } |
| 52 | + |
| 53 | + public void removeAssociation(Association ast) |
| 54 | + { associations.remove(ast); } |
| 55 | + |
| 56 | + public void addAssociation(Association ast) |
| 57 | + { associations.add(ast); } |
| 58 | + |
| 59 | + public void addVisual(VisualData vd) |
| 60 | + { visuals.add(vd); } |
| 61 | + |
| 62 | + public void removeVisual(VisualData vd) |
| 63 | + { visuals.remove(vd); } |
| 64 | + |
| 65 | + public List getEntities() |
| 66 | + { return entities; } |
| 67 | + |
| 68 | + public List getAssociations() |
| 69 | + { return associations; } |
| 70 | + |
| 71 | +} |
| 72 | + |
0 commit comments