Package org.springframework.xd.tuple

Examples of org.springframework.xd.tuple.Tuple


    String first = "Alan";
    String last = "Turing";
    int born = 1912;

    Tuple item = TupleBuilder.tuple()
        .put("first", first)
        .put("last", last)
        .put("born", born)
        .build();
View Full Code Here


    String first = "Alan";
    String last = "Turing";
    int born = 1912;

    Tuple item = TupleBuilder.tuple()
        .put("first", first)
        .put("last", last)
        .put("born", born)
        .build();
View Full Code Here

    String first = "Alan";
    String last = "Turing";
    int born = 1912;

    Tuple item = TupleBuilder.tuple()
        .put("first", first)
        .put("last", last)
        .put("born", born)
        .build();
View Full Code Here

    when(metaData.getColumnName(3)).thenReturn("third");
    when(rs.getObject(3)).thenReturn(true);

    when(rs.getMetaData()).thenReturn(metaData);

    Tuple result = mapper.mapRow(rs, 0);

    assertEquals("string", result.getValue("first"));
    assertEquals(5, result.getValue("second"));
    assertEquals(true, result.getValue("third"));
  }
View Full Code Here

  @Test
  public void testVanillaTupleCreation() throws Exception {
    FieldSet fieldSet = new DefaultFieldSet(new String[] { "This is some dummy string", "true", "C" },
        new String[] { "varString", "varBoolean", "varChar" });
    Tuple result = mapper.mapFieldSet(fieldSet);
    assertEquals("This is some dummy string", result.getString(0));
    assertEquals(true, result.getBoolean(1));
    assertEquals('C', result.getChar(2));
  }
View Full Code Here

    });
    FieldSet fieldSet = new DefaultFieldSet(new String[] { "19.95", "true", "1", "M", "1977-10-22", "2.22", "9.99",
      "5", "9", "10", "some dummy string", "2007-06-23" },
        new String[] { "field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8",
          "field9", "field10", "field11", "field12" });
    Tuple result = mapper.mapFieldSet(fieldSet);
    assertEquals(new BigDecimal("19.95"), result.getValue("field1"));
    assertEquals(true, result.getValue("field2"));
    assertEquals((byte) 1, result.getValue("field3"));
    assertEquals('M', result.getValue("field4"));
    assertEquals(formatter.parse("1977-10-22"), result.getValue("field5"));
    assertEquals(2.22, result.getValue("field6"));
    assertEquals(9.99f, result.getValue("field7"));
    assertEquals(5, result.getValue("field8"));
    assertEquals(9l, result.getValue("field9"));
    assertEquals((short) 10, result.getValue("field10"));
    assertEquals("some dummy string", result.getValue("field11"));
    assertEquals("2007-06-23", result.getValue("field12"));
  }
View Full Code Here

    SimpleDateFormat customFormatter = new SimpleDateFormat("MM/dd/yyyy hh:mm a");
    mapper.setDateFormat(customFormatter);

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "10/22/1977 01:25 AM" }, new String[] { "dateField" });

    Tuple result = mapper.mapFieldSet(fieldSet);

    assertEquals(customFormatter.parse("10/22/1977 01:25 AM"), result.getDate(0));
  }
View Full Code Here

    return new Class<?>[] { Tuple.class };
  }

  @Override
  public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException {
    Tuple tuple = (Tuple) target;
    if (tuple.hasFieldName(name)) {
      return true;
    }
    return maybeIndex(name, tuple) != null;
  }
View Full Code Here

    return index;
  }

  @Override
  public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
    Tuple tuple = (Tuple) target;
    boolean hasKey = false;
    Object value = null;
    if (tuple.hasFieldName(name)) {
      hasKey = true;
      value = tuple.getValue(name);
    }
    else {
      Integer index = maybeIndex(name, tuple);
      if (index != null) {
        hasKey = true;
        value = tuple.getValue(index);
      }
    }
    if (value == null && !hasKey) {
      throw new TupleAccessException(name);
    }
View Full Code Here

    List<Object> values = new ArrayList<Object>(input.getValues());

    fieldNames.add("k3");
    values.add("v3");

    Tuple output = TupleBuilder.tuple().ofNamesAndValues(fieldNames, values);

    return output;
  }
View Full Code Here

TOP

Related Classes of org.springframework.xd.tuple.Tuple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.