prop.setType(PropertyType.valueOf(type)); if (values.length == 1) { prop.setValue(values[0]); } else { prop.setMultiValue(values); } else { prop.setType(PropertyType.from(value.getClass())); prop.setValue(value.toString()); } else { prop.setType(PropertyType.from(value.getClass())); prop.setValue(value.toString());
final PropertyDescription pd = new PropertyDescription(cad); pd.setName("service.ranking"); pd.setValue(String.valueOf(order)); pd.setType(PropertyType.Integer); if (metatype) { final PropertyDescription pdPattern = new PropertyDescription(cad); pdPattern.setName("sling.filter.pattern"); pdPattern.setValue(pattern); pdPattern.setType(PropertyType.String); if (metatype) { pd2.setName("sling.filter.scope"); if ( scopes.length == 1 ) { pd2.setValue(scopes[0]); } else { pd2.setMultiValue(scopes);
/** * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) */ @Override public void characters(char[] ch, int start, int length) throws SAXException { if (this.pendingProperty != null) { final String text = new String(ch, start, length); if (this.pendingProperty.getValue() == null) { this.pendingProperty.setValue(text); } else { this.pendingProperty.setValue(this.pendingProperty.getValue() + text); } } } }
/** * Add global properties (if not already defined in the component) */ private void processGlobalProperties(final ClassDescription desc, final Map<String, PropertyDescription> allProperties) { // apply pre configured global properties if ( this.options.getProperties() != null ) { for(final Map.Entry<String, String> entry : this.options.getProperties().entrySet()) { final String propName = entry.getKey(); final String value = entry.getValue(); // check if the service already provides this property if ( value != null && !allProperties.containsKey(propName) ) { final PropertyDescription p = new PropertyDescription(null); p.setName(propName); p.setValue(value); p.setType(PropertyType.String); allProperties.put(propName, p); } } } }
/** Generates a property descriptor of type {@link PropertyType} */ private void generatePropertyDescriptor(final ClassAnnotation cad, final ClassDescription classDescription, final boolean metatype, final String propertyName, final String propertyDescriptorName, PropertyType propertyType, String label, String description, boolean isArray) { final PropertyDescription pd = new PropertyDescription(cad); pd.setName(propertyDescriptorName); pd.setLabel(label); pd.setDescription(description); pd.setType(propertyType); if(isArray) { final String[] values = (String[]) cad.getValue(propertyName); pd.setMultiValue(values); pd.setUnbounded(PropertyUnbounded.ARRAY); pd.setCardinality(Integer.MAX_VALUE); } else { final Object propertyVal = cad.getValue(propertyName); String pdValue = (propertyVal instanceof String) ? (String) propertyVal : propertyVal!=null ? propertyVal.toString() : null; pd.setValue(pdValue); pd.setUnbounded(PropertyUnbounded.DEFAULT); } if (!metatype) { pd.setPrivate(true); } classDescription.add(pd); }
describedClass.add(pd); pd.setName(key); pd.setValue(value); pd.setType(propType); pd.setUnbounded(PropertyUnbounded.DEFAULT);
@Override public AbstractDescription clone() { final PropertyDescription cd = new PropertyDescription(this.annotation); cd.setName(this.getName()); cd.setLabel(this.getLabel()); cd.setDescription(this.getDescription()); if ( this.getValue() != null ) { cd.setValue(this.getValue()); } else { cd.setMultiValue(this.getMultiValue()); } cd.setType(this.getType()); cd.setUnbounded(this.getUnbounded()); cd.setCardinality(this.getCardinality()); cd.setPrivate(this.isPrivate()); cd.setOptions(this.getOptions()); return cd; } }