我找到了一个出色的RegEx来提取camelCase或TitleCase表达式的一部分.
(?<!^)(?=[A-Z])
Run Code Online (Sandbox Code Playgroud)
它按预期工作:
例如使用Java:
String s = "loremIpsum";
words = s.split("(?<!^)(?=[A-Z])");
//words equals words = new String[]{"lorem","Ipsum"}
Run Code Online (Sandbox Code Playgroud)
我的问题是它在某些情况下不起作用:
在我看来,结果应该是:
换句话说,给定n个大写字符:
关于如何改进这个正则表达式的任何想法?
我使用Eclipse Luna win32.x86_64运行Java 8.
这里来自Help Menu > About > Installation Detail > Configuration Tab:
java.runtime.version=1.8.0_05-b13
java.version=1.8.0_05
Run Code Online (Sandbox Code Playgroud)
我创建了新的插件项目,请求JavaSE-1.8作为执行环境:

在myplugin/META-INF/MANIFEST.MF我的文件当然:
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Run Code Online (Sandbox Code Playgroud)
我在产品文件中使用此插件.当我尝试验证它时,我收到以下错误:

当然,如果我开始使用该产品,我会得到:
!ENTRY org.eclipse.osgi 2 0 2014-07-10 08:14:22.042
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2014-07-10 08:14:22.043
!MESSAGE Bundle update@********/myplugin/ was not resolved.
!SUBENTRY 2 myplugin 2 0 2014-07-10 08:14:22.044
!MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))".
Run Code Online (Sandbox Code Playgroud)
我试过验证了很多:
首选项> Java>已安装的JRE …
我有一些文件:
dir/foo.txt
dir/bar.txt
dir/foobar.txt
Run Code Online (Sandbox Code Playgroud)
在Ant apply任务中,我想将文件列表作为参数传递:
<target name="atask">
<apply executable="${cmd}" parallel="false" verbose="true">
<arg value="-in"/>
<srcfile/>
<arg value="dir/foo.txt"/>
<arg value="dir/bar.txt"/>
<arg value="dir/foobar.txt"/>
<fileset dir="${list.dir}" includes="*.list"/>
</apply>
</target>
Run Code Online (Sandbox Code Playgroud)
这工作正常,但如果我想使用文件集动态选择文件列表,该怎么办:
<fileset dir="dir" includes="*.txt"/>
Run Code Online (Sandbox Code Playgroud)
如何将此文件集转换为arg元素 - 每个文件一个?就像是:
<arg>
<fileset dir="dir" includes="*.txt"/>
</arg>
Run Code Online (Sandbox Code Playgroud)
代替
<arg value="dir/foo.txt"/>
<arg value="dir/bar.txt"/>
<arg value="dir/foobar.txt"/>
Run Code Online (Sandbox Code Playgroud)
(此示例不起作用,因为arg不支持文件集)
许多工具为单元测试报告生成并使用相同的XML文件格式.
示例(来源):
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="0" failures="0" hostname="hazelnut.osuosl.org" name="net.cars.engine.MoteurTest" tests="6" time="0.021" timestamp="2007-11-02T23:13:50">
<properties>
<property name="java.vendor" value="IBM Corporation" />
<property name="os.name" value="Linux" />
<!-- more property tags-->
</properties>
<testcase classname="net.cars.engine.MoteurTest" name="hasBougie" time="0.0010" />
<testcase classname="net.cars.engine.MoteurTest" name="hasCarburatueur" time="0.0010" />
<!-- more testcase tags-->
<system-out><![CDATA[]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
Run Code Online (Sandbox Code Playgroud)
经过一番研究后,我发现该格式是由apache基础(由ant项目提出)提出的.
由...生产:
消费者:
我能找到的唯一文件是ant wiki上的这个页面: Proposals/EnhancedTestReports
是否有这种格式的规范(DTD,XSD)?
我想从手写一个这样的文件...(或者如果你知道的话,可以使用librairy)......
我正在尝试使用maven-enforcer-plugin来确保激活一个配置文件(requireActiveProfile规则).请参阅此页面上的第二个示例:需要活动配置文件
它适用于单个pom文件.当我尝试将它与2个pom文件(父母和孩子)一起使用时,当我尝试构建子模块时,这不再起作用了.
我知道为什么它不起作用?
EXAMPLE
| pom.xml <1> (parent pom)
|
\---child
pom.xml <2> (child pom)
Run Code Online (Sandbox Code Playgroud)
<1>:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app.parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<profiles>
<profile>
<id>first</id>
<properties>
<my-name>Alice</my-name>
</properties>
</profile>
<profile>
<id>second</id>
<properties>
<my-name>Bob</my-name>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-first-or-second-profile-is-active</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireActiveProfile>
<profiles>first,second</profiles>
<all>false</all>
</requireActiveProfile>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Hello ${my-name}!</echo> …Run Code Online (Sandbox Code Playgroud) 我有一个 getter 返回带有通配符的列表:
import java.util.List;
public interface Foo {
List<? extends Bar> getList();
}
Run Code Online (Sandbox Code Playgroud)
哪里Bar有其他接口。
当我用 AssertJ 编写断言时,如下所示:
assertThat(foo.getList()).containsExactly(bar1, bar3);
Run Code Online (Sandbox Code Playgroud)
编辑:我的完整用法是链接 ausingElementComparator并提供 aComparator<Bar>来比较预期Bar实例。
Comparator<Bar> comparator = createBarComparator()
assertThat(foo.getList()).usingElementComparator(comparator).containsExactly(bar1, bar3);
Run Code Online (Sandbox Code Playgroud)
我收到此编译错误:
ListAssert 类型中的方法 containsExactly(capture#46-of ? extends Bar...) 不适用于参数 (Bar, Bar)
我的第一个解决方案是投射结果:
assertThat((List<Bar>)foo.getList()).containsExactly(bar1, bar3);
Run Code Online (Sandbox Code Playgroud)
然后我收到警告:
类型安全:从列表到列表的未经检查的转换
可以使用 删除警告@SuppressWarnings("unchecked"),但中间的强制转换仍然无法使断言真正具有可读性。
我的第二个解决方案是指示 ELEMENT 泛型参数的值:
Assertions.<Bar>assertThat(foo.getList()).containsExactly(bar1, bar3);
Run Code Online (Sandbox Code Playgroud)
好一点,但也不是那么好(不可能静态导入,行的开头不利于可读性)
我想我正在寻找assertThat列表的其他方法,其中类类型可以指定为第二个参数:
@CheckReturnValue
public static <ELEMENT> ListAssert<ELEMENT> assertThat(List<? extends ELEMENT> actual, Class<ELEMENT> c) {
return AssertionsForInterfaceTypes.assertThat(actual);
} …Run Code Online (Sandbox Code Playgroud) 我对 Guava 的分裂可能性感兴趣:
Splitter.on("|").split("foo|bar|baz");
// => "foo", "bar", "baz"
Run Code Online (Sandbox Code Playgroud)
这工作正常。
如果我想在“|”上拆分,现在该怎么办?但不在“[”和“]”之间:
Splitter.on(something).split("foo|ba[r|ba]z");
// => "foo", "ba[r|ba]z"
Run Code Online (Sandbox Code Playgroud)
据我了解,不可能在番石榴中定义这个“东西”。
我发现这个: Issue 799: Add google escape library to Guava。这有关系吗?
在我们的新项目中,我们有10个存储库,每个存储库都有相互依赖的Eclipse项目.
我计划建立一个默认工作流,每个开发人员都在使用master分支并使用commit-pull-push循环.为了减少提交并获得良好的线性历史,我更喜欢rebase作为pull的标准策略.这个工作正常,如果branch.master.rebase=true设置.
不幸的是,在用EGit克隆之后,必须手动为所有存储库设置它.我尝试过设置branch.autosetuprebase=always,但这只会影响手动创建的本地分支,而不会影响克隆后的主分支.
我想自动化初始设置,branch.master.rebase=true以减少错误和方便.有办法吗?最好在Eclipse/Egit内部,但也欢迎其他想法.
我已经从改变BREE JavaSE-1.6到JavaSE-1.7我的应用程序的清单文件:
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Run Code Online (Sandbox Code Playgroud)
现在我无法再次编译应用程序.
当我跑步时,mvn clean install我得到:
[INFO] Resolving dependencies of MavenProject: Xgroup:X:4.0.100-SNAPSHOT @ C:\Users\....\X\pom.xml
[WARNING] The following locally built units have been used to resolve project dependencies:
[WARNING] Za
[WARNING] Zb
[INFO] Resolving class path of MavenProject: Xgroup:X:4.0.100-SNAPSHOT @ C:\Users\....\X\pom.xml
[ERROR] Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle X cannot be resolved
[ERROR] Resolution errors:
[ERROR] Bundle X - Missing Constraint: Bundle-RequiredExecutionEnvironment: JavaSE-1.7
[ERROR] -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle X cannot …Run Code Online (Sandbox Code Playgroud) 根据问题#4883和 PR #15320,vscode:/您可以在 HTML 中创建链接:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<h1>Test</h1>
<a href="vscode://path/to/my/file.md">open file.md in vscode</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这应该与在控制台中键入以下内容具有相同的效果:
code -g -r /path/to/my/file.md
Run Code Online (Sandbox Code Playgroud)
但我得到的却不同:
点击后:
单击“打开 Visual Studio Code”后,应用程序将打开(或置于前台),但文件未打开。
我错过了什么?
我已经尝试过,<a href="vscode:///path/to/my/file.md">但结果是一样的。
鉴于这个简单的人POJO:
public class Person {
private String id;
private String name;
public Person(String id, String name) {
super();
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
}
Run Code Online (Sandbox Code Playgroud)
我想收集Map<String, Person>钥匙是id人的钥匙.
我试图像这样实现它:
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
public class CollectorMain {
public static void main(String[] args) {
List<Person> list = new ArrayList<>();
list.add(new Person("312", "John"));
list.add(new Person("454", "Alice"));
list.add(new Person("712", …Run Code Online (Sandbox Code Playgroud) 当我尝试将包含一些JavaScript的项目导入工作区(使用Eclipse的Neon.M6版本)时,我收到此错误:
eclipse.buildId=4.6.0.I20160317-0200
java.version=1.8.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
org.eclipse.core.jobs
Error
Wed Mar 30 18:38:50 CEST 2016
An internal error occurred during: "Validating ****".
java.lang.NoClassDefFoundError: jdk/nashorn/internal/runtime/ECMAException
at org.eclipse.wst.jsdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:860)
at org.eclipse.wst.jsdt.core.dom.ASTParser.createAST(ASTParser.java:651)
at org.eclipse.wst.jsdt.internal.core.validation.JavaScriptValidator.validate(JavaScriptValidator.java:62)
at org.eclipse.wst.validation.Validator$V2.validate(Validator.java:1159)
at org.eclipse.wst.validation.internal.ValManager.validate(ValManager.java:704)
at org.eclipse.wst.validation.internal.ValManager$1.visit(ValManager.java:665)
at org.eclipse.wst.validation.internal.ValManager.accept(ValManager.java:810)
at org.eclipse.wst.validation.internal.ValManager.validate(ValManager.java:669)
at org.eclipse.wst.validation.internal.ValBuilderJob$Visitor.visit(ValBuilderJob.java:299)
at org.eclipse.core.internal.resources.Resource$2.visit(Resource.java:120)
at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:84)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:129)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:52)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:117)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:105)
at org.eclipse.wst.validation.internal.ValBuilderJob.fullBuild(ValBuilderJob.java:219)
at org.eclipse.wst.validation.internal.ValBuilderJob.run(ValBuilderJob.java:178)
at org.eclipse.wst.validation.internal.ValBuilderJob.runInWorkspace(ValBuilderJob.java:126)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39) …Run Code Online (Sandbox Code Playgroud) java ×4
eclipse ×3
generics ×2
maven ×2
ant ×1
arguments ×1
assertj ×1
camelcasing ×1
collectors ×1
dtd ×1
eclipse-rcp ×1
egit ×1
equinox ×1
fileset ×1
git ×1
guava ×1
html ×1
hyperlink ×1
java-8 ×1
java-stream ×1
javascript ×1
jsdt ×1
nashorn ×1
osgi ×1
osgi-bundle ×1
parent-pom ×1
regex ×1
report ×1
title-case ×1
tycho ×1
unit-testing ×1
wildcard ×1
xml ×1
xsd ×1