本文整理汇总了Java中org.yaml.snakeyaml.representer.Representer.setDefaultFlowStyle方法的典型用法代码示例。如果您正苦于以下问题:Java Representer.setDefaultFlowStyle方法的具体用法?Java Representer.setDefaultFlowStyle怎么用?Java Representer.setDefaultFlowStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.yaml.snakeyaml.representer.Representer
的用法示例。
在下文中一共展示了Representer.setDefaultFlowStyle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Yaml
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
/**
* Create Yaml instance. It is safe to create a few instances and use them
* in different Threads.
*
* @param constructor
* BaseConstructor to construct incoming documents
* @param representer
* Representer to emit outgoing objects
* @param dumperOptions
* DumperOptions to configure outgoing objects
* @param resolver
* Resolver to detect implicit type
*/
public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions,
Resolver resolver) {
if (!constructor.isExplicitPropertyUtils()) {
constructor.setPropertyUtils(representer.getPropertyUtils());
} else if (!representer.isExplicitPropertyUtils()) {
representer.setPropertyUtils(constructor.getPropertyUtils());
}
this.constructor = constructor;
representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle());
representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle());
representer.getPropertyUtils().setAllowReadOnlyProperties(
dumperOptions.isAllowReadOnlyProperties());
representer.setTimeZone(dumperOptions.getTimeZone());
this.representer = representer;
this.dumperOptions = dumperOptions;
this.resolver = resolver;
this.name = "Yaml:" + System.identityHashCode(this);
}
示例2: Yaml
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
/**
* Create Yaml instance. It is safe to create a few instances and use them
* in different Threads.
*
* @param constructor
* BaseConstructor to construct incoming documents
* @param representer
* Representer to emit outgoing objects
* @param dumperOptions
* DumperOptions to configure outgoing objects
* @param loadingConfig
* LoadingConfig to control load behavior
* @param resolver
* Resolver to detect implicit type
*/
public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions,
LoaderOptions loadingConfig, Resolver resolver) {
if (!constructor.isExplicitPropertyUtils()) {
constructor.setPropertyUtils(representer.getPropertyUtils());
} else if (!representer.isExplicitPropertyUtils()) {
representer.setPropertyUtils(constructor.getPropertyUtils());
}
this.constructor = constructor;
this.constructor.setAllowDuplicateKeys(loadingConfig.isAllowDuplicateKeys());
if (dumperOptions.getIndent() <= dumperOptions.getIndicatorIndent()) {
throw new YAMLException("Indicator indent must be smaller then indent.");
}
representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle());
representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle());
representer.getPropertyUtils()
.setAllowReadOnlyProperties(dumperOptions.isAllowReadOnlyProperties());
representer.setTimeZone(dumperOptions.getTimeZone());
this.representer = representer;
this.dumperOptions = dumperOptions;
this.loadingConfig = loadingConfig;
this.resolver = resolver;
this.name = "Yaml:" + System.identityHashCode(this);
}
示例3: Yaml
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
/**
* Create Yaml instance. It is safe to create a few instances and use them
* in different Threads.
*
* @param constructor
* BaseConstructor to construct incoming documents
* @param representer
* Representer to emit outgoing objects
* @param dumperOptions
* DumperOptions to configure outgoing objects
* @param resolver
* Resolver to detect implicit type
*/
public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions,
Resolver resolver) {
if (!constructor.isExplicitPropertyUtils()) {
constructor.setPropertyUtils(representer.getPropertyUtils());
} else if (!representer.isExplicitPropertyUtils()) {
representer.setPropertyUtils(constructor.getPropertyUtils());
}
this.constructor = constructor;
representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle());
representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle());
representer.getPropertyUtils().setAllowReadOnlyProperties(
dumperOptions.isAllowReadOnlyProperties());
representer.setTimeZone(dumperOptions.getTimeZone());
this.representer = representer;
this.dumperOptions = dumperOptions;
this.resolver = resolver;
this.name = "Yaml:" + System.identityHashCode(this);
}
示例4: testWithBlockStyle
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
public void testWithBlockStyle() throws Exception {
Map<String, Map<String, Object>> rootMap = new HashMap<String, Map<String, Object>>();
Map<String, Object> enclosedMap = new HashMap<String, Object>();
enclosedMap.put("world", "test");
rootMap.put("test", enclosedMap);
DumperOptions yamlOptions = new DumperOptions();
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Representer yamlRepresenter = new Representer();
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(yamlRepresenter, yamlOptions);
String output = yaml.dump(rootMap);
assertEquals("test:\n world: test\n", output);
}
示例5: Yaml
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
/**
* Create Yaml instance. It is safe to create a few instances and use them in different Threads.
*
* @param constructor
* BaseConstructor to construct incoming documents
* @param representer
* Representer to emit outgoing objects
* @param dumperOptions
* DumperOptions to configure outgoing objects
* @param resolver
* Resolver to detect implicit type
*/
public Yaml(final BaseConstructor constructor, final Representer representer, final DumperOptions dumperOptions, final Resolver resolver) {
if (!constructor.isExplicitPropertyUtils()) {
constructor.setPropertyUtils(representer.getPropertyUtils());
} else if (!representer.isExplicitPropertyUtils()) {
representer.setPropertyUtils(constructor.getPropertyUtils());
}
this.constructor = constructor;
representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle());
representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle());
representer.getPropertyUtils().setAllowReadOnlyProperties(dumperOptions.isAllowReadOnlyProperties());
representer.setTimeZone(dumperOptions.getTimeZone());
this.representer = representer;
this.dumperOptions = dumperOptions;
this.resolver = resolver;
this.name = "Yaml:" + System.identityHashCode(this);
}
示例6: YamlConfigLoader
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
private YamlConfigLoader(@NotNull Builder builder, final DumperOptions options, boolean doComments) {
super(builder, new CommentHandler[] {CommentHandlers.HASH});
this.commentsEnabled = doComments; // TODO fix broken comment instrumenter D:
this.options = options;
representer = new Representer();
representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
this.yaml = new ThreadLocal<Yaml>() {
@Override
protected Yaml initialValue() {
return new Yaml(representer, options);
}
};
}
示例7: setupDumper
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
private static void setupDumper() {
options = new DumperOptions();
representer = new Representer();
options.setIndent(2);
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setAllowUnicode(Charset.defaultCharset().name().contains("UTF"));
representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
}
示例8: YAMLProcessor
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
public YAMLProcessor(File file, boolean writeDefaults, YAMLFormat format) {
super(new HashMap<String, Object>(), writeDefaults);
DumperOptions options = new DumperOptions();
options.setIndent(4);
options.setDefaultFlowStyle(format.getStyle());
Representer representer = new Representer();
representer.setDefaultFlowStyle(format.getStyle());
yaml = new Yaml(new SafeConstructor(), representer, options);
this.file = file;
}