001: /*
002: * This file is part of the WfMOpen project.
003: * Copyright (C) 2001-2005 Danet GmbH (www.danet.de), BU BTS.
004: * All rights reserved.
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * $Id: ContextChangeWrapper.java,v 1.3 2006/10/06 21:54:09 mlipp Exp $
021: *
022: * $Log: ContextChangeWrapper.java,v $
023: * Revision 1.3 2006/10/06 21:54:09 mlipp
024: * Added XML data display.
025: *
026: * Revision 1.2 2006/09/29 12:32:11 drmlipp
027: * Consistently using WfMOpen as projct name now.
028: *
029: * Revision 1.1 2005/10/24 15:30:49 drmlipp
030: * Implemented context data change display.
031: *
032: */
033: package de.danet.an.workflow.clients.mgmtportlets.process;
034:
035: import java.io.Serializable;
036:
037: import de.danet.an.workflow.api.SAXEventBuffer;
038:
039: /**
040: * @author lipp
041: *
042: */
043: public class ContextChangeWrapper implements Serializable {
044:
045: private String itemName;
046: private Object oldValue;
047: private Object newValue;
048: private transient String oldValueStringCache = null;
049: private transient String newValueStringCache = null;
050:
051: /**
052: * @param itemName
053: * @param oldValue
054: * @param newValue
055: */
056: public ContextChangeWrapper(String itemName, Object oldValue,
057: Object newValue) {
058: this .itemName = itemName;
059: this .oldValue = oldValue;
060: this .newValue = newValue;
061: }
062:
063: /**
064: * @return Returns the itemName.
065: */
066: public String getItemName() {
067: return itemName;
068: }
069:
070: /**
071: * Is old value XML?
072: */
073: public boolean isOldValueXML() {
074: return oldValue != null && (oldValue instanceof SAXEventBuffer);
075: }
076:
077: /**
078: * @return Returns the oldValue.
079: */
080: public String getOldValue() {
081: if (oldValueStringCache == null) {
082: if (oldValue != null) {
083: oldValueStringCache = oldValue.toString();
084: }
085: }
086: return oldValueStringCache;
087: }
088:
089: /**
090: * Get the start of the oldValue
091: */
092: public String getOldValueShort() {
093: if (getOldValue() == null) {
094: return null;
095: }
096: if (getOldValue().length() <= 30) {
097: return getOldValue();
098: } else {
099: return getOldValue().substring(0, 27) + "...";
100: }
101: }
102:
103: /**
104: * Is new value XML?
105: */
106: public boolean isNewValueXML() {
107: return newValue != null && (newValue instanceof SAXEventBuffer);
108: }
109:
110: /**
111: * @return Returns the newValue.
112: */
113: public String getNewValue() {
114: if (newValueStringCache == null) {
115: if (newValue != null) {
116: newValueStringCache = newValue.toString();
117: }
118: }
119: return newValueStringCache;
120: }
121:
122: /**
123: * Get the start of the newValue
124: */
125: public String getNewValueShort() {
126: if (getNewValue() == null) {
127: return null;
128: }
129: if (getNewValue().length() <= 30) {
130: return getNewValue();
131: } else {
132: return getNewValue().substring(0, 27) + "...";
133: }
134: }
135:
136: }
|