public boolean shouldBeObfuscated() { return getType() == PropertySimpleType.PASSWORD; }
/** * Return a value object for the passed property with the passed definition * @param prop Property to evaluate * @param propDef Definition to determine the type from * @return The value object */ Object getObjectForProperty(PropertySimple prop, PropertyDefinitionSimple propDef) { PropertySimpleType type = propDef.getType(); return getObjectForProperty(prop, type); }
private static CtClass getSimpleTypeClass(ClassPool cp, PropertyDefinitionSimple simple) throws NotFoundException { Class<?> paramType = null; switch (simple.getType()) { case STRING: case LONG_STRING: case PASSWORD: case FILE: case DIRECTORY: paramType = String.class; break; case BOOLEAN: paramType = Boolean.TYPE; break; case INTEGER: paramType = Integer.TYPE; break; case LONG: paramType = Long.TYPE; break; case FLOAT: paramType = Float.TYPE; break; case DOUBLE: paramType = Double.TYPE; break; } return cp.get(paramType.getName()); }
private Object getObjectWithType(PropertyDefinitionSimple pds, String val) { PropertySimpleType type = pds.getType(); Object ret; switch (type) { case STRING: ret = val; break; case INTEGER: ret = Integer.valueOf(val); break; case BOOLEAN: ret = Boolean.valueOf(val); break; case LONG: ret = Long.valueOf(val); break; case FLOAT: ret = Float.valueOf(val); break; case DOUBLE: ret = Double.valueOf(val); break; default: ret = val; } return ret; }
private static void addRepresentation(PropertyDefinitionSimple p, StringBuilder bld) { bld.append(p.getName()).append(p.getType().name()); }
PropertySimpleType type = definition.getType(); String val = property.getStringValue();
protected Property createPropertySimple(PropertyDefinitionSimple propDefSimple, Augeas augeas, AugeasNode node) { Object value; if (propDefSimple.getType() == PropertySimpleType.LONG_STRING) { List<String> childPaths = augeas.match(node.getPath()); if (childPaths.isEmpty()) { return null; } StringBuilder propValue = new StringBuilder(); for (String childPath : childPaths) { String childValue = augeas.get(childPath); propValue.append(childValue).append("\n"); } // Chop the final newline char. propValue.deleteCharAt(propValue.length() - 1); value = propValue.toString(); } else { value = toPropertyValue(propDefSimple, augeas, node); } return new PropertySimple(propDefSimple.getName(), value); }
private List<Validator> createSubValidators() { List<Validator> subValidators = new ArrayList<Validator>(); subValidators.add(new LengthValidator(PropertySimple.MAX_VALUE_LENGTH)); if (this.propertyDefinition != null) { switch (this.propertyDefinition.getType()) { case INTEGER: { subValidators.add(new LongRangeValidator(Integer.MAX_VALUE, Integer.MIN_VALUE)); break; } case LONG: { subValidators.add(new LongRangeValidator(Long.MAX_VALUE, Long.MIN_VALUE)); break; } case FLOAT: { subValidators.add(new DoubleRangeValidator(Float.MAX_VALUE, Float.MIN_VALUE)); break; } case DOUBLE: { subValidators.add(new DoubleRangeValidator(Double.MAX_VALUE, Double.MIN_VALUE)); break; // There is no need for type-based validators for booleans or enums, because the UI input controls // (e.g. radio buttons or pulldown menus) prevent invalid values from being entered. } } for (Constraint constraint : this.propertyDefinition.getConstraints()) { subValidators.add(createValidator(constraint)); } } return subValidators; }
@Override public String toString() { return "SimpleProperty[" + getName() + "] (Type: " + getType() + ")" + ((getPropertyGroupDefinition() != null) ? ("(Group: " + getPropertyGroupDefinition().getName() + ")") : ""); } }
switch (propDef.getType()) { case DOUBLE: try {
if (pd instanceof PropertyDefinitionSimple) { PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd; sender.getConfigDefinition().put(pds.getName(),pds.getType().name());
if (propertyDefinition.getType().equals(PropertySimpleType.LONG)) { Long num = Long.parseLong(property.getStringValue()); } else {
protected void setNodeFromPropertySimple(Augeas augeas, AugeasNode node, PropertyDefinitionSimple propDefSimple, PropertySimple propSimple) { String value = toNodeValue(augeas, node, propDefSimple, propSimple); if (propDefSimple.getType() == PropertySimpleType.LONG_STRING) { // First remove the existing items. //get the node position first, needed to say insert after node x String varName = "path"; String nodeExpression = getNodeInsertionPoint(augeas, node, propDefSimple, propSimple); augeas.defineNode(varName, nodeExpression, null); augeas.remove(node.getPath()); // Now add the updated items. String[] tokens = value.trim().split("\\s+"); for (int i = tokens.length; i > 0; i--) { String itemValue = tokens[i - 1]; if (itemValue != null && itemValue.trim().length() != 0) { augeas.insert("$" + varName, node.getName(), false); augeas.set(node.getPath() + "[1]", itemValue); } } } else { // Update the value of the existing node. augeas.set(node.getPath(), value); } }
/** * Copies the parameters of an OperationDefinition into to an object that can be * returned to a REST-client, so that this knows which fields are to be filled in, * of which type they are and which ones are required * @param def OperationsDefinition to "copy" * @param definitionRest The definition to fill in */ private void copyParamsForDefinition(OperationDefinition def, OperationDefinitionRest definitionRest) { ConfigurationDefinition cd = def.getParametersConfigurationDefinition(); if (cd==null) { return; } for (Map.Entry<String,PropertyDefinition> entry : cd.getPropertyDefinitions().entrySet()) { PropertyDefinition pd = entry.getValue(); if (pd instanceof PropertyDefinitionSimple) { PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pd; SimplePropDef prop = new SimplePropDef(); prop.setName(pds.getName()); prop.setRequired(pds.isRequired()); prop.setType(pds.getType()); prop.setDefaultValue(pds.getDefaultValue()); definitionRest.addParam(prop); } log.debug("copyParams: " + pd.getName() + " not yet supported"); } }
public static UIInput createInput(PropertyDefinitionSimple propertyDefinitionSimple) { UIInput input; PropertySimpleType type = (propertyDefinitionSimple != null) ? propertyDefinitionSimple.getType() : PropertySimpleType.STRING; switch (type) {
PropertyDefinitionSimple newPDS = (PropertyDefinitionSimple) newProperty; existingPDS.setType(newPDS.getType());
String p = context.getResourceType().getResourceConfigurationDefinition().getDefaultTemplate().getConfiguration().getSimpleValue(key); log.debug("Using default value for " + key + " value: " + def.getDefaultValue()); switch (def.getType()) { case INTEGER: { pro.setIntegerValue(Integer.valueOf(p));
if (propertyDefinitionSimple.getType() == PropertySimpleType.PASSWORD) { PropertySimple propertySimple = parentPropertyMap.getSimple(propertyDefinition.getName()); propertySimple.mask();
.getName()); if (!(ignoreReadOnly && def.isReadOnly())) { switch (def.getType()) { case INTEGER: { attribute.setValue(property.getIntegerValue());