Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

DataItem.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2005 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: openmobileis@e-care.fr
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  Author : Philippe Delrieu
00023  * 
00024  */
00025 
00026 package org.openmobileis.synchro.openmsp.protocol;
00027 
00036 public class DataItem  extends Item implements Element {
00041   final static long serialVersionUID = 1L;
00042 
00043 
00044   protected String meta;
00045   protected String data;
00046 
00047   public DataItem(int itemType, String meta, String data, String source, String target) {
00048     super(itemType, source, target);
00049     this.data = data;
00050     this.meta = meta;
00051   }
00052 
00053   protected DataItem (int itemType) {
00054      super(itemType);
00055   }
00056 
00057 
00058   public String getMetaInformation() {
00059     return meta;
00060     }
00061 
00062   public String getData() {
00063     return data;
00064     }
00065 
00066   public String toString() {
00067     return super.toString() +  " meta : " + meta + " data : " + data;
00068   }
00069 
00070   public void setMetaInformation(String meta) {
00071     this.meta = meta;
00072   }
00073 
00074   public void setData(String data) {
00075     this.data = data;
00076   }
00077 
00078 
00079  public void writeContent(StringBuffer buffer) {
00080      super.writeContent(buffer);
00081      if (meta != null) {
00082         MessageFactory.writeElement(buffer, MessageFactory.TAG_META, meta);
00083         buffer.append("\n");
00084      }
00085      if (data != null) {
00086         String toDisplay;
00087         if ( (data.indexOf("<xml>")) != -1)
00088           toDisplay = "<![CDATA[" + data + "]]>";
00089         else
00090           toDisplay = data;
00091         MessageFactory.writeElement(buffer, MessageFactory.TAG_DATA, toDisplay);
00092         buffer.append("\n");
00093      }
00094   }
00095 
00096 
00097 }

Generated on Wed Dec 14 21:05:32 2005 for OpenMobileIS by  doxygen 1.4.4