问题列表 - 第15997页

为什么Java语言没有提供通过注释声明给定"字段"的getter和setter的方法?

我实际上很高兴地设计和开发Java EE应用程序已经有9年了,但我最近意识到,随着时间的推移,我越来越厌倦了将所有这些丑陋的bean类与他们的getter和setter一起拖延.

考虑像这样的基本bean:

public class MyBean {

    // needs getter AND setter
    private int myField1;

    // needs only a getter, no setter
    private int myField2;

    // needs only a setter, no getter
    private int myField3;

    /**
     * Get the field1
     * @return the field1
     */
    public int getField1() {
            return myField1;
    }

    /**
     * Set the field1
     * @param value the value
     */
    public void setField1(int value) {
            myField1 = value;
    }

    /**
     * Get the field2
     * @return the …
Run Code Online (Sandbox Code Playgroud)

java syntax

4
推荐指数
1
解决办法
1191
查看次数

在Eclipse菜单Window-> Show View中显示视图

"我创建了一个Eclipse插件,它在Eclipse中创建了一个视图.目前它在Eclipse菜单中显示为:'Window-> Show View-> Others'.

我想在"窗口 - >显示视图"中显示它,而不是在"其他"子菜单下显示.

我尝试过将plugin.xml文件中的视图的"类别"设置为"org.eclipse.ui",但它仍然显示"其他"子菜单中的视图.

有没有其他方法可以这样做?在这方面,任何建议都有帮助.

在此先感谢,Abhinav"

eclipse plugins menu view show

5
推荐指数
1
解决办法
7249
查看次数

javascript变量引用/别名

是否有可能在javascript中为某个本地var分配别名/引用?

我的意思是C-like:

function foo() {
  var x = 1;
  var y = &x;
  y++;
  alert(x); // prints 2 
}
Run Code Online (Sandbox Code Playgroud)

=编辑=

是否可以在此代码中为arguments.callee设置别名?:

function foo() {
  arguments.callee.myStaticVar = arguments.callee.myStaticVar || 0;
  arguments.callee.myStaticVar++;
  return arguments.callee.myStaticVar;
}
Run Code Online (Sandbox Code Playgroud)

javascript

89
推荐指数
3
解决办法
9万
查看次数

角度的加权平均值

我想计算一组角度的加权平均值。

这个问题中,有一个如何计算平均值的答案,如本页所示。

现在我想弄清楚如何计算加权平均值。也就是说,对于每个角度都有一个权重(权重之和为 1)

0.25、0度 0.5、20度 0.25、90度

加权平均应该(如果我没有弄错的话)是 32 度。

python algorithm mean

4
推荐指数
1
解决办法
4407
查看次数

如何比较批处理脚本中文件的时间戳?

在DOS批处理文件中,实现某些事情的方法有些混淆.幸运的是,有一个很棒的批处理脚本参考站点:Simon Sheppard的SS64.(同一网站也有大量关于Bash的信息.)

一个难点是根据目录是否为空来分支执行.显而易见的if exist "%dir%\*.*"是行不通的.但是可以使用这个条件执行技巧来完成:

( dir /b /a "%dir%" | findstr . ) > nul && (
  echo %dir% non-empty
) || (
  echo %dir% empty
)
Run Code Online (Sandbox Code Playgroud)

另一个尴尬的问题是根据文件内容进行分支.再次,可以这样做:

( fc /B "%file1%" "%file2%" | find "FC: no differences encountered" ) > nul && (
  echo "%file1%" and "%file2%" are the same
) || (
  echo "%file1%" and "%file2%" are different
)
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是:
有没有办法根据文件的时间戳做分支?

这是我想要的东西:

REM *** pseudo-code!
if "%file1%" is_newer_than "%file2%" (
  echo …
Run Code Online (Sandbox Code Playgroud)

filesystems cmd batch-file

28
推荐指数
6
解决办法
7万
查看次数

SQL,删除行尾的逗号外观

我的数据如下

MyText
-------
some text, some more text, even more text,,
some text,,,,
some text, some text,,,
some text, some more text, even more, yet more, and again
Run Code Online (Sandbox Code Playgroud)

我想实现:

MyText
-------
some text, some more text, even more text
some text
some text, some text
some text, some more text, even more, yet more, and again
Run Code Online (Sandbox Code Playgroud)

如何删除行尾的逗号?我必须保留项目之间的逗号,但我需要删除任何项目

我需要在select语句中执行此操作,并且我无法在不编写函数的情况下找到应用RegEx的解决方案(我希望避免使用)

我有一个解决方案,但它特别脏,我想改进它.我正在使用一组嵌套的REPLACE替换4个逗号,3个用3个替换,2个用一个替换,然后删除一个

有任何想法吗?

编辑:数据来自外部系统,所以我无法控制,否则我会在第一个实例中正确连接逗号.我正在使用的这个语句将在SQL Server 2005上运行

sql sql-server replace

3
推荐指数
1
解决办法
1万
查看次数

WeakReference的线程安全性

使用WeakReference时,我们怎样才能确定在.IsAlive和.Target调用之间没有收集目标?

例如:

if (myWeakReference.IsAlive)
{
    // How can we be sure the object is still alive while here?
    ((MyType)myWeakReference.Target).Foo();
}
Run Code Online (Sandbox Code Playgroud)

.net c# weak-references

15
推荐指数
2
解决办法
1343
查看次数

将相似输入映射到相似输出的哈希函数?

是否有一个哈希函数,输入的微小变化会导致输出的微小变化?例如,类似:

hash("Foo") => 9e107d9d372bb6826bd81d3542a419d6
hash("Foo!") => 9e107d9d372bb6826bd81d3542a419d7 <- note small difference
Run Code Online (Sandbox Code Playgroud)

algorithm hash hashcode simhash

5
推荐指数
1
解决办法
1568
查看次数

连接字符串

我有一个asp.net应用程序.有一个数据绑定部分到datagrid.But有一个错误.我认为它可能在web配置 - 连接字符串.连接字符串是这样的

<add name="ArchitectConnectionString" connectionString="Data Source=192.168.1.15,1433;Network Library=DBMSSOCN;Initial Catalog=Architect;" providerName="System.Data.SqlClient" />
Run Code Online (Sandbox Code Playgroud)

错误是

用户''登录失败.用户未与受信任的SQL Server连接关联.

请帮我..

asp.net

1
推荐指数
1
解决办法
249
查看次数

从代码隐藏到XAML的简单数据绑定


我是WPF概念的新手.我想在文本框中显示一个字符串.我尝试了以下C#代码和XAML将字符串绑定到TextBox.Text属性.C#代码:

public partial class Window1 : Window
{
    public int TmpVal;
    public string TmpStr;

     public Window1()
    {
        TmpVal = 50;
        TmpStr = "Windows Created";
        InitializeComponent();
        this.DataContext = this;
    }
    private void viewButton_Click(object sender, RoutedEventArgs args)
    {
        TmpStr = "Button clicked";
    }
}
Run Code Online (Sandbox Code Playgroud)

}

XAML:

 <Window x:Class="TestWPF.Window1"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="800" x:Name="ThisWindow">
<Grid>
    <TextBox Name="txtTest1" Margin="200,0,200,200" HorizontalAlignment="Left" Height="50" Width="200" Text="{Binding TmpStr, ElementName=ThisWindow}" />
    <Button Name="butTest1"  Click="viewButton_Click">Test123</Button>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

执行时,我的文本框中总是会出现空白文本(即使我调用了click事件).
我浏览了stackoverflow网站,但无法解决问题(虽然很多问题都接近这个问题)
有人建议我,如果有什么被忽视或错过了吗?

c# data-binding wpf xaml

2
推荐指数
1
解决办法
1万
查看次数