[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Contour.java,NONE,1.1 ContourFacade.j
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-07-11 09:31:37
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18710 Added Files: Contour.java ContourFacade.java EdgeFacade.java Edge.java Vertex.java VertexFacade.java Log Message: Initial import --- NEW FILE: ContourFacade.java --- //--------------------------------------------------------------------------------- // $Id: ContourFacade.java,v 1.1 2005/07/11 09:31:23 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.apache.log4j.Logger; /** * Facade for contour */ public class ContourFacade { /** The logger */ private static Logger log = Logger.getLogger(ContourFacade.class); /** The instance */ private static ContourFacade instance; /** Contours */ private Set contours; /** * Constructor */ private ContourFacade() { contours = new HashSet(); } /** * Get the instance * @return The instance */ public static synchronized ContourFacade getInstance() { if (instance == null) { instance = new ContourFacade(); } return instance; } /** * Add a contour * @param c The contour */ public synchronized void add(Contour c) { contours.add(c); } /** * Remove a contour * @param c The contour */ public synchronized void remove(Contour c) { contours.remove(c); } /** * Find all contours * @return The contours (unmodifiable) */ public Set findAll() { return Collections.unmodifiableSet(contours); } /** * Find a contour by id * @param id The id * @return The contour */ public synchronized Contour findById(Long id) { Iterator it = contours.iterator(); while (it.hasNext()) { Contour c = (Contour)it.next(); if (c.getId().equals(id)) { return c; } } return null; } /** * Find a contour by name * @param name The name * @return The contour */ public synchronized Contour findByName(String name) { Iterator it = contours.iterator(); while (it.hasNext()) { Contour c = (Contour)it.next(); if (c.getName().equals(name)) { return c; } } return null; } } --- NEW FILE: VertexFacade.java --- //--------------------------------------------------------------------------------- // $Id: VertexFacade.java,v 1.1 2005/07/11 09:31:24 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.apache.log4j.Logger; /** * Facade for vertex */ public class VertexFacade { /** The logger */ private static Logger log = Logger.getLogger(VertexFacade.class); /** The instance */ private static VertexFacade instance; /** Vertexs */ private Set vertexs; /** * Constructor */ private VertexFacade() { vertexs = new HashSet(); } /** * Get the instance * @return The instance */ public static synchronized VertexFacade getInstance() { if (instance == null) { instance = new VertexFacade(); } return instance; } /** * Add a vertex * @param v The vertex */ public synchronized void add(Vertex v) { vertexs.add(v); } /** * Remove a vertex * @param v The vertex */ public synchronized void remove(Vertex v) { vertexs.remove(v); } /** * Find all vertexs * @return The vertexs (unmodifiable) */ public Set findAll() { return Collections.unmodifiableSet(vertexs); } /** * Find a vertex by id * @param id The id * @return The vertex */ public synchronized Vertex findById(Long id) { Iterator it = vertexs.iterator(); while (it.hasNext()) { Vertex v = (Vertex)it.next(); if (v.getId().equals(id)) { return v; } } return null; } /** * Find a vertex by name * @param name The name * @return The vertex */ public synchronized Vertex findByName(String name) { Iterator it = vertexs.iterator(); while (it.hasNext()) { Vertex v = (Vertex)it.next(); if (v.getName().equals(name)) { return v; } } return null; } } --- NEW FILE: Edge.java --- //--------------------------------------------------------------------------------- // $Id: Edge.java,v 1.1 2005/07/11 09:31:23 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import org.apache.log4j.Logger; /** * The edge */ public class Edge implements Serializable { /** The logger */ private static Logger log = Logger.getLogger(Edge.class); /** Id generator */ private static long l = 0; /** The id */ private Long id; /** The name */ private String name; /** The start vertex */ private Vertex from; /** The end vertex */ private Vertex to; /** The contour relationship */ private Set contours; /** * Constructor for persistence layer */ Edge() { } /** * Constructor * @param name The name */ public Edge(String name) { setId(new Long(l++)); setName(name); setFrom(new Vertex()); setTo(new Vertex()); setContours(new HashSet()); } /** * Get the id * @return The id */ public Long getId() { return id; } /** * Set the id * @param id The id */ private void setId(Long id) { this.id = id; } /** * Get the name * @return The name */ public String getName() { return name; } /** * Set the name * @param name The name */ public void setName(String name) { this.name = name; } /** * Get the to vertex * @return The end vertex */ public Vertex getTo() { return to; } /** * Set the to vertex * @param to The begin vertex */ public void setTo(Vertex to) { this.to = to; } /** * Get the from vertex * @return The begin vertex */ public Vertex getFrom() { return from; } /** * Set the from vertex * @param from The end vertex */ public void setFrom(Vertex from) { this.from = from; } /** * Get the contours * @return The contours */ public Set getContours() { return contours; } /** * Set the contours * @param contours The contours */ public void setContours(Set contours) { this.contours = contours; } /** * Return the hash code of the object * @return The hash */ public int hashCode() { return id.hashCode(); } /** * Indicates whether some other object is equal to this one. * @param o The other object * @return True if equal; otherwise false */ public boolean equals(Object o) { if (!(o instanceof Edge)) { return false; } Edge e = (Edge)o; return this.id.equals(e.getId()); } } --- NEW FILE: Vertex.java --- //--------------------------------------------------------------------------------- // $Id: Vertex.java,v 1.1 2005/07/11 09:31:24 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import org.apache.log4j.Logger; /** * The vertex */ public class Vertex implements Serializable { /** The logger */ private static Logger log = Logger.getLogger(Vertex.class); /** Id generator */ private static long l = 0; /** The id */ private Long id; /** The name */ private String name; /** The x coordinate */ private double x; /** The y coordinate */ private double y; /** The z coordinate */ private double z; /** The w coordinate */ private double w; /** The edge relationship */ private Set edges; /** * Constructor for persistence layer */ Vertex() { } /** * Constructor * @param name The name */ public Vertex(String name) { setId(new Long(l++)); setName(name); setX(0.0); setY(0.0); setZ(0.0); setW(0.0); setEdges(new HashSet()); } /** * Get the id * @return The id */ public Long getId() { return id; } /** * Set the id * @param id The id */ private void setId(Long id) { this.id = id; } /** * Get the name * @return The name */ public String getName() { return name; } /** * Set the name * @param name The name */ public void setName(String name) { this.name = name; } /** * Get the x coordinate * @return The x coordinate */ public double getX() { return x; } /** * Set the x coordinate * @param x The x coordinate */ private void setX(double x) { this.x = x; } /** * Get the y coordinate * @return The y coordinate */ public double getY() { return y; } /** * Set the y coordinate * @param y The y coordinate */ private void setY(double y) { this.y = y; } /** * Get the z coordinate * @return The z coordinate */ public double getZ() { return z; } /** * Set the z coordinate * @param z The z coordinate */ private void setZ(double z) { this.z = z; } /** * Get the w coordinate * @return The w coordinate */ public double getW() { return w; } /** * Set the w coordinate * @param w The w coordinate */ private void setW(double w) { this.w = w; } /** * Get the edges * @return The edges */ public Set getEdges() { return edges; } /** * Set the edges * @param edges The edges */ public void setEdges(Set edges) { this.edges = edges; } /** * Return the hash code of the object * @return The hash */ public int hashCode() { return id.hashCode(); } /** * Indicates whether some other object is equal to this one. * @param o The other object * @return True if equal; otherwise false */ public boolean equals(Object o) { if (!(o instanceof Vertex)) { return false; } Vertex v = (Vertex)o; return this.id.equals(v.getId()); } } --- NEW FILE: Contour.java --- //--------------------------------------------------------------------------------- // $Id: Contour.java,v 1.1 2005/07/11 09:31:23 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; /** * The contour */ public class Contour implements Serializable { /** The logger */ private static Logger log = Logger.getLogger(Contour.class); /** Id generator */ private static long l = 0; /** The id */ private Long id; /** The name */ private String name; /** The edges relationship */ private List edges; /** * Constructor for persistence layer */ Contour() { } /** * Constructor * @param name The name */ public Contour(String name) { setId(new Long(l++)); setName(name); setEdges(new ArrayList()); } /** * Get the id * @return The id */ public Long getId() { return id; } /** * Set the id * @param id The id */ private void setId(Long id) { this.id = id; } /** * Get the name * @return The name */ public String getName() { return name; } /** * Set the name * @param name The name */ public void setName(String name) { this.name = name; } /** * Get the edges * @return The edges */ public List getEdges() { return edges; } /** * Set the edges * @param edges The edges */ public void setEdges(List edges) { this.edges = edges; } /** * Return the hash code of the object * @return The hash */ public int hashCode() { return id.hashCode(); } /** * Indicates whether some other object is equal to this one. * @param o The other object * @return True if equal; otherwise false */ public boolean equals(Object o) { if (!(o instanceof Contour)) { return false; } Contour c = (Contour)o; return this.id.equals(c.getId()); } } --- NEW FILE: EdgeFacade.java --- //--------------------------------------------------------------------------------- // $Id: EdgeFacade.java,v 1.1 2005/07/11 09:31:23 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.apache.log4j.Logger; /** * Facade for edge */ public class EdgeFacade { /** The logger */ private static Logger log = Logger.getLogger(EdgeFacade.class); /** The instance */ private static EdgeFacade instance; /** Edges */ private Set edges; /** * Constructor */ private EdgeFacade() { edges = new HashSet(); } /** * Get the instance * @return The instance */ public static synchronized EdgeFacade getInstance() { if (instance == null) { instance = new EdgeFacade(); } return instance; } /** * Add a edge * @param e The edge */ public synchronized void add(Edge e) { edges.add(e); } /** * Remove a edge * @param e The edge */ public synchronized void remove(Edge e) { edges.remove(e); } /** * Find all edges * @return The edges (unmodifiable) */ public Set findAll() { return Collections.unmodifiableSet(edges); } /** * Find a edge by id * @param id The id * @return The edge */ public synchronized Edge findById(Long id) { Iterator it = edges.iterator(); while (it.hasNext()) { Edge e = (Edge)it.next(); if (e.getId().equals(id)) { return e; } } return null; } /** * Find a edge by name * @param name The name * @return The edge */ public synchronized Edge findByName(String name) { Iterator it = edges.iterator(); while (it.hasNext()) { Edge e = (Edge)it.next(); if (e.getName().equals(name)) { return e; } } return null; } } |