001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.json.jabsorb.serializer;
016    
017    import org.jabsorb.JSONSerializer;
018    import org.jabsorb.serializer.ObjectMatch;
019    import org.jabsorb.serializer.SerializerState;
020    import org.jabsorb.serializer.UnmarshallException;
021    
022    /**
023     * @author Tomas Polesovsky
024     */
025    public class LiferayJSONSerializer extends JSONSerializer {
026    
027            @Override
028            public ObjectMatch tryUnmarshall(
029                            SerializerState serializerState,
030                            @SuppressWarnings("rawtypes") Class clazz, Object json)
031                    throws UnmarshallException {
032    
033                    if (!(serializerState instanceof LiferaySerializerState)) {
034                            serializerState = new LiferaySerializerState();
035                    }
036    
037                    return super.tryUnmarshall(serializerState, clazz, json);
038            }
039    
040            @Override
041            public Object unmarshall(
042                            SerializerState serializerState,
043                            @SuppressWarnings("rawtypes") Class clazz, Object json)
044                    throws UnmarshallException {
045    
046                    if (!(serializerState instanceof LiferaySerializerState)) {
047                            serializerState = new LiferaySerializerState();
048                    }
049    
050                    return super.unmarshall(serializerState, clazz, json);
051            }
052    
053    }