001: package org.emforge.xfer;
002:
003: import javax.xml.bind.annotation.XmlTransient;
004:
005: /** Transfer Object for Variable
006: * Stored variable name and value, as well as set of additional flags
007: */
008: public class VariableTO {
009: public static final String[] LINK_PREFIXES = { "http://",
010: "https://", "mailto:", "ftp://", "file://", "notes://" };
011:
012: private String label;
013: private String displayLabel;
014: private String value;
015: private String displayValue;
016:
017: private SelectValueTO[] selectValues;
018:
019: /// flags
020: private boolean readable;
021: private boolean required;
022: private boolean writable;
023:
024: /** Default empty contructor */
025: public VariableTO() {
026:
027: }
028:
029: /** Label of Variable */
030: public String getLabel() {
031: return label;
032: }
033:
034: public void setLabel(String i_label) {
035: label = i_label;
036: }
037:
038: /** How label should be displayed to user */
039: public String getDisplayLabel() {
040: return displayLabel;
041: }
042:
043: public void setDisplayLabel(String i_displayLabel) {
044: displayLabel = i_displayLabel;
045: }
046:
047: /** Value of variable */
048: public String getValue() {
049: return value;
050: }
051:
052: public void setValue(String i_value) {
053: value = i_value;
054: }
055:
056: /** Display Value how Variable should be displayed to User */
057: public String getDisplayValue() {
058: return displayValue;
059: }
060:
061: public void setDisplayValue(String i_displayValue) {
062: displayValue = i_displayValue;
063: }
064:
065: /** returns possible select values for variable */
066: public SelectValueTO[] getSelectValues() {
067: return selectValues;
068: }
069:
070: public void setSelectValues(SelectValueTO[] i_selectValues) {
071: selectValues = i_selectValues;
072: }
073:
074: /** Is this variable should be displayed? */
075: public boolean isReadable() {
076: return readable;
077: }
078:
079: public void setReadable(boolean i_readable) {
080: readable = i_readable;
081: }
082:
083: /** Is it required variable? */
084: public boolean isRequired() {
085: return required;
086: }
087:
088: public void setRequired(boolean i_required) {
089: required = i_required;
090: }
091:
092: /** Is it writable variable? */
093: public boolean isWritable() {
094: return writable;
095: }
096:
097: public void setWritable(boolean i_writable) {
098: writable = i_writable;
099: }
100:
101: /** Is Varialbe Read-Only? */
102: @XmlTransient
103: public boolean isReadOnly() {
104: return !writable;
105: }
106:
107: /** Is variable contains link
108: *
109: * @todo think - probabl we should move it into GUI level - not here
110: * @return true if value of variable may be represented as link
111: */
112: @XmlTransient
113: public boolean isLink() {
114: for (String prefix : LINK_PREFIXES) {
115: if (value != null && value.startsWith(prefix)) {
116: return true;
117: }
118: }
119:
120: return false;
121: }
122: }
|