Java 类org.yaml.snakeyaml.introspector.PropertyUtils 实例源码
项目:marathonv5
文件:ObjectMapItem.java
private Object loadYaml(File omapfile) throws IOException {
FileReader reader = new FileReader(omapfile);
try {
Constructor constructor = new Constructor();
PropertyUtils putils = new PropertyUtils();
putils.setSkipMissingProperties(true);
constructor.setPropertyUtils(putils);
Yaml yaml = new Yaml(constructor);
return yaml.load(reader);
} catch (Throwable t) {
throw new RuntimeException("Error loading yaml from: " + omapfile.getAbsolutePath() + "\n" + t.getMessage(), t);
} finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
项目:marathonv5
文件:OMapContainer.java
private Object loadYaml(File file) throws FileNotFoundException {
FileReader reader = new FileReader(file);
try {
Constructor constructor = new Constructor();
PropertyUtils putils = new PropertyUtils();
putils.setSkipMissingProperties(true);
constructor.setPropertyUtils(putils);
Yaml yaml = new Yaml(constructor);
return yaml.load(reader);
} catch (Throwable t) {
throw new RuntimeException("Error loading yaml from: " + file.getAbsolutePath() + "\n" + t.getMessage(), t);
} finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
项目:waggle-dance
文件:YamlFactory.java
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);
}
项目:snake-yaml
文件:AbstractBeanTest.java
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());
}
项目:snakeyaml
文件:AbstractBeanTest.java
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());
}
项目:AndroidApktool
文件:MetaInfo.java
private static Yaml getYaml() {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
StringExRepresent representer = new StringExRepresent();
PropertyUtils propertyUtils = representer.getPropertyUtils();
propertyUtils.setSkipMissingProperties(true);
return new Yaml(new StringExConstructor(), representer, options);
}
项目:coteafs-config
文件:ConfigLoader.java
/**
* @author wasiq.bhamla
* @since 09-Jun-2017 5:00:19 PM
* @param cls
*/
@SuppressWarnings ("unchecked")
private <T> T loadSettings (final Class <T> cls) {
final String path = System.getProperty (this.key, this.value);
try (final InputStream in = getClass ().getResourceAsStream (path)) {
if (in != null) {
final Constructor ctor = new Constructor (cls);
final PropertyUtils propertyUtils = new PropertyUtils () {
@Override
public Property getProperty (final Class <? extends Object> obj, final String name) {
String propertyName = name;
if (propertyName.indexOf ('_') > -1) {
propertyName = CaseFormat.LOWER_UNDERSCORE.to (CaseFormat.LOWER_CAMEL, propertyName);
}
return super.getProperty (obj, propertyName);
}
};
ctor.setPropertyUtils (propertyUtils);
final Yaml yaml = new Yaml (ctor);
return (T) yaml.load (in);
}
}
catch (final Exception e) {
fail (CoteafsConfigNotLoadedError.class, "Error loading config file.", e);
}
final String MSG = "%s not found.";
fail (CoteafsConfigFileNotFoundError.class, String.format (MSG, path));
return null;
}
项目:pl
文件:YamlUtil.java
public static Yaml newYaml() {
Representer representer = new Representer();
PropertyUtils propertyUtils = representer.getPropertyUtils();
propertyUtils.setSkipMissingProperties(true);
propertyUtils.setBeanAccess(BeanAccess.FIELD);
propertyUtils.setAllowReadOnlyProperties(true);
return new Yaml(representer);
}
项目:snake-yaml
文件:PropertyUtilsSharingTest.java
public void testYamlConstructorWithPropertyUtils() {
Constructor constructor1 = new Constructor();
PropertyUtils pu = new PropertyUtils();
constructor1.setPropertyUtils(pu);
Yaml yaml = new Yaml(constructor1);
assertSame(pu, yaml.constructor.getPropertyUtils());
assertSame(pu, yaml.representer.getPropertyUtils());
}
项目:snake-yaml
文件:PropertyUtilsSharingTest.java
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());
}
项目:snake-yaml
文件:PropertyUtilsSharingTest.java
@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());
}
项目:Waterfall-Old
文件:PluginManager.java
public PluginManager(ProxyServer proxy)
{
this.proxy = proxy;
// Ignore unknown entries in the plugin descriptions
Constructor yamlConstructor = new Constructor();
PropertyUtils propertyUtils = yamlConstructor.getPropertyUtils();
propertyUtils.setSkipMissingProperties( true );
yamlConstructor.setPropertyUtils( propertyUtils );
yaml = new Yaml( yamlConstructor );
eventBus = new EventBus( proxy.getLogger() );
}
项目:UniversalProxy
文件:PluginManager.java
public PluginManager(ProxyServer proxy)
{
this.proxy = proxy;
// Ignore unknown entries in the plugin descriptions
Constructor yamlConstructor = new Constructor();
PropertyUtils propertyUtils = yamlConstructor.getPropertyUtils();
propertyUtils.setSkipMissingProperties( true );
yamlConstructor.setPropertyUtils( propertyUtils );
yaml = new Yaml( yamlConstructor );
eventBus = new EventBus( proxy.getLogger() );
}
项目:snakeyaml
文件:PropertyUtilsSharingTest.java
public void testYamlConstructorWithPropertyUtils() {
Constructor constructor1 = new Constructor();
PropertyUtils pu = new PropertyUtils();
constructor1.setPropertyUtils(pu);
Yaml yaml = new Yaml(constructor1);
assertSame(pu, yaml.constructor.getPropertyUtils());
assertSame(pu, yaml.representer.getPropertyUtils());
}
项目:snakeyaml
文件:PropertyUtilsSharingTest.java
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());
}
项目:snakeyaml
文件:PropertyUtilsSharingTest.java
@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());
}
项目:apktool-android
文件:MetaInfo.java
private static Yaml getYaml() {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
StringExRepresent representer = new StringExRepresent();
PropertyUtils propertyUtils = representer.getPropertyUtils();
propertyUtils.setSkipMissingProperties(true);
return new Yaml(new StringExConstructor(), representer, options);
}
项目:FreeBungeeChat
文件:CustomClassLoaderYamlConfiguration.java
protected Yaml initialValue() {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
CustomClassLoaderConstructor constructor = new CustomClassLoaderConstructor(getClass().getClassLoader());
PropertyUtils propertyUtils = constructor.getPropertyUtils();
propertyUtils.setSkipMissingProperties(true);
constructor.setPropertyUtils(propertyUtils);
return new Yaml(constructor, new Representer(), options);
}
项目:AndroidApktool
文件:BaseRepresenter.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
this.explicitPropertyUtils = true;
}
项目:AndroidApktool
文件:BaseConstructor.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
explicitPropertyUtils = true;
}
项目:5zig-TIMV-Plugin
文件:BaseRepresenter.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
this.explicitPropertyUtils = true;
}
项目:5zig-TIMV-Plugin
文件:BaseConstructor.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
explicitPropertyUtils = true;
}
项目:snake-yaml
文件:BaseRepresenter.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
this.explicitPropertyUtils = true;
}
项目:snake-yaml
文件:BaseConstructor.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
explicitPropertyUtils = true;
}
项目:SubServers-2
文件:BaseRepresenter.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
this.explicitPropertyUtils = true;
}
项目:SubServers-2
文件:BaseConstructor.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
explicitPropertyUtils = true;
}
项目:snakeyaml
文件:BaseRepresenter.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
this.explicitPropertyUtils = true;
}
项目:snakeyaml
文件:BaseConstructor.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
explicitPropertyUtils = true;
}
项目:TestTheTeacher
文件:BaseRepresenter.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
this.explicitPropertyUtils = true;
}
项目:TestTheTeacher
文件:BaseConstructor.java
public void setPropertyUtils(PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
explicitPropertyUtils = true;
}
项目:org.openntf.domino
文件:BaseRepresenter.java
public void setPropertyUtils(final PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
this.explicitPropertyUtils = true;
}
项目:org.openntf.domino
文件:BaseConstructor.java
public void setPropertyUtils(final PropertyUtils propertyUtils) {
this.propertyUtils = propertyUtils;
explicitPropertyUtils = true;
}