public QName getSchemaType() { return baseType.getSchemaType(); }
public Set<AegisType> getDependencies() { return baseType.getDependencies(); }
/** * {@inheritDoc} */ public void register(AegisType type) { type.setTypeMapping(this); if (type.getType() != null) { class2xml.put(type.getType(), type.getSchemaType()); class2Type.put(type.getType(), type); } if (type.getSchemaType() != null) { xml2Type.put(type.getSchemaType(), type); } if (type.getType() == null && type.getSchemaType() == null) { LOG.warning("The type " + type.getClass().getName() + " supports neither serialization (non-null TypeClass)" + " nor deserialization (non-null SchemaType)."); } }
@Override public int hashCode() { int hashcode = 0; if (getTypeClass() != null) { hashcode ^= getTypeClass().hashCode(); } if (getSchemaType() != null) { hashcode ^= getSchemaType().hashCode(); } return hashcode; }
public void removeType(AegisType type) { if (!xml2Type.containsKey(type.getSchemaType())) { nextTM.removeType(type); } else { xml2Type.remove(type.getSchemaType()); class2Type.remove(type.getType()); class2xml.remove(type.getType()); } }
if (type.isAbstract()) { part.setTypeQName(type.getSchemaType()); } else { part.setElementQName(type.getSchemaType()); if (type.hasMinOccurs()) { miValue = type.getMinOccurs(); boolean isNil = type.isNillable(); Boolean b = AnnotationReader.isNillable(anns); if (b != null || (miValue != 0 && isNil)) { if (type.hasMaxOccurs()) { String moValue; long mo = type.getMaxOccurs(); if (mo != Long.MAX_VALUE) { moValue = Long.toString(mo); type.getTypeMapping().register(type); addDependencies(deps, type);
XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension(); content.setContent(extension); extension.setBaseTypeName(sooperType.getSchemaType()); extension.setParticle(sequence); } else { if (type.isFlatArray()) { element.setMinOccurs(type.getMinOccurs()); element.setMaxOccurs(type.getMaxOccurs()); element.setNillable(type.isNillable()); } else { if (AbstractTypeCreator. HTTP_CXF_APACHE_ORG_ARRAYS.equals(type.getSchemaType().getNamespaceURI())) { XmlSchemaUtils.addImportIfNeeded(root, AbstractTypeCreator.HTTP_CXF_APACHE_ORG_ARRAYS); needXmime |= type.usesXmime(); needUtilityTypes |= type.usesUtilityTypes(); attribute.setName(name.getLocalPart()); AegisType type = getType(inf, name); attribute.setSchemaTypeName(type.getSchemaType()); String ns = name.getNamespaceURI(); if (!ns.equals(root.getTargetNamespace())) {
private void collectOneItem(Context context, Collection<Object> values, MessageReader creader, AegisType compType) { if (creader.isXsiNil()) { values.add(null); creader.readToEnd(); } else { values.add(compType.readObject(creader, context)); } // check max occurs int size = values.size(); if (size > maxOccurs) { throw new DatabindingException("The number of elements in " + getSchemaType() + " exceeds the maximum of " + maxOccurs); } }
@Override public void writeObject(Object object, MessageWriter writer, Context context) throws DatabindingException { if (object == null) { return; } try { Collection<?> list = (Collection<?>)object; AegisType type = getComponentType(); if (type == null) { throw new DatabindingException("Couldn't find component type for Collection."); } for (Iterator<?> itr = list.iterator(); itr.hasNext();) { String ns = null; if (type.isAbstract()) { ns = getSchemaType().getNamespaceURI(); } else { ns = type.getSchemaType().getNamespaceURI(); } writeValue(itr.next(), writer, context, type, type.getSchemaType().getLocalPart(), ns); } } catch (IllegalArgumentException e) { throw new DatabindingException("Illegal argument.", e); } }
public QName getSuggestedName(Service s, TypeMapping tm, OperationInfo op, int param) { Method m = getMethod(s, op); if (m == null) { return null; } QName name = tm.getTypeCreator().getElementName(m, param); // No mapped name was specified, so if its a complex type use that name // instead if (name == null) { AegisType type = tm.getTypeCreator().createType(m, param); if (type.isComplex() && !type.isAbstract()) { name = type.getSchemaType(); } } return name; }
protected void writeValue(Object value, MessageWriter writer, Context context, AegisType type) throws DatabindingException { type = TypeUtil.getWriteType(context.getGlobalContext(), value, type); MessageWriter cwriter = writer.getElementWriter(type.getSchemaType().getLocalPart(), ""); if (value == null && type.isNillable()) { // null cwriter.writeXsiNil(); } else if (type instanceof BeanType || type instanceof SoapArrayType) { // write refs to complex type String refId = MarshalRegistry.get(context).getInstanceId(value); SoapEncodingUtil.writeRef(cwriter, refId); } else { // write simple types inline type.writeObject(value, cwriter, context); } cwriter.close(); }
throw new DatabindingException("Couldn't find type for array."); if (Constants.XSD_ANYTYPE.equals(type.getSchemaType())) { forceXsiWrite = true; if (type.isAbstract()) { ns = getSchemaType().getNamespaceURI(); } else { ns = type.getSchemaType().getNamespaceURI(); name = type.getSchemaType().getLocalPart(); Class<?> arrayType = type.getTypeClass();
@Override public void writeSchema(XmlSchema root) { if (isFlat()) { return; // there is no extra level of type. } if (hasDefinedArray(root)) { return; } XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true); complex.setName(getSchemaType().getLocalPart()); XmlSchemaSequence seq = new XmlSchemaSequence(); complex.setParticle(seq); AegisType componentType = getComponentType(); XmlSchemaElement element = new XmlSchemaElement(root, false); element.setName(componentType.getSchemaType().getLocalPart()); element.setSchemaTypeName(componentType.getSchemaType()); seq.getItems().add(element); if (componentType.isNillable()) { element.setNillable(true); } element.setMinOccurs(getMinOccurs()); element.setMaxOccurs(getMaxOccurs()); }
@Override public void writeObject(Object object, MessageWriter writer, Context context) throws DatabindingException { if (null == object) { MessageWriter nilWriter = writer.getAttributeWriter(XSI_NIL); nilWriter.writeValue("true"); nilWriter.close(); } else { AegisType type = determineType(context, object.getClass()); if (null == type) { TypeMapping tm = context.getTypeMapping(); if (tm == null) { tm = getTypeMapping(); } type = tm.getTypeCreator().createType(object.getClass()); tm.register(type); } writer.writeXsiType(type.getSchemaType()); boolean nextIsBeanType = type instanceof BeanType; if (nextIsBeanType) { ((BeanType)type).writeObjectFromObjectType(object, writer, context, true); } else { type.writeObject(object, writer, context); } } }
protected QName createCollectionQName(TypeClassInfo info, AegisType type) { String ns; if (type.isComplex()) { ns = type.getSchemaType().getNamespaceURI(); } else { ns = tm.getMappingIdentifierURI(); } if (WSDLConstants.NS_SCHEMA_XSD.equals(ns)) { ns = HTTP_CXF_APACHE_ORG_ARRAYS; } String first = type.getSchemaType().getLocalPart().substring(0, 1); String last = type.getSchemaType().getLocalPart().substring(1); String localName = "ArrayOf" + first.toUpperCase() + last; if (info.nonDefaultAttributes()) { localName += "-"; if (info.getMinOccurs() >= 0) { localName += info.getMinOccurs(); } localName += "-"; if (info.getMaxOccurs() >= 0) { localName += info.getMaxOccurs(); } if (info.isFlat()) { localName += "Flat"; } } return new QName(ns, localName); }
QName overrideName = NamespaceHelper.createQName(xsr.getNamespaceContext(), overrideType); if (baseType == null || !overrideName.equals(baseType.getSchemaType())) { AegisType improvedType = null; TypeMapping tm; if (baseType != null) { tm = baseType.getTypeMapping(); improvedType = tm.getType(overrideName); LOG.finest("xsi:type=\"" + overrideName + "\" was specified, but no corresponding AegisType was registered; defaulting to " + baseType.getSchemaType()); return baseType;
AegisType type = getTypeMapping().getType(info.getType()); if (type == null || (info.getTypeName() != null && !type.getSchemaType().equals(info.getTypeName()))) { if (info.getTypeName() != null) { type = getTypeMapping().getType(info.getTypeName()); result.setNillable(false);
private AegisType getParameterType(Service s, TypeMapping tm, MessagePartInfo param, int paramtype) { AegisType type = tm.getType(param.getTypeQName()); if (type != null && type.getTypeClass() != param.getTypeClass()) { type = null; && type.isWriteOuter()) { if ((type instanceof ArrayType) && !type.isWriteOuter()) { param.setProperty("org.apache.cxf.aegis.outerType", type); ArrayType aType = (ArrayType) type; tm.register(type); type.setTypeMapping(tm);
Object writeObj = type.readObject(childReader, context); writeProperty(name, target, writeObj, clazz, inf); if (!childReader.isXsiNil()) { Object writeObj; if (type.isFlatArray()) { ArrayType aType = (ArrayType) type; PropertyDescriptor desc = inf.getPropertyDescriptorFromMappedName(name); writeObj = aType.readObject(childReader, name, context, !isList); } else { writeObj = type.readObject(childReader, context);
public Class<?> getTypeClass() { return baseType.getTypeClass(); }