48.15. 使用 Java DSL


下一步包含与这个记录类型关联的 DataFormat bindy 类,并提供 Java 软件包名称作为参数。

例如,以下使用类 BindyCsvDataFormat (与 CSV 记录类型关联的类对应),该类使用 com.acme.model 软件包名称来初始化在这个软件包中配置的模型对象。

Copy to Clipboard Toggle word wrap
// Camel 2.15 or older (configure by package name)
DataFormat bindy = new BindyCsvDataFormat("com.acme.model");

 
// Camel 2.16 onwards (configure by class name)
DataFormat bindy = new BindyCsvDataFormat(com.acme.model.MyModel.class);

48.15.1. 设置区域设置

Bindy 支持在数据格式中配置区域设置,例如 

Copy to Clipboard Toggle word wrap
// Camel 2.15 or older (configure by package name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat("com.acme.model");
// Camel 2.16 onwards (configure by class name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat(com.acme.model.MyModel.class);

bindy.setLocale("us");

或者要使用平台默认区域设置,然后使用"default"作为区域设置名称。请注意,这需要 Camel 2.14/2.13.3/2.12.5。

Copy to Clipboard Toggle word wrap
// Camel 2.15 or older (configure by package name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat("com.acme.model");
// Camel 2.16 onwards (configure by class name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat(com.acme.model.MyModel.class);

bindy.setLocale("default");

对于旧版本的版本,您可以按照如下所示使用 Java 代码来设置它

Copy to Clipboard Toggle word wrap
// Camel 2.15 or older (configure by package name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat("com.acme.model");
// Camel 2.16 onwards (configure by class name)
BindyCsvDataFormat bindy = new BindyCsvDataFormat(com.acme.model.MyModel.class);

bindy.setLocale(Locale.getDefault().getISO3Country());
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat, Inc.