001: /*
002: * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003: * Copyright (C) 2002-2005 NextApp, Inc.
004: *
005: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006: *
007: * The contents of this file are subject to the Mozilla Public License Version
008: * 1.1 (the "License"); you may not use this file except in compliance with
009: * the License. You may obtain a copy of the License at
010: * http://www.mozilla.org/MPL/
011: *
012: * Software distributed under the License is distributed on an "AS IS" basis,
013: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014: * for the specific language governing rights and limitations under the
015: * License.
016: *
017: * Alternatively, the contents of this file may be used under the terms of
018: * either the GNU General Public License Version 2 or later (the "GPL"), or
019: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020: * in which case the provisions of the GPL or the LGPL are applicable instead
021: * of those above. If you wish to allow use of your version of this file only
022: * under the terms of either the GPL or the LGPL, and not to allow others to
023: * use your version of this file under the terms of the MPL, indicate your
024: * decision by deleting the provisions above and replace them with the notice
025: * and other provisions required by the GPL or the LGPL. If you do not delete
026: * the provisions above, a recipient may use your version of this file under
027: * the terms of any one of the MPL, the GPL or the LGPL.
028: */
029:
030: package nextapp.echo2.app.update;
031:
032: import java.io.Serializable;
033: import java.util.Collections;
034: import java.util.HashMap;
035: import java.util.Iterator;
036: import java.util.Map;
037:
038: import nextapp.echo2.app.Component;
039:
040: /**
041: * A representation of all updates made on the client to an individual
042: * component.
043: */
044: public class ClientComponentUpdate implements Serializable {
045:
046: private Component component;
047: private Map inputs;
048:
049: /**
050: * Creates a <code>ClientComponentUpdate</code>.
051: *
052: * @param component the updated component
053: */
054: ClientComponentUpdate(Component component) {
055: super ();
056: this .component = component;
057: inputs = new HashMap();
058: }
059:
060: /**
061: * Adds an input property to the update, describing a single change
062: * to the component's client-side state.
063: *
064: * @param inputName the name of the input property
065: * @param inputValue the new state of the property
066: */
067: public void addInput(String inputName, Object inputValue) {
068: inputs.put(inputName, inputValue);
069: }
070:
071: /**
072: * Returns the updated component.
073: *
074: * @return the component
075: */
076: public Component getComponent() {
077: return component;
078: }
079:
080: /**
081: * Returns an iterator over the names of all input properties.
082: *
083: * @return the <code>Iterator</code>
084: */
085: public Iterator getInputNames() {
086: return Collections.unmodifiableSet(inputs.keySet()).iterator();
087: }
088:
089: /**
090: * Retrieves the new state of the specified input property.
091: *
092: * @param inputName the name of the input property
093: * @return the new state
094: */
095: public Object getInputValue(String inputName) {
096: return inputs.get(inputName);
097: }
098:
099: /**
100: * Determines if an input was posted with the specified property name.
101: *
102: * @param inputName the input property name
103: * @return true if an input is posted
104: */
105: public boolean hasInput(String inputName) {
106: return inputs.containsKey(inputName);
107: }
108: }
|