connectivity/com.nokia.tcf/src/com/nokia/tcf/impl/TCBaseConnection.java
changeset 0 fb279309251b
child 60 9d2210c8eed2
equal deleted inserted replaced
-1:000000000000 0:fb279309251b
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 /**
       
    18  * 
       
    19  */
       
    20 package com.nokia.tcf.impl;
       
    21 
       
    22 import org.eclipse.core.runtime.IStatus;
       
    23 import org.eclipse.core.runtime.Status;
       
    24 
       
    25 import com.nokia.tcf.Activator;
       
    26 import com.nokia.tcf.api.ITCConnection;
       
    27 import com.nokia.tcf.api.TCErrorConstants;
       
    28 
       
    29 public abstract class TCBaseConnection implements ITCConnection {
       
    30 
       
    31 	private int connectionType;
       
    32 	private long retryInterval;
       
    33 	private long retryTimeout;
       
    34 	protected String decodeFormat;
       
    35 	/**
       
    36 	 * @param connectionType
       
    37 	 * @param retryInterval
       
    38 	 * @param retryTimeout
       
    39 	 * @param decodeFormat
       
    40 	 */
       
    41 	public TCBaseConnection(int connectionType, long retryInterval,
       
    42 			long retryTimeout, String decodeFormat) {
       
    43 		super();
       
    44 		this.connectionType = connectionType;
       
    45 		this.retryInterval = retryInterval;
       
    46 		this.retryTimeout = retryTimeout;
       
    47 		this.decodeFormat = decodeFormat;
       
    48 	}
       
    49 
       
    50 	/**
       
    51 	 * @param connectionType
       
    52 	 */
       
    53 	public TCBaseConnection(int connectionType) {
       
    54 		super();
       
    55 		this.connectionType = connectionType;
       
    56 		this.retryInterval = DEFAULT_COMM_ERROR_RETRY_INTERVAL;
       
    57 		this.retryTimeout = DEFAULT_COMM_ERROR_RETRY_TIMEOUT;
       
    58 		this.decodeFormat = "ost";
       
    59 	}
       
    60 
       
    61 	/**
       
    62 	 * @param connectionType
       
    63 	 * @param retryInterval
       
    64 	 * @param retryTimeout
       
    65 	 */
       
    66 	public TCBaseConnection(int connectionType, long retryInterval,
       
    67 			long retryTimeout) {
       
    68 		super();
       
    69 		this.connectionType = connectionType;
       
    70 		this.retryInterval = retryInterval;
       
    71 		this.retryTimeout = retryTimeout;
       
    72 		this.decodeFormat = "ost";
       
    73 	}
       
    74 
       
    75 	/* (non-Javadoc)
       
    76 	 * @see com.nokia.tcf.api.ITCConnection#getConnectionString()
       
    77 	 */
       
    78 	public abstract String getConnectionDescription();
       
    79 	
       
    80 	/* (non-Javadoc)
       
    81 	 * @see com.nokia.tcf.api.ITCConnection#getConnectionType()
       
    82 	 */
       
    83 	public int getConnectionType() {
       
    84 		return this.connectionType;
       
    85 	}
       
    86 
       
    87 	/* (non-Javadoc)
       
    88 	 * @see com.nokia.tcf.api.ITCConnection#getRetryInterval()
       
    89 	 */
       
    90 	public long getRetryInterval() {
       
    91 		return this.retryInterval;
       
    92 	}
       
    93 
       
    94 	/* (non-Javadoc)
       
    95 	 * @see com.nokia.tcf.api.ITCConnection#getRetryTimeout()
       
    96 	 */
       
    97 	public long getRetryTimeout() {
       
    98 		return this.retryTimeout;
       
    99 	}
       
   100 
       
   101 	/* (non-Javadoc)
       
   102 	 * @see com.nokia.tcf.api.ITCConnection#setConnectionType(int)
       
   103 	 */
       
   104 	public IStatus setConnectionType(int inConnectionType) {
       
   105 		IStatus status = new Status(Status.OK, Activator.PLUGIN_ID, (int)TCErrorConstants.TCAPI_ERR_NONE, "OK", null);
       
   106 		connectionType = inConnectionType;
       
   107 		return status;
       
   108 	}
       
   109 
       
   110 	/* (non-Javadoc)
       
   111 	 * @see com.nokia.tcf.api.ITCConnection#setRetryInterval(long)
       
   112 	 */
       
   113 	public IStatus setRetryInterval(long inRetryInterval) {
       
   114 		IStatus status = new Status(Status.OK, Activator.PLUGIN_ID, (int)TCErrorConstants.TCAPI_ERR_NONE, "OK", null);
       
   115 		if (inRetryInterval <= 0) {
       
   116 			this.retryInterval = ITCConnection.DEFAULT_COMM_ERROR_RETRY_INTERVAL;
       
   117 		} else {
       
   118 			this.retryInterval = inRetryInterval;
       
   119 		}
       
   120 		return status;
       
   121 	}
       
   122 
       
   123 	/* (non-Javadoc)
       
   124 	 * @see com.nokia.tcf.api.ITCConnection#setRetryTimeout(long)
       
   125 	 */
       
   126 	public IStatus setRetryTimeout(long inRetryTimeout) {
       
   127 		IStatus status = new Status(Status.OK, Activator.PLUGIN_ID, (int)TCErrorConstants.TCAPI_ERR_NONE, "OK", null);
       
   128 		if (inRetryTimeout <= 0) {
       
   129 			this.retryTimeout = ITCConnection.DEFAULT_COMM_ERROR_RETRY_TIMEOUT;
       
   130 		} else {
       
   131 			this.retryTimeout = inRetryTimeout;
       
   132 		}
       
   133 		return status;
       
   134 	}
       
   135 
       
   136 	/* (non-Javadoc)
       
   137 	 * @see com.nokia.tcf.api.ITCConnection#getDecodeFormat()
       
   138 	 */
       
   139 	public String getDecodeFormat() {
       
   140 		return this.decodeFormat;
       
   141 	}
       
   142 
       
   143 	/* (non-Javadoc)
       
   144 	 * @see com.nokia.tcf.api.ITCConnection#setDecodeFormat(long)
       
   145 	 */
       
   146 	public IStatus setDecodeFormat(String inDecodeFormat) {
       
   147 		IStatus status = new Status(Status.OK, Activator.PLUGIN_ID, (int)TCErrorConstants.TCAPI_ERR_NONE, "OK", null);
       
   148 		if ((inDecodeFormat.compareToIgnoreCase("platsim") == 0) ||
       
   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;
       
   157 	}
       
   158 
       
   159 }