Search in sources :

Example 1 with Img

use of com.xrtb.nativeads.creative.Img in project XRTB by benmfaul.

the class Impression method doNative.

/**
	 * Handle the native impression
	 */
void doNative() {
    JsonNode node = rnode.get("native");
    if (node != null) {
        JsonNode child = null;
        nativead = true;
        nativePart = new NativePart();
        child = node.path("layout");
        if (child != null) {
            nativePart.layout = child.intValue();
        }
        if (node.path("assets") instanceof MissingNode == false) {
            ArrayNode array = (ArrayNode) node.path("assets");
            for (JsonNode x : array) {
                child = x.path("title");
                if (child instanceof MissingNode == false) {
                    nativePart.title = new Title();
                    nativePart.title.len = child.path("len").intValue();
                    if (x.path("required") instanceof MissingNode == false) {
                        nativePart.title.required = x.path("required").intValue();
                    }
                }
                child = x.path("img");
                if (child instanceof MissingNode == false) {
                    nativePart.img = new Img();
                    nativePart.img.w = child.path("w").intValue();
                    nativePart.img.h = child.path("h").intValue();
                    if (x.path("required") instanceof MissingNode == false) {
                        nativePart.img.required = x.path("required").intValue();
                    }
                    if (child.path("mimes") instanceof MissingNode == false) {
                        if (child.path("mimes") instanceof TextNode) {
                            nativePart.img.mimes.add(child.get("mimes").asText());
                        } else {
                            array = (ArrayNode) child.path("mimes");
                            for (JsonNode nx : array) {
                                nativePart.img.mimes.add(nx.textValue());
                            }
                        }
                    }
                }
                child = x.path("video");
                if (child instanceof MissingNode == false) {
                    nativePart.video = new NativeVideo();
                    nativePart.video.linearity = child.path("linearity").intValue();
                    nativePart.video.minduration = child.path("minduration").intValue();
                    nativePart.video.maxduration = child.path("maxduration").intValue();
                    if (x.path("required") instanceof MissingNode == false) {
                        nativePart.video.required = x.path("required").intValue();
                    }
                    if (child.path("mimes") instanceof MissingNode == false) {
                        array = (ArrayNode) child.path("protocols");
                        for (JsonNode nx : array) {
                            nativePart.video.protocols.add(nx.textValue());
                        }
                    }
                }
                child = x.path("data");
                if (child instanceof MissingNode == false) {
                    Data data = new Data();
                    if (x.path("required") instanceof MissingNode == false) {
                        data.required = x.path("required").intValue();
                    }
                    if (child.path("len") instanceof MissingNode == false) {
                        data.len = child.path("len").intValue();
                    }
                    data.type = child.path("type").intValue();
                    nativePart.data.add(data);
                }
            }
        }
    }
}
Also used : NativeVideo(com.xrtb.nativeads.creative.NativeVideo) Img(com.xrtb.nativeads.creative.Img) Title(com.xrtb.nativeads.creative.Title) JsonNode(com.fasterxml.jackson.databind.JsonNode) MissingNode(com.fasterxml.jackson.databind.node.MissingNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) Data(com.xrtb.nativeads.creative.Data) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 MissingNode (com.fasterxml.jackson.databind.node.MissingNode)1 TextNode (com.fasterxml.jackson.databind.node.TextNode)1 Data (com.xrtb.nativeads.creative.Data)1 Img (com.xrtb.nativeads.creative.Img)1 NativeVideo (com.xrtb.nativeads.creative.NativeVideo)1 Title (com.xrtb.nativeads.creative.Title)1