private void addPropertiesFromComponentType(Component component, Monitor monitor) { // Create component property for each property if (component.getImplementation() != null) { for (Property property : component.getImplementation().getProperties()) { // check for duplicate property names in implementation if (property != component.getImplementation().getProperty(property.getName())){ Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "DuplicateImplementationPropertyName", component.getName(), property.getName()); } ComponentProperty componentProperty = (ComponentProperty)component.getProperty(property.getName()); // if the component doesn't have a property with the same name as // the component type property then create one if (componentProperty == null) { componentProperty = assemblyFactory.createComponentProperty(); componentProperty.setName(property.getName()); componentProperty.setValue(property.getValue()); componentProperty.setMany(property.isMany()); componentProperty.setMustSupply(property.isMustSupply()); componentProperty.setXSDElement(property.getXSDElement()); componentProperty.setXSDType(property.getXSDType()); componentProperty.setProperty(property); component.getProperties().add(componentProperty); } } } }
theProperty.setName(varName); theProperty.setXSDType(typeQName); theProperty.setXSDElement(elementQName); return theProperty;
protected Property createProperty(Property property) { Property newProperty; try { newProperty = (Property)property.clone(); } catch (CloneNotSupportedException e) { throw new AssertionError(e); // should not ever happen } return newProperty; }
public static Property createProperty(AssemblyFactory assemblyFactory, String name, Class<?> javaClass, Type genericType) { Property property = assemblyFactory.createProperty(); property.setName(name); property.setMany(true); if (javaClass.isArray()) { Class<?> propType = javaClass.getComponentType(); property.setDataType(dt); } else { if (genericType instanceof ParameterizedType) { Class<?> propType = JavaIntrospectionHelper.getErasure(genericPropType); DataType dt = new DataTypeImpl(null, propType, genericPropType, XMLType.UNKNOWN); property.setDataType(dt); } else { property.setDataType(dt); property.setDataType(dt);
public Object getInstance() throws ObjectCreationException { // TUSCANY-3791 if (result != null){ return result; } if (isSimpleType) { try { result = simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null); } catch (NumberFormatException ex) { throw new ObjectCreationException("Failed to create instance for property " + property.getName() + " with value " + propertyValue, ex); } catch (IllegalArgumentException ex) { throw new ObjectCreationException("Failed to create instance for property " + property.getName() + " with value " + propertyValue, ex); } } else { result = mediator.mediate(propertyValue, sourceDataType, targetDataType, null); } return result; } }
Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), property.isMany(), reader, context); property.setValue(value); contract.getExtensions().add(extension); } else if (property != null) { property.getExtensions().add(extension); } else { if (componentType instanceof Extensible) {
if (!componentTypeProperty.isMustSupply() && componentProperty.isMustSupply()) { Monitor.error(monitor, this, componentProperty.setMustSupply(componentTypeProperty.isMustSupply()); componentProperty.setValue(componentTypeProperty.getValue()); componentTypeProperty.setValue(componentProperty.getValue()); if (!componentTypeProperty.isMany() && componentProperty.isMany()) { Monitor.error(monitor, this, componentProperty.setMany(componentTypeProperty.isMany()); componentProperty.setXSDType(componentTypeProperty.getXSDType()); componentProperty.setXSDElement(componentTypeProperty.getXSDElement()); componentTypeProperty.getXSDElement() != null && !componentProperty.getXSDElement().equals(componentTypeProperty.getXSDElement())){ Monitor.error(monitor, this, component.getName(), componentProperty.getName(), componentProperty.getXSDElement(), componentTypeProperty.getXSDElement());
public Property getProperty(String name){ Property property = null; for (Property tmp : getProperties()){ if (tmp.getName().equals(name)){ property = tmp; break; } } return property; }
if (property.getXSDType() != null && property.getXSDType().getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema") != true){ XSDefinition xsdDefinition = xsdFactory.createXSDefinition(); xsdDefinition.setUnresolved(true); xsdDefinition.setNamespace(property.getXSDType().getNamespaceURI()); warning(context.getMonitor(), "PropertyTypeNotFound", property, property.getXSDType().toString(), property.getName(), parentName); } else { property.setXSDDefinition(resolved);
} else { Document sourcePropValue = (Document)sourceProp.getValue(); componentProperty.setValue(node); if(componentProperty.getXSDElement() == null){ componentProperty.setXSDElement(sourceProp.getXSDElement()); componentProperty.setXSDType(sourceProp.getXSDType());
@Override public <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException { for (Property property : type.getProperties()) { String name = property.getName(); JavaElementImpl element = type.getPropertyMembers().get(name); introspect(property, element); DataType dt = property.getDataType(); Object logical = dt.getLogical(); if (logical instanceof XMLType && logical != XMLType.UNKNOWN) { XMLType xmlType = (XMLType)logical; property.setXSDType(xmlType.getTypeName()); property.setXSDElement(xmlType.getElementName()); } else { Class<?> baseType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType()); QName typeName = JavaXMLMapper.getXMLType(baseType); property.setXSDType(typeName); } } super.visitEnd(clazz, type); }
theProperty.setName(scaproperty.getName()); theProperty.setXSDType(JavaXMLMapper.getXMLType(propType)); if (property.getName().equals(theProperty.getName())) duplicate = property; implementation.setPropertyClass(theProperty.getName(), propType); if (propertyElement.getName().equals(scaproperty.getName())) {
/** * Look to see if any value elements have been set into the property * A bit involved as the value is stored as a DOM Document * * @param property the property to be tested * @return true is values are present */ private boolean isPropertyValueSet(Property property) { Document value = (Document)property.getValue(); if (value == null) { return false; } if (value.getDocumentElement() == null) { return false; } if (value.getDocumentElement().getChildNodes().getLength() == 0) { return false; } return true; }
componentProperty.setXSDElement(property.getXSDElement()); componentProperty.setXSDType(property.getXSDType());
private boolean isSimpleType(Property property) { if (property.getXSDType() != null) { return simpleTypeMapper.isSimpleXSDType(property.getXSDType()); } else { if (property instanceof Document) { Document doc = (Document)property; Element element = doc.getDocumentElement(); if (element.getChildNodes().getLength() == 1 && element.getChildNodes().item(0).getNodeType() == Node.TEXT_NODE) { return true; } } } return false; }
sourceDataType = new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(null, this.property.getXSDType())); targetDataType = property.getDataType(); if (targetDataType == null) { TypeInfo typeInfo = null; if (this.property.getXSDType() != null) { if (simpleTypeMapper.isSimpleXSDType(this.property.getXSDType())) { typeInfo = new TypeInfo(property.getXSDType(), true, null); } else { typeInfo = new TypeInfo(property.getXSDType(), false, null); typeInfo = new TypeInfo(property.getXSDType(), false, null);
public ObjectFactory createValueFactory(Property property, Object propertyValue, Class<?> javaType) { Document doc = (Document)propertyValue; List<Node> nodes = getValues(doc); if (property.isMany()) { return new ListObjectFactoryImpl(property, nodes, javaType); } else { Object value = null; if (!nodes.isEmpty()) { value = nodes.get(0); } return new ObjectFactoryImpl(property, value, javaType); } }
/** * Process Property declaration in JavaScript code * Supported ways: * //@Property * var locale = Property("locale"); * * //@Property * locale = Property("locale"); * * @param scriptContent * @return */ private Property processPropertyScript(String scriptContent) { Property property = null; String propertyName = null; String tokens[] = scriptContent.split("="); tokens = tokens[0].split(" "); propertyName = tokens[tokens.length -1]; if(propertyName != null) { property = assemblyFactory.createProperty(); property.setName(propertyName); } return property; }