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

com.rathravane.till.nv.impl.nvBaseWriteable Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
/*
 *	Copyright 2006-2012, Rathravane LLC
 *
 *	Licensed under the Apache License, Version 2.0 (the "License");
 *	you may not use this file except in compliance with the License.
 *	You may obtain a copy of the License at
 *	
 *	http://www.apache.org/licenses/LICENSE-2.0
 *	
 *	Unless required by applicable law or agreed to in writing, software
 *	distributed under the License is distributed on an "AS IS" BASIS,
 *	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *	See the License for the specific language governing permissions and
 *	limitations under the License.
 */
package com.rathravane.till.nv.impl;

import java.util.Map;

import com.rathravane.till.data.rrConvertor;
import com.rathravane.till.nv.rrNvWriteable;

public abstract class nvBaseWriteable extends nvBaseReadable implements rrNvWriteable
{
	@Override
	public void set ( String key, char value )
	{
		set ( key, "" + value );
	}

	@Override
	public void set ( String key, boolean value )
	{
		set ( key, new Boolean ( value ).toString () );
	}

	@Override
	public void set ( String key, int value )
	{
		set ( key, new Integer ( value ).toString () );
	}

	@Override
	public void set ( String key, long value )
	{
		set ( key, new Long ( value ).toString () );
	}

	@Override
	public void set ( String key, double value )
	{
		set ( key, new Double ( value ).toString () );
	}

	@Override
	public void set ( String key, byte[] value )
	{
		set ( key, rrConvertor.bytesToHex ( value ) );
	}

	@Override
	public void set ( String key, byte[] value, int offset, int length )
	{
		set ( key, rrConvertor.bytesToHex ( value, offset, length ) );
	}

	@Override
	public void set ( String key, String[] values )
	{
		final StringBuffer sb = new StringBuffer ();
		boolean some = false;
		for ( String val : values )
		{
			if ( some ) sb.append ( "," );
			sb.append ( val );
			some = true;
		}
		set ( key, sb.toString () );
	}

	@Override
	public void set ( Map map )
	{
		for ( Map.Entry e : map.entrySet () )
		{
			set ( e.getKey (), e.getValue () );
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy