org.yaml.snakeyaml.representer.Represent Java Examples

The following examples show how to use org.yaml.snakeyaml.representer.Represent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YamlConfiguration.java    From CloudNet with Apache License 2.0 6 votes vote down vote up
@Override
protected Yaml initialValue() {
    Representer representer = new Representer() {
        {
            representers.put(Configuration.class, new Represent() {
                @Override
                public Node representData(Object data) {
                    return represent(((Configuration) data).self);
                }
            });
        }
    };

    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);

    return new Yaml(new Constructor(), representer, options);
}
 
Example #2
Source File: Representer.java    From Diorite with MIT License 6 votes vote down vote up
public Representer()
{
    this.nullRepresenter = new RepresentNull(this);
    this.representers.put(String.class, new RepresentString(this));
    this.representers.put(Boolean.class, new RepresentBoolean(this));
    this.representers.put(Character.class, new RepresentString(this));
    this.representers.put(UUID.class, new RepresentUuid(this));
    this.representers.put(byte[].class, new RepresentByteArray(this));

    Represent primitiveArray = new RepresentPrimitiveArray(this);
    this.representers.put(short[].class, primitiveArray);
    this.representers.put(int[].class, primitiveArray);
    this.representers.put(long[].class, primitiveArray);
    this.representers.put(float[].class, primitiveArray);
    this.representers.put(double[].class, primitiveArray);
    this.representers.put(char[].class, primitiveArray);
    this.representers.put(boolean[].class, primitiveArray);

    this.classTags = new HashMap<>(10);


    this.representers.put(null, new RepresentJavaBean(this));
}
 
Example #3
Source File: SkriptYamlRepresenter.java    From skript-yaml with MIT License 5 votes vote down vote up
public SkriptYamlRepresenter() {
	this.nullRepresenter = new Represent() {
		@Override
		public Node representData(Object o) {
			return representScalar(Tag.NULL, "");
		}
	};

	this.representers.put(SkriptClass.class, new RepresentSkriptClass());
	this.representers.put(ItemType.class, new RepresentSkriptItemType());
	this.representers.put(Slot.class, new RepresentSkriptSlot());
	this.representers.put(Date.class, new RepresentSkriptDate());
	this.representers.put(Time.class, new RepresentSkriptTime());
	this.representers.put(Timespan.class, new RepresentSkriptTimespan());
	this.representers.put(Color.class, new RepresentSkriptColor());
	this.representers.put(WeatherType.class, new RepresentSkriptWeather());

	this.representers.put(Vector.class, new RepresentVector());
	this.representers.put(Location.class, new RepresentLocation());

	this.multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable());

	for (Class<?> c : representers.keySet()) {
		if (c != null) {
			String name = c.getSimpleName();
			if (!representedClasses.contains(name))
				representedClasses.add(name);
		}
	}
}
 
Example #4
Source File: ConfigurationRepresenter.java    From ServerListPlus with GNU General Public License v3.0 5 votes vote down vote up
public ConfigurationRepresenter() {
    // Remove existing representers so we can add something in the beginning
    Map<Class<?>, Represent> backup = new LinkedHashMap<>(multiRepresenters);
    multiRepresenters.clear();

    // Insert ConfigurationSerializable first
    multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable());

    // Add back all other representers
    multiRepresenters.putAll(backup);
}
 
Example #5
Source File: Representer.java    From Diorite with MIT License 4 votes vote down vote up
public void addRepresenter(Class<?> type, Represent represent)
{
    this.representers.put(type, represent);
    LinkedHashMap<Class<?>, Represent> multiRepresenters = (LinkedHashMap<Class<?>, Represent>) this.multiRepresenters;
    multiRepresenters.put(type, represent);
}