com.skype.tutorial.apptoken
Class AppToken

java.lang.Object
  extended by com.skype.tutorial.apptoken.AppToken

public class AppToken
extends java.lang.Object

Encapsulates the AppToken required to access the SkypeKit runtime.

Since:
1.0
Author:
Andrea Drane (ported/refactored from existing C++ tutorial code)

Field Summary
static java.lang.String APP_TOKEN_FILE_NAME
          Default name of the text file containing the AppToken data string.
static java.lang.String APP_TOKEN_FILE_SUFFIX
          Expected suffix for the file text file containing the AppToken data string (lowercase).
private  java.lang.StringBuffer appTokenData
          Actual AppToken string.
static java.lang.String MY_CLASS_TAG
          Info/Debug console output message prefix/identifier tag.
 
Constructor Summary
AppToken()
           
 
Method Summary
 java.lang.String getAppToken()
          Obtains the AppToken.
 java.lang.String readAppTokenFromFile(java.lang.String pathName)
          Reads an AppToken data string from a file.
 void setAppToken(java.lang.String appTokenStr)
          (Re-)Set the AppToken.
 boolean setAppTokenFromFile(java.lang.String pathName)
          Sets the AppToken data string from a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MY_CLASS_TAG

public static final java.lang.String MY_CLASS_TAG
Info/Debug console output message prefix/identifier tag. Corresponds to class name.

Since:
1.0
See Also:
Constant Field Values

APP_TOKEN_FILE_SUFFIX

public static final java.lang.String APP_TOKEN_FILE_SUFFIX
Expected suffix for the file text file containing the AppToken data string (lowercase). Used by readAppTokenFromFile(String).

Since:
1.0
See Also:
Constant Field Values

APP_TOKEN_FILE_NAME

public static final java.lang.String APP_TOKEN_FILE_NAME
Default name of the text file containing the AppToken data string. Used by readAppTokenFromFile(String).

Since:
1.0
See Also:
Constant Field Values

appTokenData

private java.lang.StringBuffer appTokenData
Actual AppToken string. After requesting and obtaining an
Constructor Detail

AppToken

public AppToken()
Method Detail

setAppToken

public void setAppToken(java.lang.String appTokenStr)
(Re-)Set the AppToken. If the specified AppToken data is null or the empty string, writes a diagnostic message to the console and leaves the AppToken unchanged.

Parameters:
appTokenStr - The actual token data string.
Since:
1.0
See Also:
appTokenData

getAppToken

public java.lang.String getAppToken()
Obtains the AppToken.

Returns:
The actual token data string.
Since:
1.0
See Also:
appTokenData

setAppTokenFromFile

public boolean setAppTokenFromFile(java.lang.String pathName)
Sets the AppToken data string from a file. The AppToken data string read must be exactly equal to the expected length (that is, the size of the specified text file).

Parameters:
pathName - The pathname of the file containing the actual token data string.
Returns:
  • true: AppToken successfully set from the file data
  • false:
    • Could not open the file
    • Could not read the requisite number of bytes from the file
    AppToken is unchanged.
Since:
1.0
See Also:
readAppTokenFromFile(java.lang.String)

readAppTokenFromFile

public java.lang.String readAppTokenFromFile(java.lang.String pathName)
Reads an AppToken data string from a file. Initially assumes the name of the path of the file containing the AppToken data string is fully qualified. If it doesn't end in txt or TXT, appends the default file name APP_TOKEN_FILE_NAME. Writes a diagnostic message to the console if the specified file cannot be opened or the AppToken data string read is not exactly equal to the expected length (that is, the size of the specified file).

Parameters:
pathName - The path of the file containing the actual token data string.
Returns:
The actual token data string, which might be empty (the specified file is empty) or null (open/read I/O error).
Since:
1.0
See Also:
APP_TOKEN_FILE_SUFFIX, APP_TOKEN_FILE_NAME