Java Code Examples for com.fasterxml.jackson.core.JsonParser#getByteValue()
The following examples show how to use
com.fasterxml.jackson.core.JsonParser#getByteValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bean63Table.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueMapStringByte parsing */ public static Map<String, Byte> parseValueMapStringByte(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Map<String, Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashMap<String, Byte> collection=new HashMap<>(); String key=null; Byte value=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { jacksonParser.nextValue(); key=jacksonParser.getText(); jacksonParser.nextValue(); if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { value=jacksonParser.getByteValue(); } collection.put(key, value); key=null; value=null; jacksonParser.nextToken(); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 2
Source File: ByteBeanTable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute value2 parsing */ public static LinkedList<Byte> parseValue2(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); LinkedList<Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { LinkedList<Byte> collection=new LinkedList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 3
Source File: ByteBeanTable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute value parsing */ public static List<Byte> parseValue(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); List<Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Byte> collection=new ArrayList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 4
Source File: ByteDaoImpl.java From kripton with Apache License 2.0 | 5 votes |
/** * for param parser2 parsing */ private List<Byte> parser2(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); List<Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Byte> collection=new ArrayList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 5
Source File: ByteBeanTable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute value2 parsing */ public static Byte[] parseValue2(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Byte[] result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Byte> collection=new ArrayList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=CollectionUtils.asByteArray(collection); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 6
Source File: ByteDaoImpl.java From kripton with Apache License 2.0 | 5 votes |
/** * for param parser1 parsing */ private Byte[] parser1(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Byte[] result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Byte> collection=new ArrayList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=CollectionUtils.asByteArray(collection); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 7
Source File: ByteBeanTable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute value2 parsing */ public static Byte[] parseValue2(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Byte[] result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Byte> collection=new ArrayList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=CollectionUtils.asByteArray(collection); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 8
Source File: ByteDaoImpl.java From kripton with Apache License 2.0 | 5 votes |
/** * for param parser1 parsing */ private Byte[] parser1(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Byte[] result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Byte> collection=new ArrayList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=CollectionUtils.asByteArray(collection); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 9
Source File: Bean63Table.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueMapEnumByte parsing */ public static HashMap<EnumType, Byte> parseValueMapEnumByte(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); HashMap<EnumType, Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashMap<EnumType, Byte> collection=new HashMap<>(); EnumType key=null; Byte value=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { jacksonParser.nextValue(); { String tempEnum=jacksonParser.getText(); key=StringUtils.hasText(tempEnum)?EnumType.valueOf(tempEnum):null; } jacksonParser.nextValue(); if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { value=jacksonParser.getByteValue(); } collection.put(key, value); key=null; value=null; jacksonParser.nextToken(); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 10
Source File: BindBean63SharedPreferences.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueMapEnumByte parsing */ protected HashMap<EnumType, Byte> parseValueMapEnumByte(String input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); HashMap<EnumType, Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashMap<EnumType, Byte> collection=new HashMap<>(); EnumType key=null; Byte value=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { jacksonParser.nextValue(); { String tempEnum=jacksonParser.getText(); key=StringUtils.hasText(tempEnum)?EnumType.valueOf(tempEnum):null; } jacksonParser.nextValue(); if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { value=jacksonParser.getByteValue(); } collection.put(key, value); key=null; value=null; jacksonParser.nextToken(); } result=collection; } return result; } catch(Exception e) { throw(new KriptonRuntimeException(e.getMessage())); } }
Example 11
Source File: BeanDaoImpl.java From kripton with Apache License 2.0 | 5 votes |
/** * for param parser2 parsing */ private HashMap<EnumType, Byte> parser2(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); HashMap<EnumType, Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashMap<EnumType, Byte> collection=new HashMap<>(); EnumType key=null; Byte value=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { jacksonParser.nextValue(); { String tempEnum=jacksonParser.getText(); key=StringUtils.hasText(tempEnum)?EnumType.valueOf(tempEnum):null; } jacksonParser.nextValue(); if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { value=jacksonParser.getByteValue(); } collection.put(key, value); key=null; value=null; jacksonParser.nextToken(); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 12
Source File: BeanDaoImpl.java From kripton with Apache License 2.0 | 5 votes |
/** * for param parser1 parsing */ private Map<String, Byte> parser1(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Map<String, Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashMap<String, Byte> collection=new HashMap<>(); String key=null; Byte value=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { jacksonParser.nextValue(); key=jacksonParser.getText(); jacksonParser.nextValue(); if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { value=jacksonParser.getByteValue(); } collection.put(key, value); key=null; value=null; jacksonParser.nextToken(); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 13
Source File: BeanTable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueByteSet parsing */ public static Set<Byte> parseValueByteSet(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Set<Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashSet<Byte> collection=new HashSet<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 14
Source File: BindBeanSharedPreferences.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueByteSet parsing */ protected Set<Byte> parseValueByteSet(String input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Set<Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashSet<Byte> collection=new HashSet<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 15
Source File: Bean2Table.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueByteSet parsing */ public static Set<Byte> parseValueByteSet(byte[] input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Set<Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashSet<Byte> collection=new HashSet<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 16
Source File: BindBean2SharedPreferences.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueByteSet parsing */ protected Set<Byte> parseValueByteSet(String input) { if (input==null) { return null; } KriptonJsonContext context=KriptonBinder.jsonBind(); try (JacksonWrapperParser wrapper=context.createParser(input)) { JsonParser jacksonParser=wrapper.jacksonParser; // START_OBJECT jacksonParser.nextToken(); // value of "element" jacksonParser.nextValue(); Set<Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashSet<Byte> collection=new HashSet<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 17
Source File: Bean75BindMap.java From kripton with Apache License 2.0 | 4 votes |
/** * parse with jackson */ @Override public Bean75 parseOnJackson(JsonParser jacksonParser) throws Exception { Bean75 instance = new Bean75(); String fieldName; if (jacksonParser.currentToken() == null) { jacksonParser.nextToken(); } if (jacksonParser.currentToken() != JsonToken.START_OBJECT) { jacksonParser.skipChildren(); return instance; } while (jacksonParser.nextToken() != JsonToken.END_OBJECT) { fieldName = jacksonParser.getCurrentName(); jacksonParser.nextToken(); // Parse fields: switch (fieldName) { case "name": // field name (mapped with "name") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.name=jacksonParser.getText(); } break; case "valueByteArray": // field valueByteArray (mapped with "valueByteArray") if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Byte> collection=new ArrayList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } instance.valueByteArray=CollectionUtils.asByteArray(collection); } break; case "valueByteTypeArray": // field valueByteTypeArray (mapped with "valueByteTypeArray") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.valueByteTypeArray=jacksonParser.getBinaryValue(); } break; default: jacksonParser.skipChildren(); break;} } return instance; }
Example 18
Source File: PrimitiveKVHandler.java From jackson-datatypes-collections with Apache License 2.0 | 4 votes |
public byte value(DeserializationContext ctx, JsonParser parser) throws IOException { return parser.getByteValue(); }
Example 19
Source File: ByteBeanBindMap.java From kripton with Apache License 2.0 | 4 votes |
/** * parse with jackson */ @Override public ByteBean parseOnJackson(JsonParser jacksonParser) throws Exception { ByteBean instance = new ByteBean(); String fieldName; if (jacksonParser.currentToken() == null) { jacksonParser.nextToken(); } if (jacksonParser.currentToken() != JsonToken.START_OBJECT) { jacksonParser.skipChildren(); return instance; } while (jacksonParser.nextToken() != JsonToken.END_OBJECT) { fieldName = jacksonParser.getCurrentName(); jacksonParser.nextToken(); // Parse fields: switch (fieldName) { case "id": // field id (mapped with "id") instance.id=jacksonParser.getLongValue(); break; case "value": // field value (mapped with "value") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.value=jacksonParser.getBinaryValue(); } break; case "value2": // field value2 (mapped with "value2") if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Byte> collection=new ArrayList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } instance.value2=CollectionUtils.asByteArray(collection); } break; default: jacksonParser.skipChildren(); break;} } return instance; }
Example 20
Source File: ByteBeanBindMap.java From kripton with Apache License 2.0 | 4 votes |
/** * parse with jackson */ @Override public ByteBean parseOnJackson(JsonParser jacksonParser) throws Exception { ByteBean instance = new ByteBean(); String fieldName; if (jacksonParser.currentToken() == null) { jacksonParser.nextToken(); } if (jacksonParser.currentToken() != JsonToken.START_OBJECT) { jacksonParser.skipChildren(); return instance; } while (jacksonParser.nextToken() != JsonToken.END_OBJECT) { fieldName = jacksonParser.getCurrentName(); jacksonParser.nextToken(); // Parse fields: switch (fieldName) { case "id": // field id (mapped with "id") instance.setId(jacksonParser.getLongValue()); break; case "value": // field value (mapped with "value") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.setValue(jacksonParser.getBinaryValue()); } break; case "value2": // field value2 (mapped with "value2") if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Byte> collection=new ArrayList<>(); Byte item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getByteValue(); } collection.add(item); } instance.setValue2(CollectionUtils.asByteArray(collection)); } break; default: jacksonParser.skipChildren(); break;} } return instance; }