SerializationContext context,
Conventions conventions) {
Type type = Type.TEXT;
Object contentValue = null;
ObjectContext valueContext = null;
AccessibleObject accessor = objectContext.getAccessor(Value.class, conventions);
if (accessor != null && !(source instanceof Element)) {
contentValue = eval(accessor, source);
valueContext = new ObjectContext(contentValue, source, accessor);
Text _text = valueContext.getAnnotation(Text.class);
type = _text != null ? _text.type() : type;
} else {
Text _text = objectContext.getAnnotation(Text.class);
type = _text != null ? _text.type() : type;
contentValue = source;
valueContext = objectContext;
}
QName qname = this.qname != null ? this.qname : getQName(objectContext.getAccessor());
StreamWriter sw = context.getStreamWriter();
sw.startText(qname, type);
writeAttributes(source, objectContext, context, conventions);
switch (type) {
case TEXT:
case HTML:
sw.writeElementText(toString(contentValue));
break;
case XHTML:
Div div = null;
if (contentValue instanceof Div)
div = (Div)contentValue;
else {
div = context.getAbdera().getFactory().newDiv();
div.setValue(toString(contentValue));
}
context.serialize(div, new ObjectContext(div));
break;
}
}