[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Vertex.java,1.13,1.14 MemoryFacade.ja
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2005-10-07 05:52:55
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22550/src/net/sourceforge/bprocessor/model Modified Files: Vertex.java MemoryFacade.java Log Message: MemoryFacade now implemented Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Vertex.java 6 Oct 2005 11:11:07 -0000 1.13 --- Vertex.java 7 Oct 2005 05:52:48 -0000 1.14 *************** *** 189,193 **** public Set getEdges() { Set result = new HashSet(); ! Set edges = EdgeFacade.getInstance().findAll(); Iterator iter = edges.iterator(); while (iter.hasNext()) { --- 189,193 ---- public Set getEdges() { Set result = new HashSet(); ! Set edges = Project.getInstance().getEdges(); Iterator iter = edges.iterator(); while (iter.hasNext()) { Index: MemoryFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/MemoryFacade.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MemoryFacade.java 6 Oct 2005 11:11:07 -0000 1.1 --- MemoryFacade.java 7 Oct 2005 05:52:48 -0000 1.2 *************** *** 8,12 **** --- 8,15 ---- package net.sourceforge.bprocessor.model; + import java.util.Collection; import java.util.HashMap; + import java.util.HashSet; + import java.util.Iterator; import java.util.Set; *************** *** 17,31 **** /** The vertices */ ! private HashMap vertices; /** The edges */ ! private HashMap edges; /** The surfaces */ ! private HashMap surfaces; /** The domains */ ! private HashMap domains; ! /** --- 20,41 ---- /** The vertices */ ! private HashMap vertices = new HashMap(); ! /** The vertex id */ ! private long vertexId; /** The edges */ ! private HashMap edges = new HashMap(); ! /** The edge id */ ! private long edgeId; /** The surfaces */ ! private HashMap surfaces = new HashMap(); ! /** The surface id */ ! private long surfaceId; /** The domains */ ! private HashMap domains = new HashMap(); ! /** The domain id */ ! private long domainId; /** *************** *** 34,37 **** --- 44,57 ---- */ public void intern(Object o) { + //System.out.println("intern " + o.toString()); + if (o instanceof Vertex) { + intern((Vertex) o); + } else if (o instanceof Edge) { + intern((Edge) o); + } else if (o instanceof Surface) { + intern((Surface) o); + } else if (o instanceof Domain) { + intern((Domain) o); + } } *************** *** 41,44 **** --- 61,97 ---- */ private void intern(Vertex v) { + v.setId(new Long(vertexId++)); + vertices.put(v.getId(), v); + //System.out.println("v-intern " + v.toString()); + } + + /** + * Intern an Edge + * @param e The Edge + */ + private void intern(Edge e) { + e.setId(new Long(edgeId++)); + edges.put(e.getId(), e); + //System.out.println("e-intern " + e.toString()); + } + + /** + * Intern a Surface + * @param s The Surface + */ + private void intern(Surface s) { + s.setId(new Long(surfaceId++)); + surfaces.put(s.getId(), s); + //System.out.println("s-intern " + s.toString()); + } + + /** + * Intern a Domain + * @param d The Domain + */ + private void intern(Domain d) { + d.setId(new Long(domainId++)); + domains.put(d.getId(), d); + //System.out.println("d-intern " + d.toString()); } *************** *** 53,62 **** /** * Remove an Object ! * @param o The Object */ public void remove(Object o) { ! } /** * Find an attribute by id --- 106,160 ---- /** * Remove an Object ! * @param o The object */ public void remove(Object o) { ! if (o instanceof Vertex) { ! remove((Vertex) o); ! } else if (o instanceof Edge) { ! remove((Edge) o); ! } else if (o instanceof Surface) { ! remove((Surface) o); ! } else if (o instanceof Domain) { ! remove((Domain) o); ! } ! } ! ! /** ! * Remove a Vertex ! * @param v The Vertex ! */ ! private void remove(Vertex v) { ! vertices.remove(v.getId()); ! v.setId(null); ! } ! ! /** ! * Remove an Edge ! * @param e The Edge ! */ ! private void remove(Edge e) { ! edges.remove(e.getId()); ! e.setId(null); ! } ! ! /** ! * Intern a Surface ! * @param s The Surface ! */ ! private void remove(Surface s) { ! surfaces.remove(s.getId()); ! s.setId(null); ! } ! ! /** ! * Remove a Domain ! * @param d The Domain ! */ ! private void remove(Domain d) { ! domains.remove(d.getId()); ! d.setId(null); } + /** * Find an attribute by id *************** *** 73,77 **** */ public Set getConstructionSpaces() { ! return null; } --- 171,175 ---- */ public Set getConstructionSpaces() { ! return filter(domains.values(), ConstructionSpace.class); } *************** *** 82,86 **** */ public ConstructionSpace findConstructionSpaceById(Long id) { ! return null; } --- 180,184 ---- */ public ConstructionSpace findConstructionSpaceById(Long id) { ! return (ConstructionSpace) domains.get(id); } *************** *** 90,94 **** */ public Set getDomains() { ! return null; } --- 188,192 ---- */ public Set getDomains() { ! return new HashSet(domains.values()); } *************** *** 99,103 **** */ public Domain findDomainById(Long id) { ! return null; } --- 197,201 ---- */ public Domain findDomainById(Long id) { ! return (Domain) domains.get(id); } *************** *** 107,111 **** */ public Set getEdges() { ! return null; } --- 205,209 ---- */ public Set getEdges() { ! return new HashSet(edges.values()); } *************** *** 116,120 **** */ public Edge findEdgeById(Long id) { ! return null; } --- 214,218 ---- */ public Edge findEdgeById(Long id) { ! return (Edge) edges.get(id); } *************** *** 124,128 **** */ public Set getElements() { ! return null; } --- 222,226 ---- */ public Set getElements() { ! return filter(domains.values(), Element.class); } *************** *** 133,137 **** */ public Element findElementById(Long id) { ! return null; } --- 231,235 ---- */ public Element findElementById(Long id) { ! return (Element) domains.get(id); } *************** *** 141,145 **** */ public Set getFunctionalSpaces() { ! return null; } --- 239,243 ---- */ public Set getFunctionalSpaces() { ! return filter(domains.values(), FunctionalSpace.class); } *************** *** 150,154 **** */ public FunctionalSpace findFunctionalSpaceById(Long id) { ! return null; } --- 248,252 ---- */ public FunctionalSpace findFunctionalSpaceById(Long id) { ! return (FunctionalSpace) domains.get(id); } *************** *** 158,162 **** */ public Set getParts() { ! return null; } --- 256,260 ---- */ public Set getParts() { ! return filter(domains.values(), Part.class); } *************** *** 167,171 **** */ public Part findPartById(Long id) { ! return null; } --- 265,269 ---- */ public Part findPartById(Long id) { ! return (Part) domains.get(id); } *************** *** 175,179 **** */ public Set getSurfaces() { ! return null; } --- 273,277 ---- */ public Set getSurfaces() { ! return new HashSet(surfaces.values()); } *************** *** 184,188 **** */ public Surface findSurfaceById(Long id) { ! return null; } --- 282,286 ---- */ public Surface findSurfaceById(Long id) { ! return (Surface) surfaces.get(id); } *************** *** 192,196 **** */ public Set getVertices() { ! return null; } --- 290,294 ---- */ public Set getVertices() { ! return new HashSet(vertices.values()); } *************** *** 201,206 **** */ public Vertex findVertexById(Long id) { ! return null; } } --- 299,321 ---- */ public Vertex findVertexById(Long id) { ! return (Vertex) vertices.get(id); } + /** + * Make a set of objects in values of the specified clarse + * @param values The values to filter + * @param clarse The class + * @return The set + */ + private Set filter(Collection values, Class clarse) { + HashSet result = new HashSet(); + Iterator iter = values.iterator(); + while (iter.hasNext()) { + Object current = iter.next(); + if (current.getClass() == clarse) { + result.add(result); + } + } + return result; + } } |