public final class AccountKey
extends java.lang.Object
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.
SecurityKey
Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
Constructor and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
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.
|
public AccountKey(java.lang.String stringAccountKey) throws java.lang.IllegalArgumentException
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.
stringAccountKey
- a Degree Days.net API account key.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).public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
AccountKey
object can only be equal to an
AccountKey
object with an identical canonical string account
key.equals
in class java.lang.Object
public int hashCode()
equals
.hashCode
in class java.lang.Object
See www.degreedays.net/api/ for more about the Degree Days.net API.
You can sign up for a Degree Days.net API account and read the integration guide that is useful and applicable whether you are using Java or not.