001: /*
002: * Copyright (c) 2003-2007 JGoodies Karsten Lentzsch. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of JGoodies Karsten Lentzsch nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030:
031: package com.jgoodies.validation.tutorial.performance;
032:
033: import com.jgoodies.binding.beans.Model;
034:
035: /**
036: * Describes a container with container number and label.
037: * Provides the following bound properties:
038: * <em>containerNo, label</em>.
039: *
040: * @author Karsten Lentzsch
041: * @version $Revision: 1.4 $
042: */
043: public class Container extends Model {
044:
045: // Names of the Bound Bean Properties *************************************
046:
047: public static final String PROPERTYNAME_CONTAINER_NO = "containerNo";
048: public static final String PROPERTYNAME_LABEL = "label";
049:
050: // Instance Fields ********************************************************
051:
052: /**
053: * Holds a number that identifies the container.
054: *
055: * @see #getContainerNo()
056: * @see #setContainerNo(String)
057: *
058: * validation-constraints:
059: * mandatory
060: * min-length: 5
061: * max-length: 5
062: * numeric
063: */
064: private String containerNo;
065:
066: /**
067: * Holds this container's label.
068: *
069: * @see #getLabel()
070: */
071: private String label;
072:
073: // Instance Creation ******************************************************
074:
075: /**
076: * Constructs an empty <code>Container</code>.
077: */
078: public Container() {
079: containerNo = "";
080: label = "";
081: }
082:
083: // Access to Bound Properties *********************************************
084:
085: /**
086: * Returns this container's unique id.
087: *
088: * @return this container's no, a system wide unique id
089: *
090: * @see #setContainerNo(String)
091: */
092: public String getContainerNo() {
093: return containerNo;
094: }
095:
096: /**
097: * Sets a new unique container number.
098: *
099: * @param newContainerNo the container number to be set
100: *
101: * @see #getContainerNo()
102: */
103: public void setContainerNo(String newContainerNo) {
104: String oldValue = getContainerNo();
105: containerNo = newContainerNo;
106: firePropertyChange(PROPERTYNAME_CONTAINER_NO, oldValue,
107: newContainerNo);
108: }
109:
110: /**
111: * Returns this container's label.
112: *
113: * @return the container date
114: *
115: * @see #setLabel(String)
116: */
117: public String getLabel() {
118: return label;
119: }
120:
121: /**
122: * Sets this container's label.
123: *
124: * @param newLabel the label to set
125: *
126: * @see #getLabel()
127: */
128: public void setLabel(String newLabel) {
129: String oldLabel = getLabel();
130: label = newLabel;
131: firePropertyChange(PROPERTYNAME_LABEL, oldLabel, newLabel);
132: }
133:
134: }
|