Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6c365d2410f6cc628c0b567a3ee187a6be57f1ca (plain) (blame)
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
103
/*******************************************************************************
 * Copyright (c) 2007 Composent, Inc. and others. All rights reserved. This
 * program and the accompanying materials are made available under the terms of
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: Composent, Inc. - initial API and implementation
 ******************************************************************************/
package org.eclipse.ecf.discovery;

import java.util.Enumeration;
import java.util.Properties;

/**
 * Service properties implementation class for {@link IServiceProperties}.  Subclasses
 * may be created as appropriate.
 */
public class ServiceProperties implements IServiceProperties {

	private final Properties props;

	public ServiceProperties() {
		super();
		props = new Properties();
	}

	public ServiceProperties(Properties props) {
		super();
		this.props = (props == null) ? new Properties() : props;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.discovery.IServiceProperties#getPropertyNames()
	 */
	public Enumeration getPropertyNames() {
		return props.keys();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.discovery.IServiceProperties#getPropertyString(java.lang.String)
	 */
	public String getPropertyString(String name) {
		final Object val = props.get(name);
		if (val instanceof String) {
			return (String) val;
		}
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.discovery.IServiceProperties#getPropertyBytes(java.lang.String)
	 */
	public byte[] getPropertyBytes(String name) {
		final Object val = props.get(name);
		if (val instanceof byte[]) {
			return (byte[]) val;
		}
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.discovery.IServiceProperties#getProperty(java.lang.String)
	 */
	public Object getProperty(String name) {
		return props.get(name);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ecf.discovery.IServiceProperties#setProperty(java.lang.String, java.lang.Object)
	 */
	public Object setProperty(String name, Object value) {
		return props.put(name, value);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ecf.discovery.IServiceProperties#setPropertyBytes(java.lang.String, byte[])
	 */
	public Object setPropertyBytes(String name, byte[] value) {
		return props.put(name, value);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ecf.discovery.IServiceProperties#setPropertyString(java.lang.String, java.lang.String)
	 */
	public Object setPropertyString(String name, String value) {
		return props.put(name, value);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ecf.discovery.IServiceProperties#asProperties()
	 */
	public Properties asProperties() {
		return new Properties(props);
	}
}

Back to the top