All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.lib.json.CharacterHandler Maven / Gradle / Ivy

Go to download

Provides a mapping from Event Admin events to Javascript Server Side Events (SSE). This bundle registers under /sse/1, the remaining path is treated as the topic. It will then send all matching events to the browser through SSE. The type of the event is org.osgi.service.eventadmin;topic=%s, the data payload is a JSON representation of the event properties.

The newest version!
package aQute.lib.json;

import java.lang.reflect.Type;
import java.util.Map;

public class CharacterHandler extends Handler {

	@Override
	public void encode(Encoder app, Object object, Map visited) throws Exception {
		Character c = (Character) object;
		int v = c.charValue();
		app.append(v + "");
	}

	@Override
	public Object decode(Decoder dec, boolean s) {
		return s ? 't' : 'f';
	}

	@Override
	public Object decode(Decoder dec, String s) {
		return (char) Integer.parseInt(s);
	}

	@Override
	public Object decode(Decoder dec, Number s) {
		return (char) s.shortValue();
	}

	@Override
	public Object decode(Decoder dec) {
		return 0;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy