如何验证具有属性的元素的文本长度.例如:
<sport code="FB">Football</sport>
Run Code Online (Sandbox Code Playgroud)
现在我需要限制代码属性的可能值(如"FB","BB","TT"),还需要限制文本的可能值和长度("Football","BasketBall"," TableTennis")以及这些文本的最大长度("Football","BasketBall","TableTennis")可以是20.
我试过了
<complexType name="sport">
<simpleContent>
<extension base="string">
<attribute name="code" type="code" />
</extension>
</simpleContent>
</complexType>
<simpleType name="code">
<restriction base="string">
<enumeration value="FB" />
<enumeration value="BB" />
<enumeration value="TT" />
</restriction>
</simpleType>
Run Code Online (Sandbox Code Playgroud)
但我无法验证文本"Foolball"的长度(也可能是值)你能否帮助解决如何验证代码和文本.谢谢
问题:Spring Component Annotation扫描没有拾取外部jar中注释的类,该类未包含在pom.xml中.但是我需要从外部jar中扫描具有特定注释的类.这些外部jar将放在类路径中,但在编译期间我的应用程序不会知道.
1)我们有一个maven模块(artifactId ="metric_processor"),它生成一个jar文件(metric_processor.jar)并有以下类
package com.metric;
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface ProcessMetric {
String name();
}
package com.metric;
public interface MetricProcessor {
int computeMetric();
}
package com.metric;
@ProcessMetric(name="LATENCY")
@Component
public class LatencyMetricProcessor implements MetricProcessor {
.....
}
Run Code Online (Sandbox Code Playgroud)
2)我们有另一个maven模块("artifactId ="metric_processor_external"),它生成一个jar(metric_processor_external.jar)并包含"metric_processor"模块作为编译时范围.
package com.metric;
@ProcessMetric(name="TEST_METRIC_EXTERNAL")
@Component
public class TestMetricProcessor implements MetricProcessor {
....
}
Run Code Online (Sandbox Code Playgroud)
3)我们有一个第三个(主要)maven模块(artifactId ="main_application"),它是一个独立的应用程序(使用spring),它在编译范围内包含模块"metric_processor".(但不包括"metric_processor_external").第三个模块的构建插件是
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.main.TriggerMetricProcessor</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> …Run Code Online (Sandbox Code Playgroud) 在我们的java应用程序中,我们试图从类型1 uuid获取unix时间.但它没有给出正确的日期时间值.
long time = uuid.timestamp();
time = time / 10000L; // Dividing by 10^4 as its in 100 nanoseconds precision
Calendar c = Calendar.getInstance();
c.setTimeInMillis(time);
c.getTime();
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
编辑:修正了除数(10 ^ 4)