File: JGraphBusinessObject.java

package info (click to toggle)
libjgraph-java 5.12.4.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 7,880 kB
  • ctags: 7,320
  • sloc: java: 20,619; xml: 123; sh: 48; makefile: 6
file content (102 lines) | stat: -rw-r--r-- 2,047 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * $Id: JGraphBusinessObject.java,v 1.2 2005/08/09 08:40:47 david Exp $
 * 
 * Copyright (c) 2001-2005, Gaudenz Alder
 * 
 * See LICENSE file in distribution for licensing details of this source file
 */
package com.jgraph.example.adapter;

import java.io.Serializable;
import java.util.Hashtable;
import java.util.Map;

/**
 * @author Gaudenz Alder
 * 
 * An object that represents an entity with an arbitrary set of properties.
 */
public class JGraphBusinessObject implements Cloneable, Serializable {

	protected Map properties = new Hashtable();

	protected String valueKey = "value";

	public JGraphBusinessObject() {
		this("");
	}

	public JGraphBusinessObject(Object userObject) {
		setValue(userObject);
	}

	/**
	 * @return Returns the properties.
	 */
	public Map getProperties() {
		return properties;
	}

	/**
	 * @param properties
	 *            The properties to set.
	 */
	public void setProperties(Map properties) {
		this.properties = properties;
	}

	public void setValue(Object value) {
		putProperty(valueKey, value);
	}

	public Object getValue() {
		return getProperty(valueKey);
	}

	/**
	 * @return Returns the labelKey.
	 */
	public String getValueKey() {
		return valueKey;
	}

	/**
	 * @param valueKey
	 *            The labelKey to set.
	 */
	public void setValueKey(String valueKey) {
		this.valueKey = valueKey;
	}

	public Object putProperty(Object key, Object value) {
		if (key != null && value != null)
			return properties.put(key, value);
		return null;
	}

	public Object getProperty(Object key) {
		if (key != null)
			return properties.get(key);
		return null;
	}

	public String toString() {
		Object value = getValue();
		if (value != null)
			return String.valueOf(value);
		return "";
	}

	public Object clone() {
		JGraphBusinessObject clone;
		try {
			clone = (JGraphBusinessObject) super.clone();
		} catch (CloneNotSupportedException e) {
			clone = new JGraphBusinessObject();
		}
		clone.setProperties(new Hashtable(getProperties()));
		clone.setValueKey(getValueKey());
		return clone;
	}

}