boolean nillable )
throws SerializationException
{
if ( obj instanceof MessageElement )
{
MessageElement element = (MessageElement) obj;
if ( ( name == null ) || name.equals( element.getQName( ) ) )
{
return element;
}
else
{
throw new SerializationException( "notImplemented" );
}
}
else if ( obj instanceof Element )
{
Element element = (Element) obj;
if ( ( name == null )
|| ( name.getLocalPart( ).equals( element.getLocalName( ) )
&& name.getNamespaceURI( ).equals( element.getNamespaceURI( ) ) ) )
{
return new MessageElement( (Element) obj );
}
else
{
throw new SerializationException( "notImplemented" );
}
}
if ( name == null )
{
throw new IllegalArgumentException( "nullArgument:name" );
}
MessageElement messageElement = new MessageElement( );
messageElement.setQName( name );
try
{
messageElement.setObjectValue( obj );
}
catch ( Exception e )
{
throw new SerializationException( "genericSerializationError", e );
}
if ( ( obj == null ) && nillable )
{
try
{
messageElement.addAttribute( Constants.NS_PREFIX_SCHEMA_XSI, Constants.URI_DEFAULT_SCHEMA_XSI, "nil",
"true" );
}
catch ( Exception e )
{
throw new SerializationException( "genericSerializationError", e );