本文整理匯總了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);
}