Elexis API documentation
Version 2.1.6 as of January 22 2012

ch.marlovits.addressSearch.directories
Class PhoneBookContentParser_ch

java.lang.Object
  extended by ch.marlovits.addressSearch.directories.HtmlParser
      extended by ch.marlovits.addressSearch.directories.PhoneBookContentParser
          extended by ch.marlovits.addressSearch.directories.PhoneBookContentParser_ch

public class PhoneBookContentParser_ch
extends PhoneBookContentParser


Constructor Summary
PhoneBookContentParser_ch(java.lang.String name, java.lang.String geo, int pageNum)
          this is the constructor: save html, name, geo and country in members
 
Method Summary
 java.util.List<java.util.HashMap<java.lang.String,java.lang.String>> extractKontakte()
          extracts Kontakte from HTML
extract [entriesPerPage] number of entries
by parsing <div class="xxx"> we can decide if this is a listEntry or a detailEntry
detailEntries: "adrNameDetLev0" "adrNameDetLev1" "adrNameDetLev3" "adrNameDetLev2" must NOT be extracted
listEntries: "adrListLev0" "adrListLev1" "adrListLev3" "adrListLev0Cat" must NOT be extracted
 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
 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
 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
static java.lang.String formatPhoneNumber(java.lang.String phoneNumber)
          Format a phone number as swiss phone number, 0xx xxx xx xx
 java.lang.String[][] getCitiesList()
          returns a list of possible city names if the entered city could not be found or matched exactly
 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
 java.lang.String[][] getCitySuggestions(java.lang.String part)
           
 int getNumOfEntries()
          extracts the total number of found entries
Abstract function, must override
 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
 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
 boolean hasCitiesList()
          test if the query returned saying that there is more than one city to select from
 boolean noCityFound()
          test if the there entered city has been found or not
 
Methods inherited from class ch.marlovits.addressSearch.directories.PhoneBookContentParser
extractFirstnames, formatPhoneNumber, formatString, initHashMap, readContent, readContent
 
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_ch

public PhoneBookContentParser_ch(java.lang.String name,
                                 java.lang.String geo,
                                 int pageNum)
this is the constructor: save html, name, geo and country in members

Parameters:
name -
geo -
pageNum -
Method Detail

getSearchInfo

public 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

Specified by:
getSearchInfo in class PhoneBookContentParser
Returns:
the search string to be displayed as info

getNumOfEntries

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

Specified by:
getNumOfEntries in class PhoneBookContentParser
Returns:
number of found entries

extractKontakte

public java.util.List<java.util.HashMap<java.lang.String,java.lang.String>> extractKontakte()
extracts Kontakte from HTML
extract [entriesPerPage] number of entries
by parsing <div class="xxx"> we can decide if this is a listEntry or a detailEntry
detailEntries:
  • "adrNameDetLev0"
  • "adrNameDetLev1"
  • "adrNameDetLev3"
  • "adrNameDetLev2" must NOT be extracted
    listEntries:
  • "adrListLev0"
  • "adrListLev1"
  • "adrListLev3"
  • "adrListLev0Cat" must NOT be extracted

    Specified by:
    extractKontakte in class PhoneBookContentParser
    Returns:
    the List of KontaktEntry's


  • extractKontaktFromList

    public 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

    Specified by:
    extractKontaktFromList in class PhoneBookContentParser
    Returns:
    the Kontakt in a HashMap, the possible keys of the HashMap are described above


    extractKontaktFromDetail

    public 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

    Specified by:
    extractKontaktFromDetail in class PhoneBookContentParser
    Returns:
    the Kontakt in a HashMap, the possible keys of the HashMap are described above


    extractMaxInfo

    public 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

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

    getURL

    public 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

    Specified by:
    getURL in class PhoneBookContentParser
    Parameters:
    name - search for this name
    geo - search in this city/location
    country - search in this country - must be iso2 name of the country
    pageNum -
    Returns:
    the url which returns the results, null if any error occurs

    formatPhoneNumber

    public static java.lang.String formatPhoneNumber(java.lang.String phoneNumber)
    Format a phone number as swiss phone number, 0xx xxx xx xx

    Parameters:
    phoneNumber - the phoneNumber as returned from vCard from tel.local.ch, eg. "+41523439772", the "+" is already replaced by " " -> " 41523439772"
    Returns:
    the reformatted phone number. if the input is not formatted correctly, then the function returns an empty string

    getCitiesList

    public java.lang.String[][] getCitiesList()
    Description copied from class: PhoneBookContentParser
    returns a list of possible city names if the entered city could not be found or matched exactly

    Specified by:
    getCitiesList in class PhoneBookContentParser
    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

    getCitiesListMessage

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

    Specified by:
    getCitiesListMessage in class PhoneBookContentParser
    Returns:
    the error/explanation string

    hasCitiesList

    public boolean hasCitiesList()
    Description copied from class: PhoneBookContentParser
    test if the query returned saying that there is more than one city to select from

    Specified by:
    hasCitiesList in class PhoneBookContentParser
    Returns:
    boolean true if there is more than one city to select from

    noCityFound

    public boolean noCityFound()
    Description copied from class: PhoneBookContentParser
    test if the there entered city has been found or not

    Specified by:
    noCityFound in class PhoneBookContentParser
    Returns:
    false if no city found

    getCitySuggestions

    public java.lang.String[][] getCitySuggestions(java.lang.String part)
    Specified by:
    getCitySuggestions in class PhoneBookContentParser

    Elexis API documentation
    Version 2.1.6 as of January 22 2012

    Copyright 2005-2011 by Gerry Weirich, Elexis