不知道怎么回事,用word跟新时虽然网站上有内容但是word依然提示出错……
如何防止切开的苹果“生锈”?
5 年前
The abuse of greatness is when it disjoins remorse from power.
public HyperlinkListener createHyperLinkListener() {
return new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
System.out.println(e);
if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
((JEditorPane) e.getSource()).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
((JEditorPane) e.getSource()).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
} catch (Exception ex) {
Logger.getLogger(HTMLServerMessagePanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
};
}
/*
* Copyrights (C) 2008 Bearice (Bearice@Gmail.com)
* Release under GNU/GPL Version 2.
*/
package cn.bearice.ipcontroller.client.core.remote.guet;
import cn.bearice.java.security.Account;
import cn.bearice.ipcontroller.controller.ControllerServer;
import cn.bearice.ipcontroller.RemoteServer;
import cn.bearice.ipcontroller.events.ServerStatusChangeListerer;
import cn.bearice.java.util.listener.*;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketAddress;
import java.net.SocketException;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.security.auth.login.AccountException;
import javax.security.auth.login.AccountLockedException;
import javax.security.auth.login.AccountNotFoundException;
/**
*
* @author Bearice
*/
public class GUET_UDPControllerServer implements ControllerServer {
public static final int STAT_NOT_LOGED_ON = 0;
public static final int STAT_LOGED_ON = 2;
public static final int STAT_LOGON_PENDDING = 1;
private static final Method statusChangedMethod;
static {
try {
statusChangedMethod = ServerStatusChangeListerer.class.getDeclaredMethod(
"serverStatusChanged",
new Class[]{
RemoteServer.class,
int.class,
int.class
});
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
class StatusChangeListenerSupport extends ListenerSupport {
void fireStatusChanged(int before, int after) {
this.fireEventAsync(statusChangedMethod, GUET_UDPControllerServer.this, before, after);
}
}
public static final int CLIENT_LISTEN_PORT = 26000;
StatusChangeListenerSupport statusChangeListenerSupport = new StatusChangeListenerSupport();
SocketAddress remoteAddress;
DatagramSocket socket;
protected int status = STAT_NOT_LOGED_ON;
protected void receive(byte[] buff) throws IOException {
DatagramPacket packet = new DatagramPacket(buff, buff.length);
do {
socket.receive(packet);
} while (packet.getSocketAddress().equals(remoteAddress));
}
protected void send(byte[] buff) throws IOException {
DatagramPacket packet = new DatagramPacket(buff, buff.length);
packet.setSocketAddress(remoteAddress);
socket.send(packet);
}
public GUET_UDPControllerServer(SocketAddress remoteAddress) {
try {
this.remoteAddress = remoteAddress;
socket = new DatagramSocket(CLIENT_LISTEN_PORT);
} catch (SocketException ex) {
Logger.getLogger(GUET_UDPControllerServer.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException(ex);
}
}
public void logon(Account account) throws AccountException {
try {
setStatus(STAT_LOGON_PENDDING);
GUET_PreLogonPacket lp = new GUET_PreLogonPacket(account.getName());
send(lp.toByteArray());
byte[] buff = new byte[22];
receive(buff);
lp.readByteArray(buff);
switch (lp.status) {
case GUET_PreLogonPacket.STATUS_ERROR:
throw new AccountNotFoundException();
case GUET_PreLogonPacket.STATUS_LOCKED:
throw new AccountLockedException();
case GUET_PreLogonPacket.STATUS_OK:
break;
default:
throw new IOException("Illegal PLP.status");
}
lp = new GUET_LogonPacket(account.getName(), account.getPassword());
send(lp.toByteArray());
buff = new byte[32];
receive(buff);
lp.readByteArray(buff);
switch (lp.status) {
case GUET_PreLogonPacket.STATUS_ERROR:
throw new AccountNotFoundException();
case GUET_PreLogonPacket.STATUS_LOCKED:
throw new AccountLockedException();
case GUET_PreLogonPacket.STATUS_OK:
break;
default:
throw new IOException("Illegal PLP.status");
}
setStatus(STAT_LOGED_ON);
} catch (IOException ex) {
Logger.getLogger(GUET_UDPControllerServer.class.getName()).log(Level.SEVERE, null, ex);
throw new AccountException("Error while commucating with server: " + ex);
}
}
public void logoff() {
if (getStatus() != STAT_LOGED_ON) {
throw new IllegalStateException("not loged on!");
}
}
public int getStatus() {
return status;
}
protected void setStatus(int status) {
int oldstst = this.status;
this.status = status;
statusChangeListenerSupport.fireStatusChanged(oldstst, status);
}
public void addStatusChangeListerer(ServerStatusChangeListerer linstener) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void removeStatusChangeLinstener(ServerStatusChangeListerer lintener) {
throw new UnsupportedOperationException("Not supported yet.");
}
public Collection getStatusChangeListeners() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
echo "\033[字背景颜色;字体颜色m字符串\033[0m"
printf(" \033[41;36m something here \033[0m");
echo "Rpc Time:\033[40;33m",$string,"\033[0m\n";
其实并不是一个服务器软件……因为那个空间不支持目录浏览,而且还有关不掉的防盗链功能……极其郁闷……所以就写了这个玩意儿……好久没碰ASP了,都忘了怎么写了,一开始每句后面习惯性加一个分号if语句总是不自觉的加上大括号啥的……
/*
* Copyrights (C) 2008 Bearice (Bearice@Gmail.com)
* Release under GNU/GPL Version 2.
*/
package cn.bearice.java.util.listener;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EventListener;
import java.util.List;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 监听器支持。
* 同于扩展特定的监听器支持类。
* <p>提供监听器的添加,获取和移除服务。提供多监听器的全同步、全异步、顺序同步,顺序异步调用。</p>
* <p>调用侦听器时不保证侦听器的调用顺序。</p>
* <p>除非特别说明,传人任何等于null的参数都将引发NullPointerException</p>
* @author Bearice
*/
public abstract class ListenerSupport<T extends EventListener> {
protected static final ExecutorService tp = Executors.newCachedThreadPool();
protected static final ExecutorService stp = Executors.newSingleThreadExecutor();
protected Collection<T> listeners = new TreeSet<T>();
private static class ListenerCaller implements Callable<Object> {
private Method method;
private Object[] args;
private EventListener listener;
public ListenerCaller(Method method, EventListener listener, Object[] args) {
this.method = method;
this.args = args;
this.listener = listener;
}
public Object call() throws Exception {
return method.invoke(tp, args);
}
}
/**
* 添加一个侦听器。
* <p>如果侦听器已经存在,则忽略。</p>
* @param listener 要添加的侦听器
* @throws NullPointerException listener等于null
*/
public void addListener(T listener) {
if (listener == null) {
throw new NullPointerException();
}
if (!listeners.contains(listener)) {
listeners.add(listener);
}
}
/**
* 移除一个侦听器。
* <p>如果侦听器不存在,则忽略。</p>
* @param listener 要移除的侦听器
* @throws NullPointerException listener等于null
*/
public void removeListener(T listener) {
if (listener == null) {
throw new NullPointerException();
}
if (listeners.contains(listener)) {
listeners.remove(listener);
}
}
/**
* 获取所有侦听器。
* 返回一个包含所有侦听器的<b>不可修改的</b>侦听器集合副本。
* 任何针对该副本的修改操作将引发异常
* @return 侦听器集合副本。
*/
public Collection<T> getAllListeners() {
return Collections.unmodifiableCollection(listeners);
}
/**
* 全异步调用所有侦听器。
* <p>所有侦听器将在不同的线程中同时调用,该方法不会阻塞当前线程。</p>
* <p><b>异常处理:</b>侦听器可以抛出任何异常,但异常将被忽略</p>
* @param method 要调用的方法对象
* @param args 参数
*/
protected void fireEventAsync(Method method, Object... args) {
for (EventListener eventListener : listeners) {
tp.submit(new ListenerCaller(method, eventListener, args));
}
}
/**
* 全同步调用所有侦听器。
* <p>所有侦听器将在不同的线程中同时调用,该方法会阻塞当前线程并等待所有监听器调用全部返回之后才返回</p>
* <p><b>异常处理:</b>侦听器可以抛出任何异常,但异常将被忽略</p>
* @param method 要调用的方法对象
* @param args 参数
*/
protected void fireEventSync(Method method, Object... args) throws InterruptedException {
List<Callable> allCallable = new ArrayList<Callable>(listeners.size());
for (EventListener eventListener : listeners) {
allCallable.add(new ListenerCaller(method, eventListener, args));
}
tp.invokeAll((Collection) allCallable);
}
/**
* 顺序异步调用所有侦听器。
* <p>所有侦听器将在相同同的线程中顺序调用,该方法不会阻塞当前线程。</p>
* <p><b>异常处理:</b>侦听器可以抛出任何异常,但异常将被忽略</p>
* <p><b>调用顺序:</b>不确定调用侦听器的顺序</p>
* @param method 要调用的方法对象
* @param args 参数
*/
protected void fireEventAsyncSeq(Method method, Object... args) {
for (EventListener eventListener : listeners) {
stp.submit(new ListenerCaller(method, eventListener, args));
}
}
/**
* 顺序同步调用所有侦听器。
* <p>所有侦听器将在相同的线程中顺序调用,该方法会阻塞当前线程并等待所有监听器调用全部返回之后才返回</p>
* <p><b>异常处理:</b>侦听器可以抛出任何异常,但异常将被忽略</p>
* <p><b>调用顺序:</b>不确定调用侦听器的顺序</p>
* @param method 要调用的方法对象
* @param args 参数
*/
protected void fireEventSyncSeq(Method method, Object... args) throws InterruptedException {
List<Callable> allCallable = new ArrayList<Callable>(listeners.size());
for (EventListener eventListener : listeners) {
allCallable.add(new ListenerCaller(method, eventListener, args));
}
stp.invokeAll((Collection) allCallable);
}
}