101 lines
2.8 KiB
Java
101 lines
2.8 KiB
Java
/*
|
|
* 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 <http://www.mozilla.org/MPL/>.
|
|
*
|
|
* 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 - Generic Mail Gateway.
|
|
*
|
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
|
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
*/
|
|
package com.silverwrist.mailgate;
|
|
|
|
import java.util.*;
|
|
import org.apache.xmlrpc.*;
|
|
|
|
public class Library
|
|
{
|
|
/*--------------------------------------------------------------------------------
|
|
* Constructor
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
public Library()
|
|
{ // do nothing
|
|
} // end constructor
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* External operations
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
public final Integer castInteger(Object obj)
|
|
{
|
|
if (obj instanceof Integer)
|
|
return (Integer)obj;
|
|
if (obj instanceof Number)
|
|
return new Integer(((Number)obj).intValue());
|
|
try
|
|
{ // convert to string and parse into an integer
|
|
return new Integer(obj.toString());
|
|
|
|
} // end try
|
|
catch (NumberFormatException nfe)
|
|
{ // class cast failed
|
|
throw new ClassCastException("castInteger: invalid cast");
|
|
|
|
} // end catch
|
|
|
|
} // end castInteger
|
|
|
|
public final String castString(Object obj)
|
|
{
|
|
return obj.toString();
|
|
|
|
} // end castString
|
|
|
|
public final XmlRpcClient connectXMLRPC(String url, boolean lite) throws PermanentExit
|
|
{
|
|
try
|
|
{ // create the client object
|
|
if (lite)
|
|
return new XmlRpcClientLite(url);
|
|
else
|
|
return new XmlRpcClient(url);
|
|
|
|
} // end try
|
|
catch (java.net.MalformedURLException e)
|
|
{ // translate the exception
|
|
throw new PermanentExit("XML-RPC URL malformed: " + url,e);
|
|
|
|
} // end catch
|
|
|
|
} // end connectXMLRPC
|
|
|
|
public final Vector createVector()
|
|
{
|
|
return new Vector();
|
|
|
|
} // end createVector
|
|
|
|
public final void failPermanent(String message) throws PermanentExit
|
|
{
|
|
throw new PermanentExit("failPermanent: " + message);
|
|
|
|
} // end failPermanent
|
|
|
|
public final void failTemporary(String message) throws TemporaryExit
|
|
{
|
|
throw new TemporaryExit("failTemporary: " + message);
|
|
|
|
} // end failTemporary
|
|
|
|
} // end class Library
|