当前位置: 首页>>代码示例>>Java>>正文


Java MappingJsonFactory.createParser方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.MappingJsonFactory.createParser方法的典型用法代码示例。如果您正苦于以下问题:Java MappingJsonFactory.createParser方法的具体用法?Java MappingJsonFactory.createParser怎么用?Java MappingJsonFactory.createParser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.MappingJsonFactory的用法示例。


在下文中一共展示了MappingJsonFactory.createParser方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jsonExtractSubnetMask

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
/**
 * 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.createParser(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;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:41,代码来源:FirewallSubnetMaskResource.java

示例2: jsonToHostDefinition

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    
    try {
        jp = f.createParser(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();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:39,代码来源:HostResource.java

示例3: getEntryNameFromJson

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
/**
 * 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.createParser(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 == StaticFlowEntryPusher.COLUMN_NAME)
			return jp.getText();
	}
	return null;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:37,代码来源:StaticFlowEntries.java

示例4: jsonToHostDefinition

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createParser(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();
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:39,代码来源:HostResource.java

示例5: getEntryNameFromJson

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
/**
 * 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.createParser(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 == StaticFlowEntryPusher.COLUMN_NAME)
			return jp.getText();
	}
	return null;
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:37,代码来源:StaticFlowEntries.java

示例6: createDocumentSource

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
private DocumentSource createDocumentSource() {
    final InputStream inputStream = _resource.read();
    try {
        final MappingJsonFactory jsonFactory = new MappingJsonFactory();
        final JsonParser parser = jsonFactory.createParser(inputStream);
        logger.debug("Created JSON parser for resource: {}", _resource);

        return new JsonDocumentSource(parser, _resource.getName());
    } catch (Exception e) {
        FileHelper.safeClose(inputStream);
        throw new MetaModelException("Unexpected error while creating JSON parser", e);
    }
}
 
开发者ID:apache,项目名称:metamodel,代码行数:14,代码来源:JsonDataContext.java

示例7: jsonToNetworkDefinition

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
protected void jsonToNetworkDefinition(String json, NetworkDefinition network) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    
    try {
        jp = f.createParser(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 == null) continue;
                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();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:48,代码来源:NetworkResource.java

示例8: jsonToVip

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
protected LBVip jsonToVip(String json) throws IOException {
    
    if (json==null) return null;
    
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    LBVip vip = new LBVip();
    
    try {
        jp = f.createParser(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;
 
        if (n.equals("id")) {
            vip.id = jp.getText();
            continue;
        } 
        if (n.equals("tenant_id")) {
            vip.tenantId = jp.getText();
            continue;
        } 
        if (n.equals("name")) {
            vip.name = jp.getText();
            continue;
        }
        if (n.equals("network_id")) {
            vip.netId = jp.getText();
            continue;
        }
        if (n.equals("protocol")) {
            String tmp = jp.getText();
            if (tmp.equalsIgnoreCase("TCP")) {
                vip.protocol = (byte) IpProtocol.TCP.getIpProtocolNumber();
            } else if (tmp.equalsIgnoreCase("UDP")) {
                vip.protocol = (byte) IpProtocol.UDP.getIpProtocolNumber();
            } else if (tmp.equalsIgnoreCase("ICMP")) {
                vip.protocol = (byte) IpProtocol.ICMP.getIpProtocolNumber();
            } 
            continue;
        }
        if (n.equals("address")) {
            vip.address = IPv4.toIPv4Address(jp.getText());
            continue;
        }
        if (n.equals("port")) {
            vip.port = Short.parseShort(jp.getText());
            continue;
        }
        if (n.equals("pool_id")) {
            vip.pools.add(jp.getText());
            continue;
        }
        
        log.warn("Unrecognized field {} in " +
                "parsing Vips", 
                jp.getText());
    }
    jp.close();
    
    return vip;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:78,代码来源:VipsResource.java

示例9: jsonToPool

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
protected LBPool jsonToPool(String json) throws IOException {
    if (json==null) return null;

    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    LBPool pool = new LBPool();
    
    try {
        jp = f.createParser(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;
        if (n.equals("id")) {
            pool.id = jp.getText();
            continue;
        } 
        if (n.equals("tenant_id")) {
            pool.tenantId = jp.getText();
            continue;
        } 
        if (n.equals("name")) {
            pool.name = jp.getText();
            continue;
        }
        if (n.equals("network_id")) {
            pool.netId = jp.getText();
            continue;
        }
        if (n.equals("lb_method")) {
            pool.lbMethod = Short.parseShort(jp.getText());
            continue;
        }
        if (n.equals("protocol")) {
            String tmp = jp.getText();
            if (tmp.equalsIgnoreCase("TCP")) {
                pool.protocol = (byte) IpProtocol.TCP.getIpProtocolNumber();
            } else if (tmp.equalsIgnoreCase("UDP")) {
                pool.protocol = (byte) IpProtocol.UDP.getIpProtocolNumber();
            } else if (tmp.equalsIgnoreCase("ICMP")) {
                pool.protocol = (byte) IpProtocol.ICMP.getIpProtocolNumber();
            } 
            continue;
        }                    
        if (n.equals("vip_id")) {
            pool.vipId = jp.getText();
            continue;
        } 
        
        log.warn("Unrecognized field {} in " +
                "parsing Pools", 
                jp.getText());
    }
    jp.close();

    return pool;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:72,代码来源:PoolsResource.java

示例10: jsonToMember

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
protected LBMember jsonToMember(String json) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    LBMember member = new LBMember();
    
    try {
        jp = f.createParser(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;
        if (n.equals("id")) {
            member.id = jp.getText();
            continue;
        } else
        if (n.equals("address")) {
            member.address = IPv4.toIPv4Address(jp.getText());
            continue;
        } else
        if (n.equals("port")) {
            member.port = Short.parseShort(jp.getText());
            continue;
        } else
        if (n.equals("connection_limit")) {
            member.connectionLimit = Integer.parseInt(jp.getText());
            continue;
        } else
        if (n.equals("admin_state")) {
            member.adminState = Short.parseShort(jp.getText());
            continue;
        } else
        if (n.equals("status")) {
            member.status = Short.parseShort(jp.getText());
            continue;
        } else
        if (n.equals("pool_id")) {
            member.poolId = jp.getText();
            continue;
        } 
        
        log.warn("Unrecognized field {} in " +
                "parsing Members", 
                jp.getText());
    }
    jp.close();

    return member;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:63,代码来源:MembersResource.java

示例11: jsonToNetworkDefinition

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
protected void jsonToNetworkDefinition(String json, NetworkDefinition network) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;

    try {
        jp = f.createParser(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 == null) continue;
                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();
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:48,代码来源:NetworkResource.java

示例12: jsonToPool

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
protected LBPool jsonToPool(String json) throws IOException {
    if (json==null) return null;

    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    LBPool pool = new LBPool();

    try {
        jp = f.createParser(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;
        if (n.equals("id")) {
            pool.id = jp.getText();
            continue;
        }
        if (n.equals("tenant_id")) {
            pool.tenantId = jp.getText();
            continue;
        }
        if (n.equals("name")) {
            pool.name = jp.getText();
            continue;
        }
        if (n.equals("network_id")) {
            pool.netId = jp.getText();
            continue;
        }
        if (n.equals("lb_method")) {
            pool.lbMethod = Short.parseShort(jp.getText());
            continue;
        }
        if (n.equals("protocol")) {
            String tmp = jp.getText();
            if (tmp.equalsIgnoreCase("TCP")) {
                pool.protocol = (byte) IpProtocol.TCP.getIpProtocolNumber();
            } else if (tmp.equalsIgnoreCase("UDP")) {
                pool.protocol = (byte) IpProtocol.UDP.getIpProtocolNumber();
            } else if (tmp.equalsIgnoreCase("ICMP")) {
                pool.protocol = (byte) IpProtocol.ICMP.getIpProtocolNumber();
            }
            continue;
        }
        if (n.equals("vip_id")) {
            pool.vipId = jp.getText();
            continue;
        }

        log.warn("Unrecognized field {} in " +
                "parsing Pools",
                jp.getText());
    }
    jp.close();

    return pool;
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:72,代码来源:PoolsResource.java

示例13: jsonToVip

import com.fasterxml.jackson.databind.MappingJsonFactory; //导入方法依赖的package包/类
protected LBVip jsonToVip(String json) throws IOException {
    
    if (json==null) return null;
    
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    LBVip vip = new LBVip();
    
    try {
        jp = f.createParser(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;
 
        if (n.equals("id")) {
            vip.id = jp.getText();
            continue;
        } 
        if (n.equals("tenant_id")) {
            vip.tenantId = jp.getText();
            continue;
        } 
        if (n.equals("name")) {
            vip.name = jp.getText();
            continue;
        }
        if (n.equals("network_id")) {
            vip.netId = jp.getText();
            continue;
        }
        if (n.equals("protocol")) {
            String tmp = jp.getText();
            if (tmp.equalsIgnoreCase("TCP")) {
                vip.protocol = (byte) IpProtocol.TCP.getIpProtocolNumber();
            } else if (tmp.equalsIgnoreCase("UDP")) {
                vip.protocol = (byte) IpProtocol.UDP.getIpProtocolNumber();
            } else if (tmp.equalsIgnoreCase("ICMP")) {
                vip.protocol = (byte) IpProtocol.ICMP.getIpProtocolNumber();
            } 
            continue;
        }
        if (n.equals("address")) {
            vip.address = IPv4.toIPv4Address(jp.getText());
            continue;
        }
        if (n.equals("port")) {
            vip.port = Short.parseShort(jp.getText());
            continue;
        }
        if (n.equals("pool_id")) {
            vip.pools.add(jp.getText());
            continue;
        }
        
        log.warn("Unrecognized field {} in " +
                "parsing Vips", 
                jp.getText());
    }
    jp.close();

    return vip;
}
 
开发者ID:rhoybeen,项目名称:floodlightLB,代码行数:78,代码来源:VipsResource.java


注:本文中的com.fasterxml.jackson.databind.MappingJsonFactory.createParser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。