<commit_before>package net.onrc.onos.ofcontroller.flowmanager.web;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DatapathSummarySerializer extends JsonSerializer<String>{
	final static Logger log = LoggerFactory.getLogger(DatapathSummarySerializer.class);
	
	@Override
	public void serialize(String datapathSummary, JsonGenerator jGen,
			SerializerProvider serializer) throws IOException,
			JsonProcessingException {
		
		String[] flowEntries = datapathSummary.split(";");
		if (flowEntries.length < 2){
			log.debug("datapathSummary string to short to parse: {}", 
					datapathSummary);
			jGen.writeStartObject();
			jGen.writeEndObject();
			return;
		}
		
		String[] srcFlowEntry = flowEntries[0].split("/");
		String[] dstFlowEntry = flowEntries[flowEntries.length - 1].split("/");
		if (srcFlowEntry.length != 3 || dstFlowEntry.length != 3){
			log.debug("Malformed datapathSummary string: {}", datapathSummary);
			jGen.writeStartObject();
			jGen.writeEndObject();
			return;
		}
		
		jGen.writeStartObject();
		
		/*
		jGen.writeObjectFieldStart("srcPort");
		jGen.writeObjectFieldStart("dpid");<commit_msg>Change the "log" field variable to "protected" so it is consistent with the rest of the code.<commit_after>package net.onrc.onos.ofcontroller.flowmanager.web;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DatapathSummarySerializer extends JsonSerializer<String>{
	protected final static Logger log = LoggerFactory.getLogger(DatapathSummarySerializer.class);
	
	@Override
	public void serialize(String datapathSummary, JsonGenerator jGen,
			SerializerProvider serializer) throws IOException,
			JsonProcessingException {
		
		String[] flowEntries = datapathSummary.split(";");
		if (flowEntries.length < 2){
			log.debug("datapathSummary string to short to parse: {}", 
					datapathSummary);
			jGen.writeStartObject();
			jGen.writeEndObject();
			return;
		}
		
		String[] srcFlowEntry = flowEntries[0].split("/");
		String[] dstFlowEntry = flowEntries[flowEntries.length - 1].split("/");
		if (srcFlowEntry.length != 3 || dstFlowEntry.length != 3){
			log.debug("Malformed datapathSummary string: {}", datapathSummary);
			jGen.writeStartObject();
			jGen.writeEndObject();
			return;
		}
		
		jGen.writeStartObject();
		
		/*
		jGen.writeObjectFieldStart("srcPort");
		jGen.writeObjectFieldStart("dpid");
{'fraction_non_alphanumeric': 0.11625441696113074, 'fraction_numerical': 0.0049469964664310955, 'mean_word_length': 5.305122494432071, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4559760', 'n_tokens_mistral': 940, 'n_tokens_neox': 829, 'n_words': 168}