/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at .
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.util;
import org.w3c.dom.*;
import com.silverwrist.util.*;
import com.silverwrist.venice.except.*;
public class VCardEmail
{
/*--------------------------------------------------------------------------------
* Predicate class to use for searches
*--------------------------------------------------------------------------------
*/
static abstract class Predicate
{
public abstract boolean test(VCardEmail e);
} // end class Predicate
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private boolean home_email;
private boolean work_email;
private boolean internet_email;
private boolean x400_email;
private boolean preferred;
private String address;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
VCardEmail(Element elt)
{
DOMElementHelper h = new DOMElementHelper(elt);
home_email = h.hasChildElement("HOME");
work_email = h.hasChildElement("WORK");
internet_email = h.hasChildElement("INTERNET");
x400_email = h.hasChildElement("X400");
preferred = h.hasChildElement("PREF");
if (!internet_email && !x400_email)
internet_email = true; // default
address = VCard.cleanup(h.getSubElementText("USERID"));
if (address==null)
address = VCard.cleanup(h.getElementText());
} // end constructor
/*--------------------------------------------------------------------------------
* External getters/setters
*--------------------------------------------------------------------------------
*/
public final boolean isHomeEmail()
{
return home_email;
} // end isHomeEmail
public final boolean isWorkEmail()
{
return work_email;
} // end isHomeEmail
public final boolean isInternetEmail()
{
return internet_email;
} // end isInternetEmail
public final boolean isX400Email()
{
return x400_email;
} // end isX400Email
public final boolean isPreferred()
{
return preferred;
} // end isPreferred
public final String getAddress()
{
return address;
} // end getAddress
} // end class VCardEmail