use of com.xrtb.nativeads.creative.NativeVideo 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);
}
}
}
}
}
Aggregations