ifbinvocationrequesthandler.java
来自「Sony Ericsson手机上的Facebook客户端全套代码」· Java 代码 · 共 142 行
JAVA
142 行
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3)
// Source File Name: IFbInvocationRequestHandler.java
package com.sonyericsson.fb.content;
import com.sonyericsson.fb.utils.Logger;
import java.io.IOException;
import java.util.Vector;
import javax.microedition.content.*;
// Referenced classes of package com.sonyericsson.fb.content:
// IFbInvocationRequestListener
abstract class IFbInvocationRequestHandler
implements RequestListener
{
IFbInvocationRequestHandler()
{
_contentHandlerID = "";
_handlerServer = null;
_listeners = new Vector();
}
protected void init(String contentHandlerID)
{
_contentHandlerID = contentHandlerID;
if(_handlerServer == null)
try
{
Logger.println("Getting content handler server for ID: " + getContentHandlerID());
_handlerServer = Registry.getServer(getContentHandlerID());
}
catch(Exception e)
{
Logger.printErrorln("Could not get a content handler server! " + getContentHandlerID());
}
if(_handlerServer != null)
_handlerServer.setListener(this);
}
protected String getContentHandlerID()
{
return _contentHandlerID;
}
public void addListener(IFbInvocationRequestListener listener)
{
removeListener(listener);
_listeners.addElement(listener);
}
public void removeListener(IFbInvocationRequestListener listener)
{
_listeners.removeElement(listener);
}
protected void notifyListeners(int type, String arguments[])
{
for(int i = 0; i < _listeners.size(); i++)
((IFbInvocationRequestListener)_listeners.elementAt(i)).invocationRecieved(type, arguments);
}
public boolean handlePendingRequests()
{
if(_handlerServer == null)
return false;
boolean handled = false;
for(Invocation invocation = _handlerServer.getRequest(false); invocation != null; invocation = _handlerServer.getRequest(false))
{
String url = invocation.getURL();
String action = invocation.getAction();
String type = invocation.getType();
String args[] = invocation.getArgs();
String invoker = invocation.getInvokingAppName();
try
{
String response[] = handleRequest(invoker, url, action, type, args);
if(invocation.getResponseRequired() && response != null)
invocation.setArgs(response);
else
if(invocation.getResponseRequired())
invocation.setArgs(null);
}
catch(Exception e) { }
_handlerServer.finish(invocation, 5);
handled = true;
}
return handled;
}
public void invocationRequestNotify(ContentHandlerServer handler)
{
handlePendingRequests();
}
protected abstract String[] handleRequest(String s, String s1, String s2, String s3, String as[]);
public abstract boolean sendMessage(int i);
protected boolean invoke(Invocation invocation)
{
boolean invocationSucceded = false;
try
{
Logger.println("Going to invoke: " + invocation.toString());
Registry registry = Registry.getRegistry(getContentHandlerID());
registry.invoke(invocation);
invocationSucceded = true;
}
catch(IllegalArgumentException e)
{
Logger.printErrorln("The ID, type, URL, and action are all null, orthe content is accessed via the URL and the URL is invalid, orthe argument array contains any null references - " + e.toString());
}
catch(NullPointerException e)
{
Logger.printErrorln("the invocation is null - " + e.toString());
}
catch(ContentHandlerException e)
{
Logger.printErrorln("There is no registered content handler that matches the requested ID, type, URL, and action - " + e.toString());
}
catch(SecurityException e)
{
Logger.printErrorln("Access to the content is not permitted - " + e.toString());
}
catch(IOException e)
{
Logger.printErrorln("Access to the content has failed - " + e.toString());
}
return invocationSucceded;
}
protected String _contentHandlerID;
protected ContentHandlerServer _handlerServer;
private Vector _listeners;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?