View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: AttributeValueContainer.java
13   * Created: 2007-00-00
14   * Author: awos
15   * $Id: AttributeValueContainer.java 2770 2009-04-21 19:17:34Z kpietak $
16   */
17  
18  package pl.edu.agh.cast.model.visual.backward;
19  
20  import java.util.List;
21  
22  import pl.edu.agh.cast.model.attributes.AttributeManager;
23  import pl.edu.agh.cast.model.attributes.AttributeMergePolicy;
24  import pl.edu.agh.cast.model.attributes.AttributeValue;
25  
26  /**
27   * An interface to be implemented by elements containing attributes.
28   *
29   * @author AGH CAST Team
30   */
31  public interface AttributeValueContainer {
32  
33  	/**
34  	 * Returns the value of the attribute named <code>name</code>.
35  	 *
36  	 * @param name
37  	 *            name of the attribute
38  	 * @return an {@link AttributeValue} instance for the given attribute
39  	 */
40  	public AttributeValue getAttributeValue(String name);
41  
42  	/**
43  	 * Sets a new attribute value, fires change event.
44  	 *
45  	 * @param name
46  	 *            name of the attribute to change
47  	 * @param newValue
48  	 *            new value of the attribute
49  	 * @throws UnsupportedOperationException
50  	 *             if attribute is not editable
51  	 */
52  	public void setAttributeValue(String name, Object newValue);
53  
54  	/**
55  	 * Sets a new attribute value according to given {@link AttributeMergePolicy}, fires change event.
56  	 *
57  	 * If <code>policy</code> is <code>null</code> then acts the same as {@link #setAttributeValue(String, Object)}.
58  	 *
59  	 * @param name
60  	 *            name of the attribute to change
61  	 * @param newValue
62  	 *            new value of the attribute
63  	 * @param policy
64  	 *            merge policy
65  	 * @throws UnsupportedOperationException
66  	 *             if attribute is not editable
67  	 */
68  	public void setAttributeValue(String name, Object newValue, AttributeMergePolicy policy);
69  
70  	/**
71  	 * Checks if given attribute is editable.
72  	 *
73  	 * @param name
74  	 *            name of the attribute
75  	 * @return editable flag
76  	 */
77  	public boolean isAttributeEditable(String name);
78  
79  	/**
80  	 * Returns complete list of attribute values in this container.
81  	 *
82  	 * Takes into consideration that registered properties may have changed in the manager, i.e. some values may be
83  	 * obsolete.
84  	 *
85  	 * @return list of all contained {@link AttributeValue}s
86  	 */
87  	public List<AttributeValue> getAllValues();
88  
89  	/**
90  	 * Removes attribute value from this container.
91  	 *
92  	 * @param name
93  	 *            name of attribute to remove
94  	 * @return removed {@link AttributeValue}, or null if this attribute's value was not set (see
95  	 *         {@link java.util.Collection#remove(Object)})
96  	 */
97  	public AttributeValue removePropertyValue(String name);
98  
99  	/**
100 	 * Returns attribute manager for this container.
101 	 *
102 	 * @return attribute manager for this container
103 	 */
104 	public AttributeManager getAttributeManager();
105 
106 }