* minor refactoring
This commit is contained in:
parent
2a291d57c0
commit
7768d2e905
|
@ -12,7 +12,7 @@ import java.security.PrivilegedActionException;
|
||||||
import java.security.PrivilegedExceptionAction;
|
import java.security.PrivilegedExceptionAction;
|
||||||
|
|
||||||
|
|
||||||
public class PrivilegedInvocation implements InvocationHandler {
|
public final class PrivilegedInvocation implements InvocationHandler {
|
||||||
|
|
||||||
private final Object object;
|
private final Object object;
|
||||||
private final AccessControlContext context;
|
private final AccessControlContext context;
|
||||||
|
@ -49,11 +49,11 @@ public class PrivilegedInvocation implements InvocationHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static <I> I newProxy(Class<I> type, I object, AccessControlContext context) {
|
public static <I> I newProxy(Class<I> interfaceClass, I object, AccessControlContext context) {
|
||||||
InvocationHandler invocationHandler = new PrivilegedInvocation(object, context);
|
InvocationHandler invocationHandler = new PrivilegedInvocation(object, context);
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
// create dynamic invocation proxy
|
// create dynamic invocation proxy
|
||||||
return type.cast(Proxy.newProxyInstance(classLoader, new Class[] { type }, invocationHandler));
|
return interfaceClass.cast(Proxy.newProxyInstance(classLoader, new Class[] { interfaceClass }, invocationHandler));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class NameSimilarityMetric implements SimilarityMetric {
|
||||||
|
|
||||||
|
|
||||||
public NameSimilarityMetric() {
|
public NameSimilarityMetric() {
|
||||||
// QGramsDistance with a word tokenizer seems to work best for similarity of names
|
// QGramsDistance with a QGram tokenizer seems to work best for similarity of names
|
||||||
metric = new QGramsDistance(new TokeniserQGram3());
|
metric = new QGramsDistance(new TokeniserQGram3());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,4 +53,5 @@ public class NameSimilarityMetric implements SimilarityMetric {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getClass().getName();
|
return getClass().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,9 @@ public abstract class FileTransferablePolicy extends TransferablePolicy {
|
||||||
protected abstract void load(List<File> files) throws IOException;
|
protected abstract void load(List<File> files) throws IOException;
|
||||||
|
|
||||||
|
|
||||||
protected abstract void clear();
|
protected void clear() {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getFileFilterDescription() {
|
public String getFileFilterDescription() {
|
||||||
|
|
|
@ -20,8 +20,9 @@ public abstract class TransferablePolicy {
|
||||||
|
|
||||||
|
|
||||||
public boolean canImport(TransferSupport support) {
|
public boolean canImport(TransferSupport support) {
|
||||||
if (support.isDrop())
|
if (support.isDrop()) {
|
||||||
support.setShowDropLocation(false);
|
support.setShowDropLocation(false);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return accept(support.getTransferable());
|
return accept(support.getTransferable());
|
||||||
|
@ -63,7 +64,7 @@ public abstract class TransferablePolicy {
|
||||||
return TransferAction.PUT;
|
return TransferAction.PUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static enum TransferAction {
|
public static enum TransferAction {
|
||||||
PUT(TransferHandler.MOVE),
|
PUT(TransferHandler.MOVE),
|
||||||
ADD(TransferHandler.COPY),
|
ADD(TransferHandler.COPY),
|
||||||
|
@ -71,7 +72,7 @@ public abstract class TransferablePolicy {
|
||||||
|
|
||||||
private final int dndConstant;
|
private final int dndConstant;
|
||||||
|
|
||||||
|
|
||||||
private TransferAction(int dndConstant) {
|
private TransferAction(int dndConstant) {
|
||||||
this.dndConstant = dndConstant;
|
this.dndConstant = dndConstant;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue