/** * {@inheritDoc} */ @Override public String toMarshaled( Object aObject ) throws MarshalException { // if ( aObject instanceof PathMap<?> ) { // aObject = ((PathMap<?>) aObject).toDataStructure(); // } try { // String theYAML = _gson.toYAML( aObject ); String theYaml = _mapper.writeValueAsString( aObject ); return theYaml; } catch ( Exception e ) { throw new MarshalException( "A problem occurred marshaling an object of type <" + aObject.getClass().getName() + ">.", e ); } }
/** * {@inheritDoc} */ @Override public String toMarshaled( Object aObject ) throws MarshalException { // if ( aObject instanceof PathMap<?> ) { // aObject = ((PathMap<?>) aObject).toDataStructure(); // } try { String theJson = _mapper.writeValueAsString( aObject ); return theJson; } catch ( Exception e ) { throw new MarshalException( "A problem occurred marshaling an object of type <" + aObject.getClass().getName() + ">.", e ); } }
/** * This method expects an instance of (sub-)type {@link Map} of generic type * {@link String} (key) and {@link List} containing {@link String} instances * (value) as argument. Also supported is the derived {@link FormFields} * type. * * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public String toMarshaled( Object aObject ) throws MarshalException { try { if ( aObject instanceof FormFields ) { return ((FormFields) aObject).toBodyFormFields(); } else if ( aObject instanceof Map<?, ?> ) { FormFields theFormFields = new FormFieldsImpl(); theFormFields.putAll( (Map<String, List<String>>) aObject ); return theFormFields.toBodyFormFields(); } throw new UnmarshalException( "Cannot marshal HTTP Form-Fields from <" + aObject + "> to type <" + String.class.getName() + "> as this factory can only marshal HTTP Form-Fields of (sub-)type \"Map<String, List<String>\"." ); } catch ( Exception e ) { throw new MarshalException( "A problem occurred marshaling an object of type <" + aObject.getClass().getName() + ">.", e ); } }