本文整理汇总了Java中org.pentaho.di.core.row.ValueMetaInterface.setType方法的典型用法代码示例。如果您正苦于以下问题:Java ValueMetaInterface.setType方法的具体用法?Java ValueMetaInterface.setType怎么用?Java ValueMetaInterface.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.row.ValueMetaInterface
的用法示例。
在下文中一共展示了ValueMetaInterface.setType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFields
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
@Override
public void getFields(RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space) throws KettleStepException
{
// Input rows and output rows are different in the webservice step
//
if (!isPassingInputData())
{
r.clear();
}
// Add the output fields...
//
for (WebServiceField field : getFieldsOut())
{
ValueMetaInterface vValue = new ValueMeta(field.getName(), field.getType());
// If the type is unrecognized we give back the XML as a String...
//
if (field.getType()==ValueMetaInterface.TYPE_NONE) {
vValue.setType(ValueMetaInterface.TYPE_STRING);
}
vValue.setOrigin(name);
r.addValueMeta(vValue);
}
}
示例2: replayHistory
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public void replayHistory() {
int idx = wFields.getSelectionIndex();
if (idx >= 0) {
String fields[] = wFields.getItem(idx);
String dateString = fields[13];
try {
ValueMetaInterface stringValueMeta = replayDateMeta.clone();
stringValueMeta.setType(ValueMetaInterface.TYPE_STRING);
Date replayDate = stringValueMeta.getDate(dateString);
spoon.executeJob(jobGraph.getManagedObject(), true, false, replayDate, false);
} catch (KettleException e1) {
new ErrorDialog(jobGraph.getShell(),
Messages.getString("TransHistory.Error.ReplayingTransformation2"), //$NON-NLS-1$
Messages.getString("TransHistory.Error.InvalidReplayDate") + dateString, e1); //$NON-NLS-1$
}
}
}
示例3: replayHistory
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public void replayHistory() {
int idx = wFields.getSelectionIndex();
if (idx >= 0) {
String fields[] = wFields.getItem(idx);
String dateString = fields[13];
try {
ValueMetaInterface stringValueMeta = replayDateMeta.clone();
stringValueMeta.setType(ValueMetaInterface.TYPE_STRING);
Date replayDate = stringValueMeta.getDate(dateString);
spoon.executeTransformation(transGraph.getManagedObject(), true, false, false, false, false, replayDate, false);
} catch (KettleException e1) {
new ErrorDialog(transGraph.getShell(),
Messages.getString("TransHistory.Error.ReplayingTransformation2"), //$NON-NLS-1$
Messages.getString("TransHistory.Error.InvalidReplayDate") + dateString, e1); //$NON-NLS-1$
}
}
}
示例4: getValue
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
private ValueMetaAndData getValue(String valuename) throws KettleValueException {
int valtype = ValueMeta.getType(wValueType.getText());
ValueMetaAndData val = new ValueMetaAndData(valuename, wInputString.getText());
ValueMetaInterface valueMeta = val.getValueMeta();
Object valueData = val.getValueData();
valueMeta.setType(valtype);
int formatIndex = wFormat.getSelectionIndex();
valueMeta.setConversionMask(formatIndex >= 0 ? wFormat.getItem(formatIndex) : wFormat.getText());
valueMeta.setLength(Const.toInt(wLength.getText(), -1));
valueMeta.setPrecision(Const.toInt(wPrecision.getText(), -1));
ValueMetaInterface stringValueMeta = new ValueMeta(valuename, ValueMetaInterface.TYPE_STRING);
stringValueMeta.setConversionMetadata(valueMeta);
Object targetData = stringValueMeta.convertDataUsingConversionMetaData(valueData);
val.setValueData(targetData);
return val;
}
示例5: addField
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
/**
* 添加字段 <br/>
* @author jingma
* @param r 行
* @param name 字段名称
* @param type 类型
* @param trimType 去除空白规则
* @param origin 宿主
* @param comments 描述
* @param length 长度
*/
@SuppressWarnings("deprecation")
protected void addField(RowMetaInterface r, String name, int type,
int trimType, String origin, String comments, int length) {
ValueMetaInterface v = new ValueMeta();
v.setName(name.toUpperCase());
v.setType(type);
v.setTrimType(trimType);
v.setOrigin(origin);
v.setComments(comments);
if(length>0){
v.setLength(length);
}
r.addValueMeta(v);
}
示例6: getFields
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public void getFields(RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space) throws KettleStepException
{
for (int i=0;i<fieldDefinition.length;i++) {
FixedFileInputField field = fieldDefinition[i];
ValueMetaInterface valueMeta = new ValueMeta(field.getName(), field.getType());
valueMeta.setConversionMask(field.getFormat());
valueMeta.setTrimType(field.getTrimType());
valueMeta.setLength(field.getLength());
valueMeta.setPrecision(field.getPrecision());
valueMeta.setConversionMask(field.getFormat());
valueMeta.setDecimalSymbol(field.getDecimal());
valueMeta.setGroupingSymbol(field.getGrouping());
valueMeta.setCurrencySymbol(field.getCurrency());
valueMeta.setStringEncoding(space.environmentSubstitute(encoding));
if (lazyConversionActive) valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
// In case we want to convert Strings...
//
ValueMetaInterface storageMetadata = valueMeta.clone();
storageMetadata.setType(ValueMetaInterface.TYPE_STRING);
storageMetadata.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
valueMeta.setStorageMetadata(storageMetadata);
valueMeta.setOrigin(origin);
rowMeta.addValueMeta(valueMeta);
}
}
示例7: setValueMeta
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
private void setValueMeta(ValueMetaInterface v, int i, String name){
int type = fieldType[i];
if (type == ValueMetaInterface.TYPE_NONE) type = ValueMetaInterface.TYPE_STRING;
v.setType(type);
v.setLength(fieldLength[i]);
v.setPrecision(fieldPrecision[i]);
v.setOrigin(name);
v.setConversionMask(fieldFormat[i]);
v.setDecimalSymbol(fieldDecimal[i]);
v.setGroupingSymbol(fieldGroup[i]);
v.setCurrencySymbol(fieldCurrency[i]);
v.setTrimType(fieldTrimType[i]);
}
示例8: getFields
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public void getFields(RowMetaInterface rowMeta, String origin, RowMetaInterface[] info,
StepMeta nextStep, VariableSpace space) throws KettleStepException {
rowMeta.clear(); // Start with a clean slate, eats the input
for (int i = 0; i < inputFields.length; i++) {
TextFileInputField field = inputFields[i];
ValueMetaInterface valueMeta = new ValueMeta(field.getName(), field.getType());
valueMeta.setConversionMask(field.getFormat());
valueMeta.setLength(field.getLength());
valueMeta.setPrecision(field.getPrecision());
valueMeta.setConversionMask(field.getFormat());
valueMeta.setDecimalSymbol(field.getDecimalSymbol());
valueMeta.setGroupingSymbol(field.getGroupSymbol());
valueMeta.setCurrencySymbol(field.getCurrencySymbol());
valueMeta.setTrimType(field.getTrimType());
if (lazyConversionActive) {
valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
}
valueMeta.setStringEncoding(space.environmentSubstitute(encoding));
// In case we want to convert Strings...
// Using a copy of the valueMeta object means that the inner and outer representation
// format is the same.
// Preview will show the data the same way as we read it.
// This layout is then taken further down the road by the metadata through the transformation.
//
ValueMetaInterface storageMetadata = valueMeta.clone();
storageMetadata.setType(ValueMetaInterface.TYPE_STRING);
storageMetadata.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
storageMetadata
.setLength(-1, -1); // we don't really know the lengths of the strings read in advance.
valueMeta.setStorageMetadata(storageMetadata);
valueMeta.setOrigin(origin);
rowMeta.addValueMeta(valueMeta);
}
if (!Const.isEmpty(filenameField) && includingFilename) {
ValueMetaInterface filenameMeta =
new ValueMeta(filenameField, ValueMetaInterface.TYPE_STRING);
filenameMeta.setOrigin(origin);
if (lazyConversionActive) {
filenameMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
filenameMeta
.setStorageMetadata(new ValueMeta(filenameField, ValueMetaInterface.TYPE_STRING));
}
rowMeta.addValueMeta(filenameMeta);
}
if (!Const.isEmpty(rowNumField)) {
ValueMetaInterface rowNumMeta = new ValueMeta(rowNumField, ValueMetaInterface.TYPE_INTEGER);
rowNumMeta.setLength(10);
rowNumMeta.setOrigin(origin);
rowMeta.addValueMeta(rowNumMeta);
}
}
示例9: init
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public boolean init(StepMetaInterface smi, StepDataInterface sdi)
{
meta=(ValidatorMeta)smi;
data=(ValidatorData)sdi;
if (super.init(smi, sdi))
{
data.constantsMeta = new ValueMetaInterface[meta.getValidations().length];
data.minimumValue = new Object[meta.getValidations().length];
data.maximumValue = new Object[meta.getValidations().length];
data.listValues = new Object[meta.getValidations().length][];
data.patternExpected = new Pattern[meta.getValidations().length];
data.patternDisallowed = new Pattern[meta.getValidations().length];
for (int i=0;i<meta.getValidations().length;i++) {
Validation field = meta.getValidations()[i];
data.constantsMeta[i] = new ValueMeta(field.getFieldName(), field.getDataType());
data.constantsMeta[i].setConversionMask(field.getConversionMask());
data.constantsMeta[i].setDecimalSymbol(field.getDecimalSymbol());
data.constantsMeta[i].setGroupingSymbol(field.getGroupingSymbol());
ValueMetaInterface stringMeta = data.constantsMeta[i].clone();
stringMeta.setType(ValueMetaInterface.TYPE_STRING);
try {
data.minimumValue[i] = Const.isEmpty(field.getMinimumValue()) ? null : data.constantsMeta[i].convertData(stringMeta, field.getMinimumValue());
data.maximumValue[i] = Const.isEmpty(field.getMaximumValue()) ? null : data.constantsMeta[i].convertData(stringMeta, field.getMaximumValue());
int listSize = field.getAllowedValues()!=null ? field.getAllowedValues().length : 0;
data.listValues[i] = new Object[listSize];
for (int s=0;s<listSize;s++) {
data.listValues[i][s] = Const.isEmpty(field.getAllowedValues()[s]) ? null : data.constantsMeta[i].convertData(stringMeta, field.getAllowedValues()[s]);
}
} catch (KettleValueException e) {
if (field.getDataType()==ValueMetaInterface.TYPE_NONE) {
logError(Messages.getString("Validator.Exception.SpecifyDataType"), e);
}
else {
logError(Messages.getString("Validator.Exception.DataConversionErrorEncountered"), e);
}
return false;
}
if (!Const.isEmpty(field.getRegularExpression())) {
data.patternExpected[i] = Pattern.compile(field.getRegularExpression());
}
if (!Const.isEmpty(field.getRegularExpressionNotAllowed())) {
data.patternDisallowed[i] = Pattern.compile(field.getRegularExpressionNotAllowed());
}
}
return true;
}
return false;
}
示例10: getMetadataFields
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public void getMetadataFields(RowMetaInterface inputRowMeta, String name)
{
if (meta!=null && meta.length>0) // METADATA mode: change the meta-data of the values mentioned...
{
for (int i=0;i<meta.length;i++)
{
SelectMetadataChange metaChange = meta[i];
int idx = inputRowMeta.indexOfValue(metaChange.getName());
if (idx>=0) // We found the value
{
// This is the value we need to change:
ValueMetaInterface v = inputRowMeta.getValueMeta(idx);
// Do we need to rename ?
if (!v.getName().equals(metaChange.getRename()) && !Const.isEmpty(metaChange.getRename()))
{
v.setName(metaChange.getRename());
v.setOrigin(name);
}
// Change the type?
if (metaChange.getType()!=ValueMetaInterface.TYPE_NONE && v.getType()!=metaChange.getType())
{
v.setType(metaChange.getType());
// This also moves the data to normal storage type
//
v.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
}
if (metaChange.getLength() != -2) { v.setLength(metaChange.getLength()); v.setOrigin(name); }
if (metaChange.getPrecision() != -2) { v.setPrecision(metaChange.getPrecision()); v.setOrigin(name); }
if (metaChange.getStorageType() >= 0) { v.setStorageType(metaChange.getStorageType()); v.setOrigin(name); }
if (!Const.isEmpty(metaChange.getConversionMask()))
{
v.setConversionMask(metaChange.getConversionMask());
v.setOrigin(name);
}
if (!Const.isEmpty(metaChange.getDecimalSymbol()))
{
v.setDecimalSymbol(metaChange.getDecimalSymbol());
v.setOrigin(name);
}
if (!Const.isEmpty(metaChange.getGroupingSymbol()))
{
v.setGroupingSymbol(metaChange.getGroupingSymbol());
v.setOrigin(name);
}
if (!Const.isEmpty(metaChange.getCurrencySymbol()))
{
v.setCurrencySymbol(metaChange.getCurrencySymbol());
v.setOrigin(name);
}
}
}
}
}
示例11: getFields
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public void getFields(RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space) throws KettleStepException
{
rowMeta.clear(); // Start with a clean slate, eats the input
for (int i=0;i<inputFields.length;i++) {
TextFileInputField field = inputFields[i];
ValueMetaInterface valueMeta = new ValueMeta(field.getName(), field.getType());
valueMeta.setConversionMask( field.getFormat() );
valueMeta.setLength( field.getLength() );
valueMeta.setPrecision( field.getPrecision() );
valueMeta.setConversionMask( field.getFormat() );
valueMeta.setDecimalSymbol( field.getDecimalSymbol() );
valueMeta.setGroupingSymbol( field.getGroupSymbol() );
valueMeta.setCurrencySymbol( field.getCurrencySymbol() );
valueMeta.setTrimType( field.getTrimType() );
if (lazyConversionActive) valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
valueMeta.setStringEncoding(space.environmentSubstitute(encoding));
// In case we want to convert Strings...
// Using a copy of the valueMeta object means that the inner and outer representation format is the same.
// Preview will show the data the same way as we read it.
// This layout is then taken further down the road by the metadata through the transformation.
//
ValueMetaInterface storageMetadata = valueMeta.clone();
storageMetadata.setType(ValueMetaInterface.TYPE_STRING);
storageMetadata.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
storageMetadata.setLength(-1,-1); // we don't really know the lengths of the strings read in advance.
valueMeta.setStorageMetadata(storageMetadata);
valueMeta.setOrigin(origin);
rowMeta.addValueMeta(valueMeta);
}
if (!Const.isEmpty(filenameField) && includingFilename) {
ValueMetaInterface filenameMeta = new ValueMeta(filenameField, ValueMetaInterface.TYPE_STRING);
filenameMeta.setOrigin(origin);
if (lazyConversionActive) {
filenameMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
filenameMeta.setStorageMetadata(new ValueMeta(filenameField, ValueMetaInterface.TYPE_STRING));
}
rowMeta.addValueMeta(filenameMeta);
}
if (!Const.isEmpty(rowNumField)) {
ValueMetaInterface rowNumMeta = new ValueMeta(rowNumField, ValueMetaInterface.TYPE_INTEGER);
rowNumMeta.setLength(10);
rowNumMeta.setOrigin(origin);
rowMeta.addValueMeta(rowNumMeta);
}
}
示例12: createFlattenedOutput
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
/**
* Retrieve the rows from the opened query.
* Also create a description of the flattened output of the query.
* This call populated rowMetaInterface and rows
* The query needs to be opened beforehand.
* @throws KettleDatabaseException in case something goes wrong
*
* TODO: this is not quite working for our purposes.
*/
public void createFlattenedOutput() throws KettleDatabaseException {
final Axis[] axes = result.getAxes();
rows = new ArrayList<List<Object>>();
headings = new ArrayList<String>();
// Compute headings. Each heading is a hierarchy name. If there are say
// 2 members on the columns, and 3 members on the rows axis, then there
// will be 5 headings.
//
for (Axis axis : axes) {
final List<Position> positions = axis.getPositions();
if (positions.isEmpty()) {
// Result set is empty. There is no data to print, and we cannot
// even deduce column headings.
return;
}
for (Member member : positions.get(0)) {
Hierarchy hierarchy = member.getHierarchy();
headings.add(hierarchy.getUniqueName());
}
}
int[] coords = new int[axes.length];
outputFlattenedRecurse(result, rows, new ArrayList<Object>(), coords, 0);
outputRowMeta = new RowMeta();
// Just scan the first row to see what data types we received...
//
for (int i=0 ; i<rows.size() && i<1 ; i++) {
List<Object> rowValues = rows.get(i);
for (int c=0 ;c<rowValues.size();c++) {
ValueMetaInterface valueMeta = new ValueMeta(headings.get(c));
Object valueData = rowValues.get(c);
if (valueData instanceof String) {
valueMeta.setType(ValueMetaInterface.TYPE_STRING);
}
else if (valueData instanceof Date) {
valueMeta.setType(ValueMetaInterface.TYPE_DATE);
}
else if (valueData instanceof Boolean) {
valueMeta.setType(ValueMetaInterface.TYPE_BOOLEAN);
}
else if (valueData instanceof Long) {
valueMeta.setType(ValueMetaInterface.TYPE_INTEGER);
}
else if (valueData instanceof Double) {
valueMeta.setType(ValueMetaInterface.TYPE_NUMBER);
}
else if (valueData instanceof BigDecimal) {
valueMeta.setType(ValueMetaInterface.TYPE_BIGNUMBER);
}
else {
throw new KettleDatabaseException("Unhandled data type found '"+valueData.getClass().toString()+"'");
}
outputRowMeta.addValueMeta(valueMeta);
}
}
// Now that we painstakingly found the metadata that comes out of the Mondrian database, cache it please...
//
DBCacheEntry cacheEntry = new DBCacheEntry(databaseMeta.getName(), queryString);
DBCache.getInstance().put(cacheEntry, outputRowMeta);
}
示例13: processRow
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
Object[] rowData;
if (data.readsRows)
{
rowData = getRow();
if (rowData==null)
{
setOutputDone();
return false;
}
}
else
{
rowData=RowDataUtil.allocateRowData(0);
incrementLinesRead();
}
// initialize
if (first && rowData!=null)
{
first=false;
// Make output meta data
//
if (data.readsRows) {
data.inputRowMeta = getInputRowMeta();
}
else {
data.inputRowMeta = new RowMeta();
}
data.outputRowMeta = data.inputRowMeta.clone();
meta.getFields(data.outputRowMeta, getStepname(), null, null, this);
// Create a copy of the output row metadata to do the data conversion...
//
data.conversionMeta = data.outputRowMeta.clone();
for (ValueMetaInterface valueMeta : data.conversionMeta.getValueMetaList()) {
valueMeta.setType(ValueMetaInterface.TYPE_STRING);
}
// Add the variables to the row...
//
// Keep the Object[] for speed. Although this step will always be used in "small" amounts, there's always going to be those cases where performance is required.
//
data.extraData = new Object[meta.getFieldName().length];
for (int i=0;i<meta.getFieldName().length;i++)
{
String newValue = environmentSubstitute(meta.getVariableString()[i]);
if (log.isDetailed()) logDetailed("field ["+meta.getFieldName()[i]+"] has value ["+newValue+"]");
// Convert the data to the desired data type...
//
ValueMetaInterface targetMeta = data.outputRowMeta.getValueMeta(data.inputRowMeta.size()+i);
ValueMetaInterface sourceMeta = data.conversionMeta.getValueMeta(data.inputRowMeta.size()+i); // String type + conversion masks, symbols, trim type, etc
data.extraData[i] = targetMeta.convertData(sourceMeta, newValue);
}
}
rowData = RowDataUtil.addRowData(rowData, data.inputRowMeta.size(), data.extraData);
putRow(data.outputRowMeta, rowData);
if (!data.readsRows) // Just one row and then stop!
{
setOutputDone();
return false;
}
return true;
}
示例14: getMetadataFields
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public void getMetadataFields(RowMetaInterface inputRowMeta, String name)
{
if (meta!=null && meta.length>0) // METADATA mode: change the meta-data of the values mentioned...
{
for (int i=0;i<meta.length;i++)
{
SelectMetadataChange metaChange = meta[i];
int idx = inputRowMeta.indexOfValue(metaChange.getName());
if (idx>=0) // We found the value
{
// This is the value we need to change:
ValueMetaInterface v = inputRowMeta.getValueMeta(idx);
// Do we need to rename ?
if (!v.getName().equals(metaChange.getRename()) && !Const.isEmpty(metaChange.getRename()))
{
v.setName(metaChange.getRename());
v.setOrigin(name);
}
// Change the type?
if (metaChange.getType()!=ValueMetaInterface.TYPE_NONE && v.getType()!=metaChange.getType())
{
v.setType(metaChange.getType());
// This also moves the data to normal storage type
//
v.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
}
if (metaChange.getLength() != -2) { v.setLength(metaChange.getLength()); v.setOrigin(name); }
if (metaChange.getPrecision() != -2) { v.setPrecision(metaChange.getPrecision()); v.setOrigin(name); }
if (metaChange.getStorageType() >= 0) { v.setStorageType(metaChange.getStorageType()); v.setOrigin(name); }
if (!Const.isEmpty(metaChange.getConversionMask()))
{
v.setConversionMask(metaChange.getConversionMask());
v.setOrigin(name);
}
v.setDateFormatLenient(metaChange.isDateFormatLenient());
if (!Const.isEmpty(metaChange.getEncoding()))
{
v.setStringEncoding(metaChange.getEncoding());
v.setOrigin(name);
}
if (!Const.isEmpty(metaChange.getDecimalSymbol()))
{
v.setDecimalSymbol(metaChange.getDecimalSymbol());
v.setOrigin(name);
}
if (!Const.isEmpty(metaChange.getGroupingSymbol()))
{
v.setGroupingSymbol(metaChange.getGroupingSymbol());
v.setOrigin(name);
}
if (!Const.isEmpty(metaChange.getCurrencySymbol()))
{
v.setCurrencySymbol(metaChange.getCurrencySymbol());
v.setOrigin(name);
}
}
}
}
}
示例15: getFields
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public RowMeta getFields(String searchBase) throws KettleException {
RowMeta fields = new RowMeta();
List<String> fieldsl = new ArrayList<String>();
try {
search(searchBase, null, 0, null, SEARCH_SCOPE_SUBTREE_SCOPE);
Attributes attributes = null;
fieldsl = new ArrayList<String>();
while ((attributes = getAttributes()) != null) {
NamingEnumeration<? extends Attribute> ne = attributes.getAll();
while (ne.hasMore()) {
Attribute attr = ne.next();
String fieldName = attr.getID();
if (!fieldsl.contains(fieldName)) {
fieldsl.add(fieldName);
// Get fieldname
ValueMetaInterface value = new ValueMeta(fieldName);
String attributeValue = attr.get().toString();
// Try to get the Type
if (IsDate(attributeValue)) {
value.setType(ValueMeta.TYPE_DATE);
} else if (IsInteger(attributeValue)) {
value.setType(ValueMeta.TYPE_INTEGER);
} else if (IsNumber(attributeValue)) {
value.setType(ValueMeta.TYPE_NUMBER);
} else {
value.setType(ValueMeta.TYPE_STRING);
}
fields.addValueMeta(value);
}
}
}
return fields;
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "LDAPConnection.Error.RetrievingFields"));
} finally {
fieldsl = null;
}
}