Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JBrowser Source Code Files
JBrowser Source Code Files are provided in the
source package file.
You can download JBrowser source package as described in the previous tutorial and go to the "src" sub-folder to view Source Code files.
You can also browse JBrowser Source Code files below:
✍: FYIcenter
⏎ org/mozilla/browser/impl/EventBuffer.java
package org.mozilla.browser.impl;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class EventBuffer {
static Log log = LogFactory.getLog(EventBuffer.class);
//knockout event buffer [eventName=>time]
Map<String,Long> eventBuffer = new HashMap<String, Long>();
//public void record(String anEventName, Object[] anArgs) // agrs are most probably not needed
public void record(String anEventName){
log.debug("recording event:"+anEventName); //$NON-NLS-1$
eventBuffer.put(anEventName, new Long(System.currentTimeMillis()) );
}
public void replayOn(Object aTarget){
//order by time (hate Java)
List<Map.Entry<String, Long>> entryList = new ArrayList<Map.Entry<String, Long>>( eventBuffer.entrySet() );
Collections.sort( entryList,
new Comparator<Map.Entry<String, Long>>(){
public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {
return o1.getValue().compareTo(o2.getValue());
}}
);
for (Entry<String, Long> entry : entryList) {
String event = entry.getKey();
try {
log.debug("replaying event:"+event); //$NON-NLS-1$
//execute the method
// Method method = aTarget.getClass().getMethod( event );
Method method = getPrivateMethod(event, aTarget );
method.invoke(aTarget);
}
catch(Exception e){
log.debug("Could not replay event "+event+" on "+aTarget); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
}
eventBuffer.clear();
}
public static Method getPrivateMethod( String aMethodName, Object anObject) {
final Method methods[] = anObject.getClass().getDeclaredMethods();
for (int i = 0; i < methods.length; ++i) {
if (aMethodName.equals(methods[i].getName())) {
methods[i].setAccessible(true);
return methods[i];
}
}
return null;
}
@SuppressWarnings(value="all") //$NON-NLS-1$
public static void main(String[] args) {
Object o = new Object() {
public void onHop(){
System.err.println("Hop"); //$NON-NLS-1$
}
public void onHey(){
System.err.println("Hey"); //$NON-NLS-1$
}
};
EventBuffer eb = new EventBuffer();
eb.record("onHop"); //$NON-NLS-1$
eb.record("onHey"); //$NON-NLS-1$
eb.record("onHop"); //$NON-NLS-1$
eb.replayOn(o);
// should return Hey Hop
}
}
⏎ org/mozilla/browser/impl/EventBuffer.java
Or download all of them as a single archive file:
File name: jbrowser-1.9-fyi.zip File size: 625318 bytes Release date: 2022-11-10 Download
⇐ Download and Install JBrowser Source Package
2017-07-17, ≈46🔥, 1💬
Popular Posts:
commons-collections4-4.2 -sources.jaris the source JAR file for Apache Commons Collections 4.2, whic...
Where Can I get source code files of jsse.jar? You can get source code files of jsse.jar (JSSE) from...
What Is poi-ooxml-3.5.jar? poi-ooxml-3.5.jar is one of the JAR files for Apache POI 3.5, which provi...
How to download and install JDK (Java Development Kit) 1.3? If you want to write Java applications, ...
How to display types defined in an XML Schema file with the xs\QueryXS.java provided in the Apache X...