Line | Hits | Source |
---|---|---|
1 | /******************************************************************************* | |
2 | * Demetrix process modelling system | |
3 | * | |
4 | * Copyright (c) 2003, 2004 Dimitri A. Pissarenko | |
5 | * | |
6 | * This file is part of Demetrix. | |
7 | * | |
8 | * Demetrix is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2.1 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * Demetrix is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with Demetrix; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | * | |
22 | * For further information you may | |
23 | * | |
24 | * - send an e-mail in Russian, German or English to dimitri.pissarenko@gmx.net | |
25 | * - look at http://sourceforge.net/projects/demetrix/ | |
26 | * - look at http://demetrix.sourceforge.net/ | |
27 | * - look at http://members.inode.at/d.pissarenko/ | |
28 | * | |
29 | *****************************************************************************/ | |
30 | package net.sourceforge.demetrix.model; | |
31 | import java.util.Enumeration; | |
32 | import java.util.Iterator; | |
33 | import org._3pq.jgrapht.Graph; | |
34 | import net.sourceforge.demetrix.properties.DemetrixPropertiesHolder; | |
35 | import net.sourceforge.demetrix.properties.DemetrixPropertiesStorage; | |
36 | import net.sourceforge.demetrix.properties.DemetrixProperty; | |
37 | import net.sourceforge.demetrix.properties.StringProperty; | |
38 | /** | |
39 | * @author Dimitri Pissarenko | |
40 | * | |
41 | */ | |
42 | public class Resource implements ProcessChainNode, DemetrixPropertiesHolder { | |
43 | private Graph subGraph; | |
44 | private DemetrixPropertiesStorage properties; | |
45 | 32 | public Resource() { |
46 | 32 | StringProperty nameProperty = null; |
47 | 32 | properties = new DemetrixPropertiesStorage(); |
48 | 32 | nameProperty = new StringProperty(); |
49 | 32 | nameProperty.setName("name"); |
50 | 32 | nameProperty.setValue("resource"); |
51 | 32 | this.addProperty(nameProperty); |
52 | 32 | } |
53 | /* (non-Javadoc) | |
54 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#addProperty(net.sourceforge.demetrix.properties.DemetrixProperty) | |
55 | */ | |
56 | public void addProperty(DemetrixProperty property) { | |
57 | 29 | this.properties.addProperty(property); |
58 | 29 | } |
59 | /* (non-Javadoc) | |
60 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#getAllProperties() | |
61 | */ | |
62 | public Iterator getAllProperties() { | |
63 | 4 | return this.properties.getAllProperties(); |
64 | } | |
65 | /* (non-Javadoc) | |
66 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#getProperty(java.lang.String) | |
67 | */ | |
68 | public DemetrixProperty getProperty(String name) { | |
69 | 62 | return this.properties.getProperty(name); |
70 | } | |
71 | /* (non-Javadoc) | |
72 | * @see java.lang.Object#toString() | |
73 | */ | |
74 | public String toString() { | |
75 | 9 | StringProperty nameProperty = null; |
76 | 9 | nameProperty = (StringProperty) this.getProperty("name"); |
77 | 9 | if (nameProperty != null) { |
78 | 9 | return (String) nameProperty.getValue(); |
79 | } else { | |
80 | 0 | return ""; |
81 | } | |
82 | } | |
83 | /* (non-Javadoc) | |
84 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#getAllPropertyNames() | |
85 | */ | |
86 | public Enumeration getAllPropertyNames() { | |
87 | 0 | return this.properties.getAllPropertyNames(); |
88 | } | |
89 | /* (non-Javadoc) | |
90 | * @see java.lang.Object#equals(java.lang.Object) | |
91 | */ | |
92 | public boolean equals(Object anotherObject) { | |
93 | 90 | DemetrixPropertiesHolder demetrixPropertiesHolder = null; |
94 | 90 | if (anotherObject == null) { |
95 | 1 | return false; |
96 | } | |
97 | 89 | if (anotherObject instanceof DemetrixPropertiesHolder) { |
98 | 88 | demetrixPropertiesHolder = (DemetrixPropertiesHolder) anotherObject; |
99 | ||
100 | 88 | return this.getPropertiesStorage().equals( |
101 | demetrixPropertiesHolder.getPropertiesStorage()); | |
102 | } else { | |
103 | 1 | return false; |
104 | } | |
105 | } | |
106 | /* (non-Javadoc) | |
107 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#getPropertiesStorage() | |
108 | */ | |
109 | public DemetrixPropertiesHolder getPropertiesStorage() { | |
110 | 192 | return this.properties; |
111 | } | |
112 | /* (non-Javadoc) | |
113 | * @see net.sourceforge.demetrix.model.ProcessChainNode#getSubGraph() | |
114 | */ | |
115 | public Graph getSubGraph() { | |
116 | 0 | return this.subGraph; |
117 | } | |
118 | /* (non-Javadoc) | |
119 | * @see net.sourceforge.demetrix.model.ProcessChainNode#setSubGraph(org._3pq.jgrapht.graph.Subgraph) | |
120 | */ | |
121 | public void setSubGraph(Graph subGraph) { | |
122 | 1 | this.subGraph = subGraph; |
123 | 1 | } |
124 | ||
125 | /* (non-Javadoc) | |
126 | * @see java.lang.Object#hashCode() | |
127 | */ | |
128 | public int hashCode() { | |
129 | 150 | int hashCode=0; |
130 | 150 | if (this.subGraph!=null) |
131 | { | |
132 | 0 | hashCode+=this.subGraph.hashCode(); |
133 | } | |
134 | 150 | hashCode+=this.properties.hashCode(); |
135 | 150 | return hashCode; |
136 | } | |
137 | ||
138 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |