All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jdcloud.Poi.model.transform.PoiPortrailRegionSynResponseUnmarshaller Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2018 JDCLOUD.COM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * OpenAPI spec version: 1.0
 * 
 *
 * NOTE: This class is auto generated by the jdcloud code generator program.
 */

package net.jdcloud.Poi.model.transform;

import javax.xml.bind.JAXBException;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.jdcloud.sdk.apim.JdcloudSdkException;
import com.jdcloud.sdk.apim.http.ContentType;
import com.jdcloud.sdk.apim.service.JdcloudUnmarshaller;
import com.jdcloud.sdk.apim.utils.ConvertUtils;
import net.jdcloud.Poi.model.poiportrailregionsyn.Result;
import net.jdcloud.Poi.model.PoiPortrailRegionSynResponse;

public class PoiPortrailRegionSynResponseUnmarshaller implements JdcloudUnmarshaller {

    public final static Feature[] FEATURES = { Feature.AutoCloseSource, Feature.UseBigDecimal,
            Feature.AllowUnQuotedFieldNames, Feature.AllowSingleQuotes, Feature.AllowArbitraryCommas,
            Feature.AllowArbitraryCommas, Feature.SortFeidFastMatch, Feature.IgnoreNotMatch };

    public PoiPortrailRegionSynResponse unmarshall(String content, ContentType contentType) {
        PoiPortrailRegionSynResponse poiPortrailRegionSynResponse = new PoiPortrailRegionSynResponse();
        if(contentType == ContentType.APPLICATION_XML || contentType == ContentType.TEXT_XML) {

            try {
                poiPortrailRegionSynResponse.setResult(ConvertUtils.xmlToBean(content, Result.class));
            } catch (Exception e) {
                throw new JdcloudSdkException(e);
            }

        } else {
            poiPortrailRegionSynResponse.setResult(JSON.parseObject(content, Result.class, FEATURES));}
        return poiPortrailRegionSynResponse;
    }

    private static PoiPortrailRegionSynResponseUnmarshaller instance;

    public static PoiPortrailRegionSynResponseUnmarshaller getInstance() {
        if (instance == null)
            instance = new PoiPortrailRegionSynResponseUnmarshaller();
        return instance;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy