/** * Factory method for getting an instance of JSON numeric value * that expresses given 8-bit value */ public NumericNode numberNode(byte v) { return IntNode.valueOf(v); }
public static IntNode valueOf(int i) { if (i > MAX_CANONICAL || i < MIN_CANONICAL) return new IntNode(i); return CANONICALS[i - MIN_CANONICAL]; }
case INT: if ( fieldValue.getClass() == IntNode.class ) { return getKettleValue( new Long( ( (IntNode) fieldValue ).getIntValue() ) );
if (from instanceof IntNode) return ((IntNode)from).getIntValue(); if (from instanceof BooleanNode) return ((BooleanNode)from).getBooleanValue(); if (from instanceof DoubleNode) return ((DoubleNode)from).getDoubleValue();
/** * Factory method for getting an instance of JSON numeric value * that expresses given 32-bit integer value */ public NumericNode numberNode(int v) { return IntNode.valueOf(v); }
public static IntNode valueOf(int i) { if (i > MAX_CANONICAL || i < MIN_CANONICAL) return new IntNode(i); return CANONICALS[i - MIN_CANONICAL]; }
/** * Factory method for getting an instance of JSON numeric value * that expresses given 16-bit integer value */ public NumericNode numberNode(short v) { return IntNode.valueOf(v); }
public static IntNode valueOf(int i) { if (i > MAX_CANONICAL || i < MIN_CANONICAL) return new IntNode(i); return CANONICALS[i - MIN_CANONICAL]; }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Short value) { return (value == null) ? nullNode() : IntNode.valueOf(value.shortValue()); }
public static IntNode valueOf(int i) { if (i > MAX_CANONICAL || i < MIN_CANONICAL) return new IntNode(i); return CANONICALS[i - MIN_CANONICAL]; }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Byte value) { return (value == null) ? nullNode() : IntNode.valueOf(value.intValue()); }
public static IntNode valueOf(int i) { if (i > MAX_CANONICAL || i < MIN_CANONICAL) return new IntNode(i); return CANONICALS[i - MIN_CANONICAL]; }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Integer value) { return (value == null) ? nullNode() : IntNode.valueOf(value.intValue()); }
@Test public void testAvroRecordSchema() throws Exception { org.apache.avro.Schema avroStringSchema = org.apache.avro.Schema.create(org.apache.avro.Schema.Type.STRING); org.apache.avro.Schema avroIntSchema = org.apache.avro.Schema.create(org.apache.avro.Schema.Type.INT); org.apache.avro.Schema schema = org.apache.avro.Schema.createRecord("UserInfo", "Describes user information", "org.example.schema", false); List<org.apache.avro.Schema.Field> fields = new ArrayList<>(); org.apache.avro.Schema.Field field = new org.apache.avro.Schema.Field("username", avroStringSchema, "Field represents username", new TextNode("unknown")); fields.add(field); field = new org.apache.avro.Schema.Field("age", avroIntSchema, "Field represents age of user", new IntNode(-1)); fields.add(field); schema.setFields(fields); Schema parsedSchema = Schema.parseJson(schema.toString()); Assert.assertTrue("UserInfo".equals(parsedSchema.getRecordName())); Assert.assertEquals(2, parsedSchema.getFields().size()); Schema.Field parsedField = parsedSchema.getFields().get(0); Assert.assertTrue("username".equals(parsedField.getName())); Assert.assertTrue("STRING".equals(parsedField.getSchema().getType().toString())); parsedField = parsedSchema.getFields().get(1); Assert.assertTrue("age".equals(parsedField.getName())); Assert.assertTrue("INT".equals(parsedField.getSchema().getType().toString())); }
/** * Factory method for getting an instance of JSON numeric value * that expresses given 32-bit integer value */ public NumericNode numberNode(int v) { return IntNode.valueOf(v); }
/** * Factory method for getting an instance of JSON numeric value * that expresses given 8-bit value */ public NumericNode numberNode(byte v) { return IntNode.valueOf(v); }
/** * Factory method for getting an instance of JSON numeric value * that expresses given 16-bit integer value */ public NumericNode numberNode(short v) { return IntNode.valueOf(v); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Short value) { return (value == null) ? nullNode() : IntNode.valueOf(value.shortValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Byte value) { return (value == null) ? nullNode() : IntNode.valueOf(value.intValue()); }
/** * Alternate factory method that will handle wrapper value, which may * be null. * Due to possibility of null, returning type is not guaranteed to be * {@link NumericNode}, but just {@link ValueNode}. * * @since 1.9 */ public ValueNode numberNode(Integer value) { return (value == null) ? nullNode() : IntNode.valueOf(value.intValue()); }