Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.marlovits.addressSearch.directories
Class PhoneBookContentParser

java.lang.Object
  extended by ch.marlovits.addressSearch.directories.HtmlParser
      extended by ch.marlovits.addressSearch.directories.PhoneBookContentParser
Direct Known Subclasses:
PhoneBookContentParser_at, PhoneBookContentParser_ch, PhoneBookContentParser_de

public abstract class PhoneBookContentParser
extends HtmlParser


Constructor Summary
PhoneBookContentParser(java.lang.String name, java.lang.String geo, int pageNum, java.lang.String charSet)
          this is the constructor: save name, geo and pageNum in members, calc htmlText and save in members too
 
Method Summary
static java.lang.String extractFirstnames(java.lang.String firstnames, java.lang.String delimiter)
          extract the firstnames from the input String
abstract  java.util.List<java.util.HashMap<java.lang.String,java.lang.String>> extractKontakte()
          extracts Kontakte from HTML
extract [entriesPerPage] number of entries
Abstract function, must override
abstract  java.util.HashMap<java.lang.String,java.lang.String> extractKontaktFromDetail()
          extracts a Kontakt from a DetailEntry (single result displayed on a page)
this just extracts the parts needed for the display in the results list
if the actual detail info is needed, then the vCards are extracted
this procedure can be the same as extracting from a list
- for ch this is different from extractListKontakt
- for de this is the same as extractListKontakt
- for at this is the same as extractListKontakt Abstract function, must override
abstract  java.util.HashMap<java.lang.String,java.lang.String> extractKontaktFromList()
          extracts a Kontakt from a listEntry (multiple results displayed on a page)
this just extracts the parts needed for the display in the results list
if the actual detail info is needed, then the vCards are extracted
Abstract function, must override
abstract  java.util.HashMap<java.lang.String,java.lang.String> extractMaxInfo(java.util.HashMap<java.lang.String,java.lang.String> kontaktHashMap)
          extracts a Kontakt with ALL available info from a vCard and /or html combined
usually if there is a vCard then it is better to use this to get the data
static java.lang.String formatPhoneNumber(java.lang.String phoneNumber)
          Format a phone number according to the country of the subclass
static java.lang.String formatPhoneNumber(java.lang.String phoneNumber, java.lang.String inFormat, java.lang.String outFormat)
          Format a phone number according to your needs.
static java.lang.String formatString(java.lang.String sourceString)
          reformat string correctly which came from vCard from tel.local.ch
abstract  java.lang.String[][] getCitiesList()
          returns a list of possible city names if the entered city could not be found or matched exactly
abstract  java.lang.String getCitiesListMessage()
          if there is more than one city to select from then this procedure extracts the error message to show to the user for explaining
abstract  java.lang.String[][] getCitySuggestions(java.lang.String part)
           
abstract  int getNumOfEntries()
          extracts the total number of found entries
Abstract function, must override
abstract  java.lang.String getSearchInfo()
          extract infos for the current search from HTML-source
- für die Suche in ch - tel.search.ch zBsp "Treffer 1 - 10 von 11"
- für die Suche in de - telefonbuch.de zBsp "Seite 1 (von 6)"
- für die Suche in at - herold.at/telefonbuch zBsp "Treffer 1-15 von 61"
Abstract function, must override
abstract  java.net.URL getURL(java.lang.String name, java.lang.String geo, int pageNum)
          creates and returns a URL for reading data from an online-address-query page
Abstract function, must override
abstract  boolean hasCitiesList()
          test if the query returned saying that there is more than one city to select from
 void initHashMap(java.util.HashMap<java.lang.String,java.lang.String> entry)
           
abstract  boolean noCityFound()
          test if the there entered city has been found or not
static java.lang.String readContent(java.lang.String urlText, java.lang.String charSet, int timeout)
          read and return the contents of a html page
 java.lang.String readContent(java.lang.String name, java.lang.String geo, int pageNum, java.lang.String charSet, int timeout)
          read and return the contents of a html page, uses default character encoding timeout needed because on telefonbuch.de vCards sometimes do not work correctly...
 
Methods inherited from class ch.marlovits.addressSearch.directories.HtmlParser
extract, extractTo, getNextPos, getNextPos, getTail, moveTo, reset, setHtmlText, startsWith
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PhoneBookContentParser

public PhoneBookContentParser(java.lang.String name,
                              java.lang.String geo,
                              int pageNum,
                              java.lang.String charSet)
this is the constructor: save name, geo and pageNum in members, calc htmlText and save in members too

Parameters:
name - search for this name
geo - search in this city/location
pageNum - which page to get, zero-based
Method Detail

getSearchInfo

public abstract java.lang.String getSearchInfo()
extract infos for the current search from HTML-source
- für die Suche in ch - tel.search.ch zBsp "Treffer 1 - 10 von 11"
- für die Suche in de - telefonbuch.de zBsp "Seite 1 (von 6)"
- für die Suche in at - herold.at/telefonbuch zBsp "Treffer 1-15 von 61"
Abstract function, must override

Returns:
the search string to be displayed as info

getNumOfEntries

public abstract int getNumOfEntries()
extracts the total number of found entries
Abstract function, must override

Returns:
number of found entries

extractKontakte

public abstract java.util.List<java.util.HashMap<java.lang.String,java.lang.String>> extractKontakte()
extracts Kontakte from HTML
extract [entriesPerPage] number of entries
Abstract function, must override

Returns:
the List of KontaktEntry's

extractKontaktFromList

public abstract java.util.HashMap<java.lang.String,java.lang.String> extractKontaktFromList()
extracts a Kontakt from a listEntry (multiple results displayed on a page)
this just extracts the parts needed for the display in the results list
if the actual detail info is needed, then the vCards are extracted
Abstract function, must override

Returns:
the Kontakt in a HashMap, the possible keys of the HashMap are described above

extractKontaktFromDetail

public abstract java.util.HashMap<java.lang.String,java.lang.String> extractKontaktFromDetail()
extracts a Kontakt from a DetailEntry (single result displayed on a page)
this just extracts the parts needed for the display in the results list
if the actual detail info is needed, then the vCards are extracted
this procedure can be the same as extracting from a list
- for ch this is different from extractListKontakt
- for de this is the same as extractListKontakt
- for at this is the same as extractListKontakt Abstract function, must override

Returns:
the Kontakt in a HashMap, the possible keys of the HashMap are described above

extractMaxInfo

public abstract java.util.HashMap<java.lang.String,java.lang.String> extractMaxInfo(java.util.HashMap<java.lang.String,java.lang.String> kontaktHashMap)
extracts a Kontakt with ALL available info from a vCard and /or html combined
usually if there is a vCard then it is better to use this to get the data

Parameters:
kontaktHashMap - Kontakt for which to extract the info
Returns:
the Kontakt in a HashMap, the possible keys of the HashMap are described above

hasCitiesList

public abstract boolean hasCitiesList()
test if the query returned saying that there is more than one city to select from

Returns:
boolean true if there is more than one city to select from

getCitiesListMessage

public abstract java.lang.String getCitiesListMessage()
if there is more than one city to select from then this procedure extracts the error message to show to the user for explaining

Returns:
the error/explanation string

getCitiesList

public abstract java.lang.String[][] getCitiesList()
returns a list of possible city names if the entered city could not be found or matched exactly

Returns:
String[] the list of city-pairs, null if none found. each entry consist of following parts: city - selectable. if the entry is not selectable, then it is just a category for the following entries

noCityFound

public abstract boolean noCityFound()
test if the there entered city has been found or not

Returns:
false if no city found

getCitySuggestions

public abstract java.lang.String[][] getCitySuggestions(java.lang.String part)

extractFirstnames

public static java.lang.String extractFirstnames(java.lang.String firstnames,
                                                 java.lang.String delimiter)
extract the firstnames from the input String

Parameters:
firstnames - input
delimiter - used to separate the firstnames for the result string
Returns:
the separated firstnames, delimited by <delimiter>

formatString

public static java.lang.String formatString(java.lang.String sourceString)
reformat string correctly which came from vCard from tel.local.ch

Parameters:
sourceString -
Returns:
the correctly formatted string

formatPhoneNumber

public static java.lang.String formatPhoneNumber(java.lang.String phoneNumber)
Format a phone number according to the country of the subclass

Parameters:
phoneNumber - the phoneNumber as returned from html
Returns:
the reformatted phone number. if the input is not formatted correctly, then the function returns an empty string this implementation just returns the unchanged phone number

formatPhoneNumber

public static java.lang.String formatPhoneNumber(java.lang.String phoneNumber,
                                                 java.lang.String inFormat,
                                                 java.lang.String outFormat)
Format a phone number according to your needs. NOT YET IMPLEMENTED

Parameters:
phoneNumber - the phoneNumber as returned from html
inFormat - the format of the input
outFormat - how to format the output
Returns:
the reformatted phone number. if the input is not formatted correctly, then the function returns an empty string

getURL

public abstract java.net.URL getURL(java.lang.String name,
                                    java.lang.String geo,
                                    int pageNum)
creates and returns a URL for reading data from an online-address-query page
Abstract function, must override

Parameters:
name - search for this name
geo - search in this city/location
pageNum - which page to get
Returns:
the url which returns the results, null if any error occurs

readContent

public java.lang.String readContent(java.lang.String name,
                                    java.lang.String geo,
                                    int pageNum,
                                    java.lang.String charSet,
                                    int timeout)
read and return the contents of a html page, uses default character encoding timeout needed because on telefonbuch.de vCards sometimes do not work correctly...

Parameters:
name - search for this name
geo - search in this city/location
pageNum - which page to get
timeOut - = how long to wait for the page to be returned in milliseconds, 0 = no timeout
Returns:
String, the contents of the page

readContent

public static java.lang.String readContent(java.lang.String urlText,
                                           java.lang.String charSet,
                                           int timeout)
read and return the contents of a html page

Parameters:
urlText - = the url from where the page should be read
charSet - = the character set to be used for page-encoding
timeOut - = how long to wait for the page to be returned in milliseconds, 0 = no timeout
Returns:
String, the contents of the page

initHashMap

public void initHashMap(java.util.HashMap<java.lang.String,java.lang.String> entry)

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis