public AegisType getType(Type javaType) { AegisType type = class2Type.get(javaType); if (type == null && nextTM != null) { type = nextTM.getType(javaType); } return type; }
/** * Get the <code>AegisType</code> of the elements in the array. * * @return */ public AegisType getComponentType() { Class<?> compType = getTypeClass().getComponentType(); AegisType type; if (componentName == null) { type = getTypeMapping().getType(compType); } else { type = getTypeMapping().getType(componentName); // We couldn't find the type the user specified. One is created // below instead. if (type == null) { LOG.finest("Couldn't find array component type " + componentName + ". Creating one instead."); } } if (type == null) { type = getTypeMapping().getTypeCreator().createType(compType); getTypeMapping().register(type); } return type; }
/** * If a class was provided as part of the root list, retrieve it's AegisType by schema type QName. * * @param schemaTypeName * @return */ public AegisType getRootType(QName schemaTypeName) { if (rootTypeQNames.contains(schemaTypeName)) { return typeMapping.getType(schemaTypeName); } return null; }
/** * Get the <code>AegisType</code> of the elements in the array. This is only used for writing an array. * When reading the type is solely determined by the required arrayType soap attribute. */ public AegisType getComponentType() { Class<?> compType = getTypeClass().getComponentType(); AegisType type; if (componentName == null) { type = getTypeMapping().getType(compType); } else { type = getTypeMapping().getType(componentName); // We couldn't find the type the user specified. One is created // below instead. if (type == null) { LOG.finest("Couldn't find array component type " + componentName + ". Creating one instead."); } } if (type == null) { type = getTypeMapping().getTypeCreator().createType(compType); getTypeMapping().register(type); } return type; }
public AegisType getType(QName xmlType) { AegisType type = xml2Type.get(xmlType); if (type == null && nextTM != null) { type = nextTM.getType(xmlType); } return type; }
/** * {@inheritDoc} */ public void write(Object obj, QName elementName, boolean optional, XMLStreamWriter output, java.lang.reflect.Type objectType) throws Exception { AegisType aegisType = null; if (objectType instanceof Class) { aegisType = getContext().getTypeMapping().getType(objectType); } if (aegisType == null) { TypeCreator creator = getContext().getTypeMapping().getTypeCreator(); aegisType = creator.createType(objectType); } if (aegisType == null) { Message message = new Message("NO_MAPPING_FOR_TYPE", LOG, objectType); throw new DatabindingException(message); } write(obj, elementName, optional, output, aegisType); } }
/** * If a class was provided as part of the 'root' list, retrieve it's AegisType by Class. * * @param clazz * @return */ public AegisType getRootType(Class<?> clazz) { if (rootClasses.contains(clazz)) { return typeMapping.getType(clazz); } return null; }
/** * {@inheritDoc} */ public void write(Object obj, QName elementName, boolean optional, XMLStreamWriter output, java.lang.reflect.Type objectType) throws Exception { AegisType aegisType = null; if (objectType instanceof Class) { aegisType = getContext().getTypeMapping().getType(objectType); } if (aegisType == null) { TypeCreator creator = getContext().getTypeMapping().getTypeCreator(); aegisType = creator.createType(objectType); } if (aegisType == null) { Message message = new Message("NO_MAPPING_FOR_TYPE", LOG, objectType); throw new DatabindingException(message); } write(obj, elementName, optional, output, aegisType); } }
/** * If a class was provided as part of the 'root' list, retrieve it's AegisType by Class. * * @param clazz * @return */ public AegisType getRootType(Class<?> clazz) { if (rootClasses.contains(clazz)) { return typeMapping.getType(clazz); } return null; }
/** * If a class was provided as part of the root list, retrieve it's AegisType by schema type QName. * * @param schemaTypeName * @return */ public AegisType getRootType(QName schemaTypeName) { if (rootTypeQNames.contains(schemaTypeName)) { return typeMapping.getType(schemaTypeName); } return null; }
public AegisType getType(Type javaType) { AegisType type = class2Type.get(javaType); if (type == null && nextTM != null) { type = nextTM.getType(javaType); } return type; }
public AegisType getType(QName xmlType) { AegisType type = xml2Type.get(xmlType); if (type == null && nextTM != null) { type = nextTM.getType(xmlType); } return type; }
@Override public Object readObject(MessageReader mreader, Context context) throws DatabindingException { DocumentType dt = (DocumentType)getTypeMapping().getType(Document.class); return new DOMSource((Document)dt.readObject(mreader, context)); }
public static AegisType getWriteTypeStandalone(AegisContext globalContext, Object value, AegisType type) { if (type != null) { return getWriteType(globalContext, value, type); } TypeMapping tm; tm = globalContext.getTypeMapping(); // don't use this for null! type = tm.getType(value.getClass()); return type; }
@Override public Object readObject(MessageReader mreader, Context context) throws DatabindingException { DocumentType dt = (DocumentType)getTypeMapping().getType(Document.class); return new DOMSource((Document)dt.readObject(mreader, context)); }
public static AegisType getWriteTypeStandalone(AegisContext globalContext, Object value, AegisType type) { if (type != null) { return getWriteType(globalContext, value, type); } TypeMapping tm; tm = globalContext.getTypeMapping(); // don't use this for null! type = tm.getType(value.getClass()); return type; }
private String marshal(Object obj) throws Exception { AegisContext context = aegisDatabinding.getAegisContext(); AegisWriter<XMLStreamWriter> writer = context.createXMLStreamWriter(); AegisType aegisType = context.getTypeMapping().getType(obj.getClass()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(outputStream); writer.write(obj, new QName("http://logging.ws.ruleservice.rules.openl.org", ""), false, xmlWriter, aegisType); xmlWriter.close(); return outputStream.toString(Charset.defaultCharset()); } }
public AegisType determineType(Context context, Class<?> clazz) { TypeMapping tm = context.getTypeMapping(); if (tm == null) { tm = getTypeMapping(); } AegisType type = tm.getType(clazz); if (null != type) { return type; } Class<?>[] interfaces = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { Class<?> anInterface = interfaces[i]; type = tm.getType(anInterface); if (null != type) { return type; } } Class<?> superclass = clazz.getSuperclass(); if (null == superclass || Object.class.equals(superclass)) { return null; } return determineType(context, superclass); }
private String marshal(Object obj) throws Exception { AegisContext context = aegisDatabinding.getAegisContext(); AegisWriter<XMLStreamWriter> writer = context.createXMLStreamWriter(); AegisType aegisType = context.getTypeMapping().getType(obj.getClass()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(outputStream); writer.write(obj, new QName("http://logging.ws.ruleservice.rules.openl.org", ""), false, xmlWriter, aegisType); xmlWriter.close(); return outputStream.toString(Charset.defaultCharset()); } }
public T readFrom(Class<T> type, Type genericType, Annotation[] annotations, MediaType m, MultivaluedMap<String, String> headers, InputStream is) throws IOException { if (genericType == null) { genericType = type; } if (type == null) { type = messyCastToRawType(genericType); } AegisContext context = getAegisContext(type, genericType); AegisType typeToRead = context.getTypeMapping().getType(genericType); AegisReader<XMLStreamReader> aegisReader = context.createXMLStreamReader(); XMLStreamReader xmlStreamReader = null; try { xmlStreamReader = createStreamReader(typeToRead, is); return type.cast(aegisReader.read(xmlStreamReader, typeToRead)); } catch (Exception e) { throw ExceptionUtils.toBadRequestException(e, null); } finally { StaxUtils.close(xmlStreamReader); } }