use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class TableView method getRowWithoutValues.
public RowMetaInterface getRowWithoutValues() {
RowMetaInterface f = new RowMeta();
f.addValueMeta(new ValueMetaInteger("#"));
for (int i = 0; i < columns.length; i++) {
f.addValueMeta(new ValueMetaString(columns[i].getName()));
}
return f;
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class StringSearchResult method getResultRowMeta.
public static final RowMetaInterface getResultRowMeta() {
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString(BaseMessages.getString(PKG, "SearchResult.TransOrJob")));
rowMeta.addValueMeta(new ValueMetaString(BaseMessages.getString(PKG, "SearchResult.StepDatabaseNotice")));
rowMeta.addValueMeta(new ValueMetaString(BaseMessages.getString(PKG, "SearchResult.String")));
rowMeta.addValueMeta(new ValueMetaString(BaseMessages.getString(PKG, "SearchResult.FieldName")));
return rowMeta;
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class ValueMetaAndData method loadXML.
/**
* Read the data for this Value from an XML Node
*
* @param valnode
* The XML Node to read from
* @return true if all went well, false if something went wrong.
*/
public boolean loadXML(Node valnode) {
valueMeta = null;
try {
String valname = XMLHandler.getTagValue(valnode, "name");
int valtype = ValueMetaBase.getType(XMLHandler.getTagValue(valnode, "type"));
String text = XMLHandler.getTagValue(valnode, "text");
boolean isnull = "Y".equalsIgnoreCase(XMLHandler.getTagValue(valnode, "isnull"));
int len = Const.toInt(XMLHandler.getTagValue(valnode, "length"), -1);
int prec = Const.toInt(XMLHandler.getTagValue(valnode, "precision"), -1);
String mask = XMLHandler.getTagValue(valnode, "mask");
valueMeta = new ValueMeta(valname, valtype);
valueData = text;
valueMeta.setLength(len);
valueMeta.setPrecision(prec);
if (mask != null) {
valueMeta.setConversionMask(mask);
}
if (valtype != ValueMetaInterface.TYPE_STRING) {
ValueMetaInterface originMeta = new ValueMetaString(valname);
if (valueMeta.isNumeric()) {
originMeta.setDecimalSymbol(".");
originMeta.setGroupingSymbol(null);
originMeta.setCurrencySymbol(null);
}
if (valtype == ValueMetaInterface.TYPE_DATE) {
originMeta.setConversionMask(ValueMetaBase.COMPATIBLE_DATE_FORMAT_PATTERN);
}
valueData = Const.trim(text);
valueData = valueMeta.convertData(originMeta, valueData);
}
if (isnull) {
valueData = null;
}
} catch (Exception e) {
valueData = null;
return false;
}
return true;
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class ValueMetaTest method testDateString8601.
@Test
public void testDateString8601() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Kaliningrad"));
ValueMetaInterface datValueMeta = new ValueMetaString();
datValueMeta.setConversionMask("yyyy-MM-dd'T'HH:mm:ss'.000Z'");
try {
Date res = datValueMeta.getDate("2011-03-13T02:23:18.000Z");
Calendar c = Calendar.getInstance();
c.setTime(res);
assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
assertEquals("Day should be 13", 13, c.get(Calendar.DAY_OF_MONTH));
assertEquals("Year should be 2011", 2011, c.get(Calendar.YEAR));
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
datValueMeta = new ValueMetaString();
datValueMeta.setConversionMask("yyyy-MM-dd'T'HH:mm:ss'.000Z'");
try {
datValueMeta.getDate("2011-03-13T02:23:18.000Z");
fail("Expected exception when trying to convert date");
} catch (Exception ex) {
}
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class ValueMetaTest method testDateStringDL8601.
@Test
public void testDateStringDL8601() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
ValueMetaInterface datValueMeta = new ValueMetaString();
datValueMeta.setConversionMask("yyyy-MM-dd'T'HH:mm:ss'.000'XXX");
try {
Date res = datValueMeta.getDate("2008-03-09T02:34:54.000Z");
// make sure it's what we expect...
Calendar c = Calendar.getInstance();
c.setTime(res);
assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
datValueMeta = new ValueMetaString();
datValueMeta.setConversionMask("yyyy-MM-dd'T'HH:mm:ss'.000'XXX");
try {
Date res = datValueMeta.getDate("2008-03-09T02:34:54.000+01:00");
// make sure it's what we expect...
Calendar c = Calendar.getInstance();
c.setTime(res);
assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
datValueMeta = new ValueMetaString();
datValueMeta.setConversionMask("yyyy-MM-dd'T'HH-mm-ss'.000'XXX");
try {
Date res = datValueMeta.getDate("2008-03-09T02-34-54.000-01:00");
// make sure it's what we expect...
Calendar c = Calendar.getInstance();
c.setTime(res);
assertEquals("Month should be 2", 2, c.get(Calendar.MONTH));
assertEquals("Day should be 8", 8, c.get(Calendar.DAY_OF_MONTH));
assertEquals("Year should be 2008", 2008, c.get(Calendar.YEAR));
} catch (Exception ex) {
fail("Error converting date." + ex.getMessage());
}
}
Aggregations