telosys
Blame | Last modification | View Log | RSS feed
package org.objectweb.telosys.rpl.xml.mapper;
import java.io.PrintWriter;
import org.objectweb.telosys.common.val.FloatValue;
import org.objectweb.telosys.rpl.xml.IXmlWrapper;
import org.objectweb.telosys.rpl.xml.XmlWrapperAncestor;
/**
* XML mapper implementation for FloatValue
*
* @author TELOSYS GENERATOR
*
*/
public class FloatValueMapper extends XmlWrapperAncestor implements IXmlWrapper
{
/*
* Default constructor
*/
public FloatValueMapper()
{
super(FloatValue.class);
}
//-----------------------------------------------------------------------------------
/*
* Interface Implementation
* @see org.objectweb.telosys.rpl.xml.IXmlWrapper
*/
public Object createBean()
{
return new FloatValue() ;
}
//-----------------------------------------------------------------------------------
/*
* Interface Implementation
* @see org.telosys.xml.IXmlWrapper
* Set the values received in XML format
* ( the "XML entities" are processed by the parser => no conversion needed )
*/
public void setXmlFieldValue(Object oBean, String sName, String sValue)
{
if (oBean != null)
{
if (oBean instanceof FloatValue)
{
FloatValue vo = (FloatValue) oBean;
if (sName.equals( "value" ))
{
vo.setValue( getFloat(sName,sValue,0) );
return;
}
//--- Unknown attribute
throwException("unknown attribute '" + sName + "' in setXmlFieldValue(" + sName + "," + sValue + ")");
}
else
{
throwException("bean class = '" + oBean.getClass().getName() + "' ( FloatValue expected )");
}
}
else
{
throwException("bean is null");
}
}
//-----------------------------------------------------------------------------------
/*
* Interface Implementation
* @see org.telosys.xml.IXmlWrapper
* Serialized the bean in XML format
*/
public void toXml(PrintWriter out, Object oBean, String sTagName)
{
if (oBean != null)
{
if (oBean instanceof FloatValue)
{
FloatValue vo = (FloatValue) oBean ;
out.print("<" + sTagName + " ");
out.print( "value=\"" + vo.getValue() + "\" ");
out.println("/>");
}
else
{
throwException("bean class = '" + oBean.getClass().getName() + "' ( FloatValue expected )");
}
}
else
{
out.print("<!-- " + sTagName + " = null -->");
}
}
//-----------------------------------------------------------------------------------
}