@Override public String getValue(){ return super.getValue(); }
@Override public String getValue(){ return super.getValue(); }
@Override public String getValue(){ return super.getValue(); }
private Expression filterConstant(Constant constant){ if(("FMTWIDTH").equals(constant.getValue())){ FieldRef fieldRef = new FieldRef(FieldName.create("FMTWIDTH")); return fieldRef; } return constant; } }
static public DataType getConstantDataType(Constant constant){ DataType dataType = constant.getDataType(); if(dataType == null){ dataType = TypeUtil.getConstantDataType(constant.getValue()); } return dataType; }
static private List<String> parseVector(FunctionExpression.Argument argument){ List<String> result = new ArrayList<>(); FunctionExpression vectorExpression = toVectorExpression(argument); List<FunctionExpression.Argument> objectArguments = vectorExpression.getArguments(); for(FunctionExpression.Argument objectArgument : objectArguments){ Constant constant = (Constant)objectArgument.getExpression(); result.add(constant.getValue()); } return result; }
static private Map<String, String> parseRevalue(FunctionExpression.Argument replaceArgument){ Map<String, String> result = new LinkedHashMap<>(); FunctionExpression vectorExpression = toVectorExpression(replaceArgument); List<FunctionExpression.Argument> objectArguments = vectorExpression.getArguments(); for(FunctionExpression.Argument objectArgument : objectArguments){ String from = objectArgument.getTag(); if(from == null){ throw new IllegalArgumentException(); } Constant constant = (Constant)objectArgument.getExpression(); if(constant.getDataType() != null && (DataType.STRING).equals(constant.getDataType())){ throw new IllegalArgumentException(); } String to = constant.getValue(); result.put(from, to); } return result; }
static public FieldValue evaluateConstant(Constant constant){ DataType dataType = getConstantDataType(constant); OpType opType = TypeUtil.getOpType(dataType); if(constant instanceof HasParsedValue){ HasParsedValue<?> hasParsedValue = (HasParsedValue<?>)constant; TypeInfo typeInfo = new TypeInfo(){ @Override public DataType getDataType(){ return dataType; } @Override public OpType getOpType(){ return opType; } }; return hasParsedValue.getValue(typeInfo); } return FieldValueUtil.create(dataType, opType, constant.getValue()); }
public void addField(Field<?> field){ RExpEncoder encoder = getEncoder(); Feature feature = new ContinuousFeature(encoder, field); if(field instanceof DerivedField){ DerivedField derivedField = (DerivedField)field; Expression expression = derivedField.getExpression(); if(expression instanceof Apply){ Apply apply = (Apply)expression; if(checkApply(apply, "pow", FieldRef.class, Constant.class)){ List<Expression> expressions = apply.getExpressions(); FieldRef fieldRef = (FieldRef)expressions.get(0); Constant constant = (Constant)expressions.get(1); try { int power = Integer.parseInt(constant.getValue()); feature = new PowerFeature(encoder, fieldRef.getField(), DataType.DOUBLE, power); } catch(NumberFormatException nfe){ // Ignored } } } } putFeature(field.getName(), feature); this.fields.add(field); }
Constant constant = (Constant)expression; String value = constant.getValue(); if(value.startsWith("-")){ value = value.substring(1);
Constant constant = (Constant)pmmlExpression; constant.setValue("-" + constant.getValue());
Constant constant = (Constant)expression; constant.setValue("-" + constant.getValue()); } else