本文整理汇总了Java中org.yaml.snakeyaml.representer.Representer.setPropertyUtils方法的典型用法代码示例。如果您正苦于以下问题:Java Representer.setPropertyUtils方法的具体用法?Java Representer.setPropertyUtils怎么用?Java Representer.setPropertyUtils使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.yaml.snakeyaml.representer.Representer
的用法示例。
在下文中一共展示了Representer.setPropertyUtils方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: newYaml
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
public static Yaml newYaml() {
PropertyUtils propertyUtils = new AdvancedPropertyUtils();
propertyUtils.setSkipMissingProperties(true);
Constructor constructor = new Constructor(Federations.class);
TypeDescription federationDescription = new TypeDescription(Federations.class);
federationDescription.putListPropertyType("federatedMetaStores", FederatedMetaStore.class);
constructor.addTypeDescription(federationDescription);
constructor.setPropertyUtils(propertyUtils);
Representer representer = new AdvancedRepresenter();
representer.setPropertyUtils(new FieldOrderPropertyUtils());
representer.addClassTag(Federations.class, Tag.MAP);
representer.addClassTag(AbstractMetaStore.class, Tag.MAP);
representer.addClassTag(WaggleDanceConfiguration.class, Tag.MAP);
representer.addClassTag(YamlStorageConfiguration.class, Tag.MAP);
representer.addClassTag(GraphiteConfiguration.class, Tag.MAP);
DumperOptions dumperOptions = new DumperOptions();
dumperOptions.setIndent(2);
dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK);
return new Yaml(constructor, representer, dumperOptions);
}
示例4: testErrorMessage
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
public void testErrorMessage() throws Exception {
BeanA1 b = new BeanA1();
b.setId(2l);
b.setName("name1");
Constructor c = new Constructor();
Representer r = new Representer();
PropertyUtils pu = new PropertyUtils();
c.setPropertyUtils(pu);
r.setPropertyUtils(pu);
pu.getProperties(BeanA1.class, BeanAccess.FIELD);
Yaml yaml = new Yaml(c, r);
// yaml.setBeanAccess(BeanAccess.FIELD);
String dump = yaml.dump(b);
BeanA1 b2 = (BeanA1) yaml.load(dump);
assertEquals(b.getId(), b2.getId());
assertEquals(b.getName(), b2.getName());
}
示例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(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);
}
示例6: 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);
}
示例7: testYamlRepresenterWithPropertyUtils
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
public void testYamlRepresenterWithPropertyUtils() {
Representer representer2 = new Representer();
PropertyUtils pu = new PropertyUtils();
representer2.setPropertyUtils(pu);
Yaml yaml = new Yaml(representer2);
assertSame(pu, yaml.constructor.getPropertyUtils());
assertSame(pu, yaml.representer.getPropertyUtils());
}
示例8: testYamlConstructorANDRepresenterWithPropertyUtils
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
@Test
public void testYamlConstructorANDRepresenterWithPropertyUtils() {
Constructor constructor = new Constructor();
PropertyUtils pu_c = new PropertyUtils();
constructor.setPropertyUtils(pu_c);
Representer representer = new Representer();
PropertyUtils pu_r = new PropertyUtils();
representer.setPropertyUtils(pu_r);
Yaml yaml = new Yaml(constructor, representer);
assertSame(pu_c, yaml.constructor.getPropertyUtils());
assertSame(pu_r, yaml.representer.getPropertyUtils());
}
示例9: testReversedOrder
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
public void testReversedOrder() {
Representer repr = new Representer();
repr.setPropertyUtils(new ReversedPropertyUtils());
Yaml yaml = new Yaml(repr);
String output = yaml.dump(getBean());
// System.out.println(output);
assertEquals(Util.getLocalResource("issues/issue59-1.yaml"), output);
}
示例10: testUnsorted
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
public void testUnsorted() {
Representer repr = new Representer();
repr.setPropertyUtils(new UnsortedPropertyUtils());
Yaml yaml = new Yaml(repr);
String output = yaml.dump(getBean());
// System.out.println(output);
assertEquals(Util.getLocalResource("issues/issue59-2.yaml"), output);
}
示例11: createYaml
import org.yaml.snakeyaml.representer.Representer; //导入方法依赖的package包/类
/**
* Creates and returns a new {@link Yaml} instance for (optional)
* use in writing {@link ConfigOrBuilder} and {@link
* MetadataOrBuilder} objects.
*
* <p>This method never returns {@code null}.</p>
*
* <p>Overrides of this method must not return {@code null}.</p>
*
* <p>Behavior is undefined if overrides of this method interact
* with other methods defined by this class.</p>
*
* @return a non-{@code null} {@link Yaml} instance
*/
protected Yaml createYaml() {
final Representer representer = new TerseRepresenter();
representer.setPropertyUtils(new CustomPropertyUtils());
final DumperOptions options = new DumperOptions();
options.setAllowReadOnlyProperties(true);
return new Yaml(new Constructor(), representer, options);
}