01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation.
03: * Licensed Material - Property of IBM. All rights reserved.
04: * US Government Users Restricted Rights - Use, duplication or disclosure
05: * restricted by GSA ADP Schedule Contract with IBM Corp.
06: *
07: * Contributors:
08: * IBM Corporation - initial API and implementation
09: *******************************************************************************/package org.eclipse.ui.examples.navigator;
10:
11: import org.eclipse.core.resources.IFile;
12:
13: /**
14: * Provides a simple model of a name=value pair from a *.properties file.
15: *
16: * @since 3.2
17: */
18: public class PropertiesTreeData {
19:
20: private IFile container;
21: private String name;
22: private String value;
23:
24: /**
25: * Create a property with the given name and value contained by the given file.
26: *
27: * @param aName The name of the property.
28: * @param aValue The value of the property.
29: * @param aFile The file that defines this property.
30: */
31: public PropertiesTreeData(String aName, String aValue, IFile aFile) {
32: name = aName;
33: value = aValue;
34: container = aFile;
35: }
36:
37: /**
38: * The name of this property.
39: * @return The name of this property.
40: */
41: public String getName() {
42: return name;
43: }
44:
45: /**
46: * Return the value of the property in the file.
47: * @return The value of the property in the file.
48: */
49: public String getValue() {
50: return value;
51: }
52:
53: /**
54: * The IFile that defines this property.
55: * @return The IFile that defines this property.
56: */
57: public IFile getFile() {
58: return container;
59: }
60:
61: public int hashCode() {
62: return name.hashCode();
63: }
64:
65: public boolean equals(Object obj) {
66: return obj instanceof PropertiesTreeData
67: && ((PropertiesTreeData) obj).getName().equals(name);
68: }
69:
70: public String toString() {
71: StringBuffer toString = new StringBuffer(getName())
72: .append(":").append(getValue()); //$NON-NLS-1$
73: return toString.toString();
74: }
75:
76: }
|