1 14 15 package org.quickserver.util.xmlreader; 16 17 import org.quickserver.net.server.DataMode; 18 import org.quickserver.net.server.DataType; 19 20 26 public class DefaultDataMode implements java.io.Serializable { 27 private DataMode defaultDataModeIN; 28 private DataMode defaultDataModeOUT; 29 30 public DefaultDataMode() { 31 defaultDataModeIN = DataMode.STRING; 32 defaultDataModeOUT = DataMode.STRING; 33 } 34 35 39 public void setDataModeIn(String dataMode) { 40 if(dataMode.toUpperCase().equals("STRING")) 41 defaultDataModeIN = DataMode.STRING; 42 else if(dataMode.toUpperCase().equals("BYTE")) 43 defaultDataModeIN = DataMode.BYTE; 44 else if(dataMode.toUpperCase().equals("OBJECT")) 45 defaultDataModeIN = DataMode.OBJECT; 46 else if(dataMode.toUpperCase().equals("BINARY")) 47 defaultDataModeIN = DataMode.BINARY; 48 } 49 50 public String getDataModeIn() { 51 return defaultDataModeIN.toString(); 52 } 53 54 58 public void setDataModeOut(String dataMode) { 59 if(dataMode.toUpperCase().equals("STRING")) 60 defaultDataModeOUT = DataMode.STRING; 61 else if(dataMode.toUpperCase().equals("BYTE")) 62 defaultDataModeOUT = DataMode.BYTE; 63 else if(dataMode.toUpperCase().equals("OBJECT")) 64 defaultDataModeOUT = DataMode.OBJECT; 65 else if(dataMode.toUpperCase().equals("BINARY")) 66 defaultDataModeOUT = DataMode.BINARY; 67 } 68 69 public String getDataModeOut() { 70 return defaultDataModeOUT.toString(); 71 } 72 73 74 77 public void setDataMode(DataMode dataMode, DataType dataType) { 78 if(dataType==DataType.IN) 79 this.defaultDataModeIN = dataMode; 80 if(dataType==DataType.OUT) 81 this.defaultDataModeOUT = dataMode; 82 } 83 86 public DataMode getDataMode(DataType dataType) { 87 if(dataType==DataType.IN) 88 return defaultDataModeIN; 89 if(dataType==DataType.OUT) 90 return defaultDataModeOUT; 91 else 92 throw new IllegalArgumentException ("Unknown DataType: "+dataType); 93 } 94 95 98 public String toXML(String pad) { 99 if(pad==null) pad=""; 100 StringBuffer sb = new StringBuffer (); 101 sb.append(pad+"<default-data-mode>\n"); 102 sb.append(pad+"\t<data-type-in>"+getDataModeIn()+"</data-type-in>\n"); 103 sb.append(pad+"\t<data-type-out>"+getDataModeOut()+"</data-type-out>\n"); 104 sb.append(pad+"</default-data-mode>\n"); 105 return sb.toString(); 106 } 107 } | Popular Tags |