我想计算不同位图的SHA1哈希值(不强制使用SHA).问题是有一些基本相同的位图(验证码),但名称经常变化.
我发现了这个:
但这不是我想要的解决方案.
Bitmap.hashCode()只生成一个Integer,当我正确时
返回此对象的整数哈希代码.通过契约,equals(Object)返回true的任何两个对象都必须返回相同的哈希码值.这意味着Object的子类通常会覆盖两个方法或两个方法.
我不想要对象的哈希码,我想要位图内容的哈希码.感谢名单!
在一项内务管理任务中,我需要清理所有行(每个实体),但不是最新的。我目前没有看到没有循环的方法。
当前的数据源如下所示:
我应该删除“旧”执行并只保留最新的。
我的方法是循环实体键,但我想避免 foreach。最后结果应该是要删除的task_id和taskexec_id的列表。有没有办法只使用 postgre/sql 来做到这一点?
这是我到目前为止所拥有的:
create function entity_with_multiple_propagationtasks()
returns TABLE(entitykey character varying)
language plpgsql
as
$$
BEGIN
RETURN QUERY SELECT DISTINCT task.entitykey FROM
(SELECT task.entitykey FROM task WHERE dtype = 'PropagationTask' GROUP BY task.entitykey having count(*) > (SELECT count(*) FROM conninstance)) more_than_one_entry
INNER JOIN task ON task.entitykey = more_than_one_entry.entitykey
INNER JOIN taskexec ON taskexec.task_id = task.id ORDER BY task.entitykey ASC;
END
$$;
SELECT task.entitykey AS entitykey, task.id AS task_id, taskexec.id AS taskexec_id, taskexec.enddate as enddate
FROM task …Run Code Online (Sandbox Code Playgroud) 对于我在Swing中的图标我有不同的枚举,如:
public enum Icon32 {
STOP("resources/icons/x32/stop.ico"),
RUN("resources/icons/x32/run.ico");
private File path;
private Icon32(String path) {
this.path = new File(path);
}
public File getFile() {
return path;
}
Run Code Online (Sandbox Code Playgroud)
要么
public enum Tab {
XML("resources/icons/x32/tab/tab_1.ico"), QR("resources/icons/x32/tab/tab_2.ico"),ABOUT("resources/icons/x32/tab/tab_3.ico");
private File path;
private Tab(String path) {
this.path = new File(path);
}
public File getFile() {
return path;
}
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个抽象实现:
public abstract class AbstractImageType {
private File path;
private AbstractImageType(String path) {
this.path = new File(path);
}
public File getFile() {
return path;
}
@Override
public …Run Code Online (Sandbox Code Playgroud) 它与iconv-lite一起用于节点0.10.但现在有了
$ node -v
v4.1.1
Run Code Online (Sandbox Code Playgroud)
我不能将iconv-lite与最新的节点版本一起使用.所以我试着回到Iconv:
var Iconv = require('iconv').Iconv;
...
request(url, {
uri: url,
method: 'GET'}, function (err, resp, body) {
var ic = new Iconv('ISO-8859-1', 'utf-8');
var buf = ic.convert(body);
body = buf.toString('utf-8');
Run Code Online (Sandbox Code Playgroud)
但这导致�ber它应该在哪里Über.
我不知道如何解决这个问题.欢迎任何提示.
例如,我有A,B,C类,它们都在一个List<Object>(列表来自XML-Parser,我对这部分没有影响).通常我只需要一种类型.所以我写了以下课程:
public class FilterForObject{
public static List<A> extractA(Result r){
return extractClass(r,A.class);
}
public static List<B> extractB(Result r){
return extractClass(r,B.class);
}
public static List<C> extractC(Result r){
return extractClass(r,C.class);
}
private static <T> List<T> exctracClass(final Result r,final Class<T> resultClass) {
List<T> ret = new ArrayList<T>(40);
for (Object o : r.getAorBorC()) {
if( o instanceof T){
ret.add((T)o); // For some reasons this doesn't work
}
}
return ret;
}
}
Run Code Online (Sandbox Code Playgroud)
我遇到了以下警告:
无法对类型参数T执行instanceof检查.请使用其擦除对象,因为将在运行时擦除其他泛型类型信息
但是我没有得到确切的问题,在编译时所有可能的返回类型都是已知的?
我想要一个带有通用A类的同步LinkedList,这里是相关部分:
public abstract class A<T extends B> implements Runnable {
Run Code Online (Sandbox Code Playgroud)
B的接口,即"真正的"B,将是一个超类
public interface B{
Run Code Online (Sandbox Code Playgroud)
以下设置将引发运行时错误:
LinkedList<A<? extends B>> eopList = (LinkedList<A<? extends B>>) Collections
.synchronizedCollection(new LinkedList<A<? extends B>>());
Run Code Online (Sandbox Code Playgroud)
我找到了以下提案,但它也不会编译:
LinkedList<A<? extends B>> eopList = (LinkedList) Collections
.synchronizedCollection(new LinkedList<A<? extends B>>());
Run Code Online (Sandbox Code Playgroud)
这是日志:
Exception in thread "main" java.lang.ClassCastException: java.util.Collections$SynchronizedCollection cannot be cast to java.util.LinkedList
Run Code Online (Sandbox Code Playgroud) 以下正则表达式应该在C#中处理:
我想找到包含'['或']'的所有字符串.
它应该匹配以下字符串;
...an folder ] ...
...and ] another...
...[so] this is...
...and [ a few more]...
...lorem ipsum[...
Run Code Online (Sandbox Code Playgroud)
以下代码不会编译:
string pattern ="\.*(\[|\])\.*";
List<string> directoriesMatchingPattern= Util.GetSubFoldersMatching(attachmentDirectory,pattern);
Run Code Online (Sandbox Code Playgroud)
并实施:
public static List<string> GetSubFoldersMatching(string attachmentDirectory, string pattern)
{
List<string> matching = new List<string>();
foreach (string directoryName in Directory.GetDirectories(attachmentDirectory))
{
Match match = Regex.Match(directoryName, pattern, RegexOptions.IgnoreCase);
if (match.Success)
{
matching.Add(directoryName);
}
else
{
matching.AddRange(GetSubFoldersMatching(directoryName,pattern));
}
}
return matching;
}
Run Code Online (Sandbox Code Playgroud)
Visual Studio显示的错误是:
Error Unrecognized escape sequence
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题,或者如何正确地逃避这些问题呢?谷歌搜索没有任何帮助.
我有正则表达式教练验证的正则表达式
(\d+)\.(\d+)\.(\d+) (\d+):(\d+):(\d+)
Run Code Online (Sandbox Code Playgroud)
这符合dd.mm.yyyy hh:mm:ss格式,但在Perl我没有收到任何东西
我的数组包含这两个条目
foo 24.03.2014 19:18:57 foobar foo bar
bar 24.03.2014 15:19:00 asdfasrwe jlkj
Run Code Online (Sandbox Code Playgroud)
这是我的Perl程序
use Try::Tiny;
foreach(@array)
{
try {
my ($day, $month, $year,$hours, $minutes, $seconds) = ($_ =~ m/(\d+)\.(\d+)\.(\d+) (\d+):(\d+):(\d+)/);
my $time= "$hours:$minutes:$seconds";
my $date= "$day.$month.$year";
} catch {
warn "caught error: $_";
};
print "Time: $time, Date: $date\n";
}
Run Code Online (Sandbox Code Playgroud)
输出是
Time: , Date:
Time: , Date:
Run Code Online (Sandbox Code Playgroud)
与正则表达式教练一样,我的正则表达式已被批准,并且没有例外.我没有看到我的错误.问题出在哪儿?
java ×3
generics ×2
regex ×2
android ×1
bitmap ×1
c# ×1
encoding ×1
enums ×1
hash ×1
iso-8859-1 ×1
linked-list ×1
node.js ×1
perl ×1
postgresql ×1
request ×1
sql ×1
synchronized ×1