org.tentackle.util
Class Telno

java.lang.Object
  extended by org.tentackle.util.Telno

public class Telno
extends Object

A phone-number.

A phone-number is defined as follows:

 +CCC AAAA NNNN[-EEEE]

  C = country code
  A = area code
  N = number
  E = extension (optional)
 

Author:
harald

Constructor Summary
Telno()
          Creates an empty (and invalid) phono number without extension
 
Method Summary
 void clear()
          Clears the phone number
 int getArea()
          Gets the area code.
 int getCountry()
          Gets the country code.
 int getDefaultCountry()
          Gets the default country code.
 String getError()
          Gets the error message.
 int getExtension()
          Gets the extension.
 int getNumber()
          Gets the number part.
 String getTelno()
          Gets the phone number as a string.
 boolean isValid()
          Returns whether number is valid
 void setArea(int area)
          Sets the area code.
 void setCountry(int country)
          Sets the country code.
 void setDefaultCountry(int defaultCountry)
          Sets the default country code.
 void setError(String error)
          Sets the error message.
 void setExtension(int extension)
          Sets the extension.
 void setNumber(int number)
          Sets the number part.
 boolean setTelno(String telno)
          Sets the phone number and verifies it.
The digits must be either seperated by a dash or a space.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Telno

public Telno()
Creates an empty (and invalid) phono number without extension

Method Detail

clear

public void clear()
Clears the phone number


setTelno

public boolean setTelno(String telno)
Sets the phone number and verifies it.
The digits must be either seperated by a dash or a space. The national prefix is mandatory!

Parameters:
telno - the string to parse, null if "not set"
Returns:
true if ok, false if error

getTelno

public String getTelno()
Gets the phone number as a string.

Returns:
the phone-number as a string

toString

public String toString()
Description copied from class: java.lang.Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.

isValid

public boolean isValid()
Returns whether number is valid

Returns:
true if valid, else invalid or empty

getCountry

public int getCountry()
Gets the country code.

Returns:
the country code

setCountry

public void setCountry(int country)
Sets the country code.

Parameters:
country - the country code

getArea

public int getArea()
Gets the area code.

Returns:
the area code

setArea

public void setArea(int area)
Sets the area code.

Parameters:
area - the area code

getNumber

public int getNumber()
Gets the number part.

Returns:
the phone number part

setNumber

public void setNumber(int number)
Sets the number part.

Parameters:
number - the phone number part

getExtension

public int getExtension()
Gets the extension.

Returns:
the extension, -1 if none

setExtension

public void setExtension(int extension)
Sets the extension.

Parameters:
extension - the extension, -1 if none

getDefaultCountry

public int getDefaultCountry()
Gets the default country code.

Returns:
the default country code, 0 if no default

setDefaultCountry

public void setDefaultCountry(int defaultCountry)
Sets the default country code. Will be prepended if missing.

Parameters:
defaultCountry - the default country code, 0 if no default

getError

public String getError()
Gets the error message.

Returns:
the error message, null if none

setError

public void setError(String error)
Sets the error message.

Parameters:
error - the error message, null if none


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de