connectivity/com.nokia.tcf/src/com/nokia/tcf/impl/TCBaseConnection.java
changeset 60 9d2210c8eed2
parent 2 d760517a8095
equal deleted inserted replaced
59:c892c53c664e 60:9d2210c8eed2
    26 import com.nokia.tcf.api.ITCConnection;
    26 import com.nokia.tcf.api.ITCConnection;
    27 import com.nokia.tcf.api.TCErrorConstants;
    27 import com.nokia.tcf.api.TCErrorConstants;
    28 
    28 
    29 public abstract class TCBaseConnection implements ITCConnection {
    29 public abstract class TCBaseConnection implements ITCConnection {
    30 
    30 
    31 	private int connectionType;
    31 	private String connectionType;
    32 	private long retryInterval;
    32 	private long retryInterval;
    33 	private long retryTimeout;
    33 	private long retryTimeout;
    34 	protected String decodeFormat;
    34 	protected String decodeFormat;
    35 	/**
    35 	/**
    36 	 * @param connectionType
    36 	 * @param connectionType
    37 	 * @param retryInterval
    37 	 * @param retryInterval
    38 	 * @param retryTimeout
    38 	 * @param retryTimeout
    39 	 * @param decodeFormat
    39 	 * @param decodeFormat
    40 	 */
    40 	 */
    41 	public TCBaseConnection(int connectionType, long retryInterval,
    41 	public TCBaseConnection(String connectionType, long retryInterval,
    42 			long retryTimeout, String decodeFormat) {
    42 			long retryTimeout, String decodeFormat) {
    43 		super();
    43 		super();
    44 		this.connectionType = connectionType;
    44 		this.connectionType = connectionType.toLowerCase();
    45 		this.retryInterval = retryInterval;
    45 		this.retryInterval = retryInterval;
    46 		this.retryTimeout = retryTimeout;
    46 		this.retryTimeout = retryTimeout;
    47 		this.decodeFormat = decodeFormat;
    47 		this.decodeFormat = decodeFormat;
    48 	}
    48 	}
    49 
    49 
    50 	/**
    50 	/**
    51 	 * @param connectionType
    51 	 * @param connectionType
    52 	 */
    52 	 */
    53 	public TCBaseConnection(int connectionType) {
    53 	public TCBaseConnection(String connectionType) {
    54 		super();
    54 		super();
    55 		this.connectionType = connectionType;
    55 		this.connectionType = connectionType.toLowerCase();
    56 		this.retryInterval = DEFAULT_COMM_ERROR_RETRY_INTERVAL;
    56 		this.retryInterval = DEFAULT_COMM_ERROR_RETRY_INTERVAL;
    57 		this.retryTimeout = DEFAULT_COMM_ERROR_RETRY_TIMEOUT;
    57 		this.retryTimeout = DEFAULT_COMM_ERROR_RETRY_TIMEOUT;
    58 		this.decodeFormat = "ost";
    58 		this.decodeFormat = "ost";
    59 	}
    59 	}
    60 
    60 
    61 	/**
    61 	/**
    62 	 * @param connectionType
    62 	 * @param connectionType
    63 	 * @param retryInterval
    63 	 * @param retryInterval
    64 	 * @param retryTimeout
    64 	 * @param retryTimeout
    65 	 */
    65 	 */
    66 	public TCBaseConnection(int connectionType, long retryInterval,
    66 	public TCBaseConnection(String connectionType, long retryInterval,
    67 			long retryTimeout) {
    67 			long retryTimeout) {
    68 		super();
    68 		super();
    69 		this.connectionType = connectionType;
    69 		this.connectionType = connectionType.toLowerCase();
    70 		this.retryInterval = retryInterval;
    70 		this.retryInterval = retryInterval;
    71 		this.retryTimeout = retryTimeout;
    71 		this.retryTimeout = retryTimeout;
    72 		this.decodeFormat = "ost";
    72 		this.decodeFormat = "ost";
    73 	}
    73 	}
    74 
    74 
    78 	public abstract String getConnectionDescription();
    78 	public abstract String getConnectionDescription();
    79 	
    79 	
    80 	/* (non-Javadoc)
    80 	/* (non-Javadoc)
    81 	 * @see com.nokia.tcf.api.ITCConnection#getConnectionType()
    81 	 * @see com.nokia.tcf.api.ITCConnection#getConnectionType()
    82 	 */
    82 	 */
    83 	public int getConnectionType() {
    83 	public String getConnectionType() {
    84 		return this.connectionType;
    84 		return this.connectionType;
    85 	}
    85 	}
    86 
    86 
    87 	/* (non-Javadoc)
    87 	/* (non-Javadoc)
    88 	 * @see com.nokia.tcf.api.ITCConnection#getRetryInterval()
    88 	 * @see com.nokia.tcf.api.ITCConnection#getRetryInterval()
    99 	}
    99 	}
   100 
   100 
   101 	/* (non-Javadoc)
   101 	/* (non-Javadoc)
   102 	 * @see com.nokia.tcf.api.ITCConnection#setConnectionType(int)
   102 	 * @see com.nokia.tcf.api.ITCConnection#setConnectionType(int)
   103 	 */
   103 	 */
   104 	public IStatus setConnectionType(int inConnectionType) {
   104 	public IStatus setConnectionType(String inConnectionType) {
   105 		IStatus status = new Status(Status.OK, Activator.PLUGIN_ID, (int)TCErrorConstants.TCAPI_ERR_NONE, "OK", null);
   105 		IStatus status = new Status(Status.OK, Activator.PLUGIN_ID, (int)TCErrorConstants.TCAPI_ERR_NONE, "OK", null);
   106 		connectionType = inConnectionType;
   106 		connectionType = inConnectionType.toLowerCase();
   107 		return status;
   107 		return status;
   108 	}
   108 	}
   109 
   109 
   110 	/* (non-Javadoc)
   110 	/* (non-Javadoc)
   111 	 * @see com.nokia.tcf.api.ITCConnection#setRetryInterval(long)
   111 	 * @see com.nokia.tcf.api.ITCConnection#setRetryInterval(long)
   143 	/* (non-Javadoc)
   143 	/* (non-Javadoc)
   144 	 * @see com.nokia.tcf.api.ITCConnection#setDecodeFormat(long)
   144 	 * @see com.nokia.tcf.api.ITCConnection#setDecodeFormat(long)
   145 	 */
   145 	 */
   146 	public IStatus setDecodeFormat(String inDecodeFormat) {
   146 	public IStatus setDecodeFormat(String inDecodeFormat) {
   147 		IStatus status = new Status(Status.OK, Activator.PLUGIN_ID, (int)TCErrorConstants.TCAPI_ERR_NONE, "OK", null);
   147 		IStatus status = new Status(Status.OK, Activator.PLUGIN_ID, (int)TCErrorConstants.TCAPI_ERR_NONE, "OK", null);
   148 		if ((inDecodeFormat.compareToIgnoreCase("platsim") == 0) ||
   148 		decodeFormat = inDecodeFormat;
   149 				(inDecodeFormat.compareToIgnoreCase("ost") == 0) ||
       
   150 				(inDecodeFormat.compareToIgnoreCase("rawtrk") == 0)) {
       
   151 			decodeFormat = inDecodeFormat;
       
   152 		} else {
       
   153 			status  = new Status(Status.ERROR, Activator.PLUGIN_ID, (int)TCErrorConstants.TCAPI_ERR_INVALID_DECODE_FORMAT, "Error", null);
       
   154 			decodeFormat = "ost";
       
   155 		}
       
   156 		return status;
   149 		return status;
   157 	}
   150 	}
   158 
   151 
   159 }
   152 }