當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。