/******************************************************************************* * Copyright (c) 2010-2014 SAP AG and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * SAP AG - initial API and implementation *******************************************************************************/ package org.eclipse.skalli.core.rest.resources; import java.io.IOException; import org.eclipse.skalli.services.extension.rest.RestConverterBase; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; class PropertyUpdateConverter extends RestConverterBase<PropertyUpdate> { public static final String API_VERSION = "1.0"; //$NON-NLS-1$ public static final String NAMESPACE = "http://www.eclipse.org/skalli/2010/API"; //$NON-NLS-1$ @Override protected void marshal(PropertyUpdate obj) throws IOException { } public PropertyUpdateConverter() { super(PropertyUpdate.class, "dataChangePattern"); //$NON-NLS-1$ } @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { PropertyUpdate dataChange = new PropertyUpdate(); while (reader.hasMoreChildren()) { reader.moveDown(); String field = reader.getNodeName(); String value = reader.getValue(); if (PropertyUpdate.PROPERTY_TEMPLATE.equals(field)) { dataChange.setTemplate(value); } } return dataChange; } @Override public String getApiVersion() { return API_VERSION; } @Override public String getNamespace() { return NAMESPACE; } @Override public String getXsdFileName() { return "property-update.xsd";//$NON-NLS-1$ } @Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { //not needed } }