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

org.mentalog.encoder.CharSequenceEncoder Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package org.mentalog.encoder;

import java.nio.ByteBuffer;

public class CharSequenceEncoder implements Encoder {
	
	@Override
	public boolean encode(Object obj, ByteBuffer bb, int varargsPos, int varargsLen) {
		
		if (obj instanceof CharSequence) {
			CharSequence s = (CharSequence) obj;
			
			int len = s.length();
			for (int i = 0; i < len; i++) {
				bb.put((byte) s.charAt(i));
			}
			
			return true;
		}
		
		return false;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy