Java Code Examples for org.pentaho.di.trans.steps.textfileinput.TextFileInputField#setPrecision()
The following examples show how to use
org.pentaho.di.trans.steps.textfileinput.TextFileInputField#setPrecision() .
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: ParGzipCsvInputMetaTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public TextFileInputField getTestObject() { TextFileInputField rtn = new TextFileInputField(); rtn.setCurrencySymbol( UUID.randomUUID().toString() ); rtn.setDecimalSymbol( UUID.randomUUID().toString() ); rtn.setFormat( UUID.randomUUID().toString() ); rtn.setGroupSymbol( UUID.randomUUID().toString() ); rtn.setName( UUID.randomUUID().toString() ); rtn.setTrimType( rand.nextInt( 4 ) ); rtn.setPrecision( rand.nextInt( 9 ) ); rtn.setLength( rand.nextInt( 50 ) ); rtn.setType( rand.nextInt( 7 ) ); // Note - these fields aren't serialized by the meta class ... cannot test for them // rtn.setRepeated( rand.nextBoolean() ); // rtn.setSamples( new String[] { UUID.randomUUID().toString(), UUID.randomUUID().toString(), // UUID.randomUUID().toString() } ); // rtn.setNullString( UUID.randomUUID().toString() ); // rtn.setIfNullValue( UUID.randomUUID().toString() ); // rtn.setIgnored( rand.nextBoolean() ); // rtn.setPosition( rand.nextInt( 10 ) ); return rtn; }
Example 2
Source File: TextFileInputFieldValidator.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public TextFileInputField getTestObject() { TextFileInputField rtn = new TextFileInputField( UUID.randomUUID().toString(), rand.nextInt(), rand.nextInt() ); rtn.setType( rand.nextInt( 7 ) ); rtn.setCurrencySymbol( UUID.randomUUID().toString() ); rtn.setDecimalSymbol( UUID.randomUUID().toString() ); rtn.setFormat( UUID.randomUUID().toString() ); rtn.setGroupSymbol( UUID.randomUUID().toString() ); rtn.setIfNullValue( UUID.randomUUID().toString() ); rtn.setIgnored( rand.nextBoolean() ); rtn.setNullString( UUID.randomUUID().toString() ); rtn.setPrecision( rand.nextInt( 9 ) ); rtn.setRepeated( rand.nextBoolean() ); rtn.setTrimType( rand.nextInt( ValueMetaString.trimTypeDesc.length ) ); return rtn; }
Example 3
Source File: CsvInputMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public void injectStepMetadataEntries( List<StepInjectionMetaEntry> metadata ) { for ( StepInjectionMetaEntry entry : metadata ) { KettleAttributeInterface attr = findAttribute( entry.getKey() ); // Set top level attributes... // if ( entry.getValueType() != ValueMetaInterface.TYPE_NONE ) { if ( attr.getKey().equals( "FILENAME" ) ) { filename = (String) entry.getValue(); } else if ( attr.getKey().equals( "FILENAME_FIELD" ) ) { filenameField = (String) entry.getValue(); } else if ( attr.getKey().equals( "ROW_NUM_FIELD" ) ) { rowNumField = (String) entry.getValue(); } else if ( attr.getKey().equals( "HEADER_PRESENT" ) ) { headerPresent = (Boolean) entry.getValue(); } else if ( attr.getKey().equals( "DELIMITER" ) ) { delimiter = (String) entry.getValue(); } else if ( attr.getKey().equals( "ENCLOSURE" ) ) { enclosure = (String) entry.getValue(); } else if ( attr.getKey().equals( "BUFFERSIZE" ) ) { bufferSize = (String) entry.getValue(); } else if ( attr.getKey().equals( "LAZY_CONVERSION" ) ) { lazyConversionActive = (Boolean) entry.getValue(); } else if ( attr.getKey().equals( "PARALLEL" ) ) { runningInParallel = (Boolean) entry.getValue(); } else if ( attr.getKey().equals( "NEWLINE_POSSIBLE" ) ) { newlinePossibleInFields = (Boolean) entry.getValue(); } else if ( attr.getKey().equals( "ADD_FILENAME_RESULT" ) ) { isaddresult = (Boolean) entry.getValue(); } else if ( attr.getKey().equals( "FORMAT" ) ) { fileFormat = (String) entry.getValue(); } else if ( attr.getKey().equals( "ENCODING" ) ) { encoding = (String) entry.getValue(); } else { throw new RuntimeException( "Unhandled metadata injection of attribute: " + attr.toString() + " - " + attr.getDescription() ); } } else { if ( attr.getKey().equals( "FIELDS" ) ) { // This entry contains a list of lists... // Each list contains a single CSV input field definition (one line in the dialog) // List<StepInjectionMetaEntry> inputFieldEntries = entry.getDetails(); inputFields = new TextFileInputField[inputFieldEntries.size()]; for ( int row = 0; row < inputFieldEntries.size(); row++ ) { StepInjectionMetaEntry inputFieldEntry = inputFieldEntries.get( row ); TextFileInputField inputField = new TextFileInputField(); List<StepInjectionMetaEntry> fieldAttributes = inputFieldEntry.getDetails(); for ( int i = 0; i < fieldAttributes.size(); i++ ) { StepInjectionMetaEntry fieldAttribute = fieldAttributes.get( i ); KettleAttributeInterface fieldAttr = findAttribute( fieldAttribute.getKey() ); String attributeValue = (String) fieldAttribute.getValue(); if ( fieldAttr.getKey().equals( "FIELD_NAME" ) ) { inputField.setName( attributeValue ); } else if ( fieldAttr.getKey().equals( "FIELD_TYPE" ) ) { inputField.setType( ValueMetaFactory.getIdForValueMeta( attributeValue ) ); } else if ( fieldAttr.getKey().equals( "FIELD_FORMAT" ) ) { inputField.setFormat( attributeValue ); } else if ( fieldAttr.getKey().equals( "FIELD_LENGTH" ) ) { inputField.setLength( attributeValue == null ? -1 : Integer.parseInt( attributeValue ) ); } else if ( fieldAttr.getKey().equals( "FIELD_PRECISION" ) ) { inputField.setPrecision( attributeValue == null ? -1 : Integer.parseInt( attributeValue ) ); } else if ( fieldAttr.getKey().equals( "FIELD_CURRENCY" ) ) { inputField.setCurrencySymbol( attributeValue ); } else if ( fieldAttr.getKey().equals( "FIELD_DECIMAL" ) ) { inputField.setDecimalSymbol( attributeValue ); } else if ( fieldAttr.getKey().equals( "FIELD_GROUP" ) ) { inputField.setGroupSymbol( attributeValue ); } else if ( fieldAttr.getKey().equals( "FIELD_TRIM_TYPE" ) ) { inputField.setTrimType( ValueMetaString.getTrimTypeByCode( attributeValue ) ); } else { throw new RuntimeException( "Unhandled metadata injection of attribute: " + fieldAttr.toString() + " - " + fieldAttr.getDescription() ); } } inputFields[row] = inputField; } } } } }