net.degreedays.api
Class AccountKey

java.lang.Object
  extended by net.degreedays.api.AccountKey

public final class AccountKey
extends java.lang.Object

The shorter of the two access keys, the account key identifies a unique Degree Days.net API account.

Each API account has two access keys: an account key and a security key. The account key identifies the unique Degree Days.net API account. It is a public key in the sense that there is no need to keep it secret.

Here's an example of an account key:

k9vs-e6a3-zh8r

Like the example above, all account keys are made up of three 4-character blocks separated by hyphens, with each non-hyphen character being one of the following:

abcdefghjkmnpqrstuvwxyz23456789

Account keys do not contain upper-case characters or any of the following easily-confused letters and digits: 'i', 'l', 'o', '0' and '1'. The same is true of security keys (the other type of access key). The intention is to make these keys easy for non-technical users to handle (e.g. if entering them into software that you've made for them).

An AccountKey object is a wrapper around a string account key. It is useful for validating account keys from user input, since the constructor will only allow an AccountKey object to be created with a string of the correct format or a string that can be manipulated into the correct format without too much ambiguity.

See Also:
Access keys, SecurityKey

Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.


Constructor Summary
AccountKey(java.lang.String stringAccountKey)
          Constructs an AccountKey object using the specified string account key or throws an IllegalArgumentException if the string is clearly invalid.
 
Method Summary
 boolean equals(java.lang.Object o)
          An AccountKey object can only be equal to an AccountKey object with an identical canonical string account key.
 int hashCode()
          Overridden to ensure consistency with equals.
 java.lang.String toString()
          Returns the non-null, non-empty, canonical string account key.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AccountKey

public AccountKey(java.lang.String stringAccountKey)
           throws java.lang.IllegalArgumentException
Constructs an AccountKey object using the specified string account key or throws an IllegalArgumentException if the string is clearly invalid.

This is somewhat tolerant of imperfect user input. It will try to intelligently handle upper-case letters, white space, and missing or non-hyphen block separators. If you're storing or displaying a string key that a user has entered, make sure to use the string returned by toString(), as that will be the corrected key in its canonical form.

Parameters:
stringAccountKey - a Degree Days.net API account key.
Throws:
java.lang.NullPointerException - if stringAccountKey is null.
java.lang.IllegalArgumentException - if stringAccountKey cannot reasonably be parsed as a Degree Days.net API account key (see these notes for a description of the correct format).
Method Detail

toString

public java.lang.String toString()
Returns the non-null, non-empty, canonical string account key.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
An AccountKey object can only be equal to an AccountKey object with an identical canonical string account key.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overridden to ensure consistency with equals.

Overrides:
hashCode in class java.lang.Object


www.degreedays.net/api/