Java 类org.codehaus.jackson.map.MappingJsonFactory 实例源码

项目:Repository-RI    文件:RestHelper.java   
public static Response jsonResponse (Object obj, Class clazz) throws JAXBException{
    StringWriter writer = new StringWriter();
    try {
        ObjectMapper mapper = new ObjectMapper();

        MappingJsonFactory jsonFactory = new MappingJsonFactory();
        JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(writer);

        mapper.writeValue(jsonGenerator, obj);
        writer.close();

    } catch (IOException e) {
    }

    return Response.status(200).type("application/json").entity(writer.toString()).build();
}
项目:Mattermost-client    文件:WsSocketListener.java   
@Override
default public void onMessage(final String message)
{
    try
    {
        onEvent(new MappingJsonFactory().createJsonParser(message).readValueAs(Event.class));
    }
    catch (final Exception e)
    {
        _logger.log(Level.SEVERE, "Can't convert json to Map<String,Object>" + message, e);
        onEvent(new Event());
    }
}
项目:Mattermost-client    文件:MatterMostBotClient.java   
public static <T> T decode(final int status, final String str, final Class<T> t)
{
    try
    {
        if (200 == status || 201 == status)
            return new MappingJsonFactory().createJsonParser(str).readValueAs(t);
        else
            throw new ApiV4Exception(new MappingJsonFactory().createJsonParser(str).readValueAs(com.cloudtemple.mattermost.traders.Error.class));
    }
    catch (final IOException e)
    {
        _logger.log(Level.SEVERE, "", e);
        throw new ApiV4Exception(e);
    }
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:HostResource.java   
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }

    jp.close();
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:FirewallResource.java   
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
项目:iwethey    文件:JacksonSerializer.java   
public JacksonSerializer()
{
    this.serializerFactory = new CustomSerializerFactory();
    this.serializerFactory.addGenericMapping(CGLIBLazyInitializer.class, new CGLIBLazyInitializerHandler());

    this.factory = new MappingJsonFactory(new ObjectMapper(this.serializerFactory));
    this.factory.setGeneratorFeature(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
}
项目:smartenit    文件:HostResource.java   
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }

    jp.close();
}
项目:smartenit    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:smartenit    文件:FirewallResource.java   
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
项目:archived-net-virt-platform    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:floodlight-qosmanager    文件:HostResource.java   
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }

    jp.close();
}
项目:floodlight-qosmanager    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:floodlight-qosmanager    文件:FirewallResource.java   
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
项目:floodlight-nfv    文件:HostResource.java   
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }

    jp.close();
}
项目:floodlight-nfv    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:floodlight-nfv    文件:FirewallResource.java   
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
项目:ppinot    文件:JSONLogProvider.java   
public JSONLogProvider(Reader reader, JSONLogEntryLoader loader) {
    this.loader = loader;
    try {
        this.parser = new MappingJsonFactory().createJsonParser(reader);
    } catch (IOException e) {
        throw new RuntimeException("JSON Stream cannot be read");
    }
}
项目:HederaInFloodlight    文件:HostResource.java   
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }

    jp.close();
}
项目:HederaInFloodlight    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:HederaInFloodlight    文件:FirewallResource.java   
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
项目:floodlight-oss    文件:HostResource.java   
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }

    jp.close();
}
项目:floodlight-oss    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals(""))
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:floodlight-oss    文件:FirewallResource.java   
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
项目:my-floodlight    文件:HostResource.java   
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }

    jp.close();
}
项目:my-floodlight    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:my-floodlight    文件:FirewallResource.java   
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
项目:FL_HAND    文件:HostResource.java   
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }

    jp.close();
}
项目:FL_HAND    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:FL_HAND    文件:FirewallResource.java   
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
项目:sdn-project    文件:HostResource.java   
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }

    jp.close();
}
项目:sdn-project    文件:StaticFlowEntries.java   
/**
 * Gets the entry name of a flow mod
 * @param fmJson The OFFlowMod in a JSON representation
 * @return The name of the OFFlowMod, null if not found
 * @throws IOException If there was an error parsing the JSON
 */
public static String getEntryNameFromJson(String fmJson) throws IOException{
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            return jp.getText();
    }

    return null;
}
项目:sdn-project    文件:FirewallResource.java   
/**
 * Extracts subnet mask from a JSON string
 * @param fmJson The JSON formatted string
 * @return The subnet mask
 * @throws IOException If there was an error parsing the JSON
 */
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
    String subnet_mask = "";
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "subnet-mask") {
            subnet_mask = jp.getText();
            break;
        }
    }

    return subnet_mask;
}
项目:openrtb-hg    文件:AbstractJsonTranslator.java   
public void toJSON(Writer writer, T value) throws IOException {
    MappingJsonFactory factory = new MappingJsonFactory();
    JsonGenerator generator = factory.createJsonGenerator(writer);

    if (usePrettyPrinter) {
        generator.useDefaultPrettyPrinter();
    }
    objectMapper.writeValue(generator, value);
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:NetworkResource.java   
protected void jsonToNetworkDefinition(String json, NetworkDefinition network) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("network")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("name")) {
                    network.name = jp.getText();
                } else if (field.equals("gateway")) {
                    String gw = jp.getText();
                    if ((gw != null) && (!gw.equals("null")))
                        network.gateway = gw;
                } else if (field.equals("id")) {
                    network.guid = jp.getText();
                } else {
                    log.warn("Unrecognized field {} in " +
                            "parsing network definition", 
                            jp.getText());
                }
            }
        }
    }

    jp.close();
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:StaticFlowEntries.java   
/**
 * Turns a JSON formatted Static Flow Pusher string into a storage entry
 * Expects a string in JSON along the lines of:
 *        {
 *            "switch":       "AA:BB:CC:DD:EE:FF:00:11",
 *            "name":         "flow-mod-1",
 *            "cookie":       "0",
 *            "priority":     "32768",
 *            "ingress-port": "1",
 *            "actions":      "output=2",
 *        }
 * @param fmJson The JSON formatted static flow pusher entry
 * @return The map of the storage entry
 * @throws IOException If there was an error parsing the JSON
 */
public static Map<String, Object> jsonToStorageEntry(String fmJson) throws IOException {
    Map<String, Object> entry = new HashMap<String, Object>();
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            entry.put(StaticFlowEntryPusher.COLUMN_NAME, jp.getText());
        else if (n == "switch")
            entry.put(StaticFlowEntryPusher.COLUMN_SWITCH, jp.getText());
        else if (n == "actions")
            entry.put(StaticFlowEntryPusher.COLUMN_ACTIONS, jp.getText());
        else if (n == "priority")
            entry.put(StaticFlowEntryPusher.COLUMN_PRIORITY, jp.getText());
        else if (n == "active")
            entry.put(StaticFlowEntryPusher.COLUMN_ACTIVE, jp.getText());
        else if (n == "wildcards")
            entry.put(StaticFlowEntryPusher.COLUMN_WILDCARD, jp.getText());
        else if (n == "ingress-port")
            entry.put(StaticFlowEntryPusher.COLUMN_IN_PORT, jp.getText());
        else if (n == "src-mac")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_SRC, jp.getText());
        else if (n == "dst-mac")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_DST, jp.getText());
        else if (n == "vlan-id")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN, jp.getText());
        else if (n == "vlan-priority")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN_PCP, jp.getText());
        else if (n == "ether-type")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_TYPE, jp.getText());
        else if (n == "tos-bits")
            entry.put(StaticFlowEntryPusher.COLUMN_NW_TOS, jp.getText());
        else if (n == "protocol")
            entry.put(StaticFlowEntryPusher.COLUMN_NW_PROTO, jp.getText());
        else if (n == "src-ip")
            entry.put(StaticFlowEntryPusher.COLUMN_NW_SRC, jp.getText());
        else if (n == "dst-ip")
            entry.put(StaticFlowEntryPusher.COLUMN_NW_DST, jp.getText());
        else if (n == "src-port")
            entry.put(StaticFlowEntryPusher.COLUMN_TP_SRC, jp.getText());
        else if (n == "dst-port")
            entry.put(StaticFlowEntryPusher.COLUMN_TP_DST, jp.getText());
    }

    return entry;
}
项目:hops    文件:EntityGroupFSTimelineStore.java   
@Override
protected void serviceStart() throws Exception {

  super.serviceStart();
  LOG.info("Starting {}", getName());
  summaryStore.start();

  Configuration conf = getConfig();
  aclManager = new TimelineACLsManager(conf);
  aclManager.setTimelineStore(summaryStore);
  summaryTdm = new TimelineDataManager(summaryStore, aclManager);
  summaryTdm.init(conf);
  addService(summaryTdm);
  // start child services that aren't already started
  super.serviceStart();

  if (!fs.exists(activeRootPath)) {
    fs.mkdirs(activeRootPath);
    fs.setPermission(activeRootPath, ACTIVE_DIR_PERMISSION);
  }
  if (!fs.exists(doneRootPath)) {
    fs.mkdirs(doneRootPath);
    fs.setPermission(doneRootPath, DONE_DIR_PERMISSION);
  }

  objMapper = new ObjectMapper();
  objMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
  jsonFactory = new MappingJsonFactory(objMapper);
  final long scanIntervalSecs = conf.getLong(
      YarnConfiguration
          .TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_SCAN_INTERVAL_SECONDS,
      YarnConfiguration
          .TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_SCAN_INTERVAL_SECONDS_DEFAULT
  );
  final long cleanerIntervalSecs = conf.getLong(
      YarnConfiguration
        .TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_CLEANER_INTERVAL_SECONDS,
      YarnConfiguration
        .TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_CLEANER_INTERVAL_SECONDS_DEFAULT
  );
  final int numThreads = conf.getInt(
      YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_THREADS,
      YarnConfiguration
          .TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_THREADS_DEFAULT);
  LOG.info("Scanning active directory {} every {} seconds", activeRootPath,
      scanIntervalSecs);
  LOG.info("Cleaning logs every {} seconds", cleanerIntervalSecs);

  executor = new ScheduledThreadPoolExecutor(numThreads,
      new ThreadFactoryBuilder().setNameFormat("EntityLogPluginWorker #%d")
          .build());
  executor.scheduleAtFixedRate(new EntityLogScanner(), 0, scanIntervalSecs,
      TimeUnit.SECONDS);
  executor.scheduleAtFixedRate(new EntityLogCleaner(), cleanerIntervalSecs,
      cleanerIntervalSecs, TimeUnit.SECONDS);
}
项目:seqr    文件:JsonStreamParser.java   
public JsonStreamParser(File jsonFile) throws IOException {
    factory = new MappingJsonFactory();
    parser = factory.createJsonParser(jsonFile);
}
项目:smartenit    文件:NetworkResource.java   
protected void jsonToNetworkDefinition(String json, NetworkDefinition network) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("network")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("name")) {
                    network.name = jp.getText();
                } else if (field.equals("gateway")) {
                    String gw = jp.getText();
                    if ((gw != null) && (!gw.equals("null")))
                        network.gateway = gw;
                } else if (field.equals("id")) {
                    network.guid = jp.getText();
                } else {
                    log.warn("Unrecognized field {} in " +
                            "parsing network definition", 
                            jp.getText());
                }
            }
        }
    }

    jp.close();
}
项目:smartenit    文件:StaticFlowEntries.java   
/**
 * Turns a JSON formatted Static Flow Pusher string into a storage entry
 * Expects a string in JSON along the lines of:
 *        {
 *            "switch":       "AA:BB:CC:DD:EE:FF:00:11",
 *            "name":         "flow-mod-1",
 *            "cookie":       "0",
 *            "priority":     "32768",
 *            "ingress-port": "1",
 *            "actions":      "output=2",
 *        }
 * @param fmJson The JSON formatted static flow pusher entry
 * @return The map of the storage entry
 * @throws IOException If there was an error parsing the JSON
 */
public static Map<String, Object> jsonToStorageEntry(String fmJson) throws IOException {
    Map<String, Object> entry = new HashMap<String, Object>();
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createJsonParser(fmJson);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }

    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }

    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }

        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;

        if (n == "name")
            entry.put(StaticFlowEntryPusher.COLUMN_NAME, jp.getText());
        else if (n == "switch")
            entry.put(StaticFlowEntryPusher.COLUMN_SWITCH, jp.getText());
        else if (n == "actions")
            entry.put(StaticFlowEntryPusher.COLUMN_ACTIONS, jp.getText());
        else if (n == "priority")
            entry.put(StaticFlowEntryPusher.COLUMN_PRIORITY, jp.getText());
        else if (n == "active")
            entry.put(StaticFlowEntryPusher.COLUMN_ACTIVE, jp.getText());
        else if (n == "wildcards")
            entry.put(StaticFlowEntryPusher.COLUMN_WILDCARD, jp.getText());
        else if (n == "ingress-port")
            entry.put(StaticFlowEntryPusher.COLUMN_IN_PORT, jp.getText());
        else if (n == "src-mac")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_SRC, jp.getText());
        else if (n == "dst-mac")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_DST, jp.getText());
        else if (n == "vlan-id")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN, jp.getText());
        else if (n == "vlan-priority")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN_PCP, jp.getText());
        else if (n == "ether-type")
            entry.put(StaticFlowEntryPusher.COLUMN_DL_TYPE, jp.getText());
        else if (n == "tos-bits")
            entry.put(StaticFlowEntryPusher.COLUMN_NW_TOS, jp.getText());
        else if (n == "protocol")
            entry.put(StaticFlowEntryPusher.COLUMN_NW_PROTO, jp.getText());
        else if (n == "src-ip")
            entry.put(StaticFlowEntryPusher.COLUMN_NW_SRC, jp.getText());
        else if (n == "dst-ip")
            entry.put(StaticFlowEntryPusher.COLUMN_NW_DST, jp.getText());
        else if (n == "src-port")
            entry.put(StaticFlowEntryPusher.COLUMN_TP_SRC, jp.getText());
        else if (n == "dst-port")
            entry.put(StaticFlowEntryPusher.COLUMN_TP_DST, jp.getText());
    }

    return entry;
}