本文整理汇总了Java中com.thoughtworks.xstream.converters.MarshallingContext类的典型用法代码示例。如果您正苦于以下问题:Java MarshallingContext类的具体用法?Java MarshallingContext怎么用?Java MarshallingContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MarshallingContext类属于com.thoughtworks.xstream.converters包,在下文中一共展示了MarshallingContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
/**
* writes the argument <code>value</code> to the XML file specified through
* <code>writer</code>
*
* @pre <code>value</code> is a valid <code>Expression</code>, <code>
* writer</code> is a valid <code>HierarchicalStreamWriter</code>, and
* <code>context</code> is a valid <code>MarshallingContext</code>
* @post <code>value</code> is written to the XML file specified via
* <code>writer</code>
* @param value <code>Expression</code> that you wish to write to a file
* @param writer stream to write through
* @param context <code>MarshallingContext</code> used to store generic data
*/
@Override
public void marshal(Object value, HierarchicalStreamWriter writer,
MarshallingContext context) {
Expression expression = (Expression) value;
writer.startNode("name");
writer.setValue(expression.getName());
writer.endNode();
writer.startNode("excelExpressionString");
writer.setValue(expression.getExcelExpressionString());
writer.endNode();
writer.startNode("expressionTree");
context.convertAnother(expression.getExpressionTree());
writer.endNode();
}
示例2: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
/**
* writes the argument <code>value</code> to the XML file specified through
* <code>writer</code>
*
* @pre <code>value</code> is a valid <code>ShrimpSpeciesNode</code>, <code>
* writer</code> is a valid <code>HierarchicalStreamWriter</code>, and
* <code>context</code> is a valid <code>MarshallingContext</code>
* @post <code>value</code> is written to the XML file specified via
* <code>writer</code>
* @param value <code>ShrimpSpeciesNode</code> that you wish to write to a
* file
* @param writer stream to write through
* @param context <code>MarshallingContext</code> used to store generic data
*/
@Override
public void marshal(Object value, HierarchicalStreamWriter writer,
MarshallingContext context) {
ShrimpSpeciesNode shrimpSpeciesNode = (ShrimpSpeciesNode) value;
writer.startNode("isotopeName");
writer.setValue(shrimpSpeciesNode.getName());
writer.endNode();
writer.startNode("squidSpeciesModel");
context.convertAnother(shrimpSpeciesNode.getSquidSpeciesModel());
writer.endNode();
writer.startNode("methodNameForShrimpFraction");
writer.setValue(shrimpSpeciesNode.getMethodNameForShrimpFraction());
writer.endNode();
}
示例3: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
/**
* writes the argument <code>value</code> to the XML file specified through
* <code>writer</code>
*
* @pre <code>value</code> is a valid <code>SpotFieldNode</code>, <code>
* writer</code> is a valid <code>HierarchicalStreamWriter</code>, and
* <code>context</code> is a valid <code>MarshallingContext</code>
* @post <code>value</code> is written to the XML file specified via
* <code>writer</code>
* @param value <code>SpotFieldNode</code> that you wish to write to a
* file
* @param writer stream to write through
* @param context <code>MarshallingContext</code> used to store generic data
*/
@Override
public void marshal(Object value, HierarchicalStreamWriter writer,
MarshallingContext context) {
SpotFieldNode spotFieldNode = (SpotFieldNode) value;
writer.startNode("isotopeName");
writer.setValue(spotFieldNode.getName());
writer.endNode();
writer.startNode("methodNameForShrimpFraction");
writer.setValue(spotFieldNode.getMethodNameForShrimpFraction());
writer.endNode();
}
示例4: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
/**
* writes the argument <code>value</code> to the XML file specified through
* <code>writer</code>
*
* @pre <code>value</code> is a valid <code>ConstantNode</code>, <code>
* writer</code> is a valid <code>HierarchicalStreamWriter</code>, and
* <code>context</code> is a valid <code>MarshallingContext</code>
* @post <code>value</code> is written to the XML file specified via
* <code>writer</code>
* @param value <code>ConstantNode</code> that you wish to write to a file
* @param writer stream to write through
* @param context <code>MarshallingContext</code> used to store generic data
*/
@Override
public void marshal(Object value, HierarchicalStreamWriter writer,
MarshallingContext context) {
ExpressionTreeInterface constantNode = (ConstantNode) value;
writer.startNode("name");
writer.setValue(constantNode.getName());
writer.endNode();
writer.startNode("value");
Object myValue = ((ConstantNode) constantNode).getValue();
if (myValue instanceof Double) {
writer.setValue(Double.toString((Double) ((ConstantNode) constantNode).getValue()));
} else if (myValue instanceof Integer) {
writer.setValue(Integer.toString((Integer) ((ConstantNode) constantNode).getValue()));
} else if (myValue instanceof String) {
writer.setValue((String) ((ConstantNode) constantNode).getValue());
} else { // boolean
writer.setValue(Boolean.toString((Boolean) ((ConstantNode) constantNode).getValue()));
}
writer.endNode();
}
示例5: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
/**
* writes the argument <code>value</code> to the XML file specified through
* <code>writer</code>
*
* @pre <code>value</code> is a valid <code>Task</code>, <code>
* writer</code> is a valid <code>HierarchicalStreamWriter</code>, and
* <code>context</code> is a valid <code>MarshallingContext</code>
* @post <code>value</code> is written to the XML file specified via
* <code>writer</code>
* @param value <code>Task</code> that you wish to write to a file
* @param writer stream to write through
* @param context <code>MarshallingContext</code> used to store generic data
*/
@Override
public void marshal(Object value, HierarchicalStreamWriter writer,
MarshallingContext context) {
TaskInterface task = (Task) value;
writer.startNode("name");
writer.setValue(task.getName());
writer.endNode();
writer.startNode("taskExpressionsOrdered");
context.convertAnother(task.getTaskExpressionTreesOrdered());
writer.endNode();
}
示例6: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(Object original, HierarchicalStreamWriter writer, MarshallingContext context) {
super.marshal(original, writer, context);
WxPayOrderNotifyResult obj = (WxPayOrderNotifyResult) original;
List<WxPayOrderNotifyCoupon> list = obj.getCouponList();
if (list == null || list.size() == 0) {
return;
}
for (int i = 0; i < list.size(); i++) {
WxPayOrderNotifyCoupon coupon = list.get(i);
writer.startNode("coupon_id_" + i);
writer.setValue(coupon.getCouponId());
writer.endNode();
writer.startNode("coupon_type_" + i);
writer.setValue(coupon.getCouponType());
writer.endNode();
writer.startNode("coupon_fee_" + i);
writer.setValue(coupon.getCouponFee() + "");
writer.endNode();
}
}
示例7: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(HierarchicalStreamWriter writer, MarshallingContext context, Object object)
{
Collection<?> col = getCollection(object);
if( col != null )
{
Iterator<?> i = col.iterator();
boolean first = true;
while( i.hasNext() )
{
Object value = i.next();
if( value == null )
{
continue;
}
if( !first )
{
writer.endNode();
writer.startNode(endNode);
}
first = false;
converter.marshal(writer, context, value);
}
}
}
示例8: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(Object arg0, HierarchicalStreamWriter writer, MarshallingContext arg2)
{
writer.addAttribute("xmlns:oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/");
writer.addAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
writer.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
writer.addAttribute("xsi:schemaLocation",
"http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd");
DublinCore metadata = (DublinCore) arg0;
startNode(writer, "dc:title", metadata.getTitle());
startNode(writer, "dc:creator", metadata.getCreator());
startNode(writer, "dc:creator", metadata.getTitle());
startNode(writer, "dc:date", metadata.getDate());
startNode(writer, "dc:description", metadata.getDescription());
startNode(writer, "dc:identifier", metadata.getIdentifier());
}
示例9: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext arg2)
{
Request rep = (Request) object;
Map map = rep.getAttributes();
Iterator i = map.keySet().iterator();
while( i.hasNext() )
{
String key = i.next().toString();
String[] value = (String[]) map.get(key);
for( int j = 0; j < value.length; j++ )
{
writer.addAttribute(key, value[j]);
}
}
writer.setValue(rep.getNode());
}
示例10: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext arg2)
{
Header header = (Header) object;
addAttribute(writer, "status", header.getStatus());
writer.startNode("identifier");
writer.setValue(header.getIdentifier());
writer.endNode();
writer.startNode("datestamp");
writer.setValue(header.getDatestamp());
writer.endNode();
Iterator i = header.getSpecs().iterator();
while( i.hasNext() )
{
writer.startNode("setSpec");
writer.setValue(i.next().toString());
writer.endNode();
}
}
示例11: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(Object object, HierarchicalStreamWriter writer, MarshallingContext arg2)
{
Response rep = (Response) object;
writer.addAttribute("xmlns", "http://www.openarchives.org/OAI/2.0/");
writer.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
writer.addAttribute("xsi:schemaLocation",
"http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd");
startNode(writer, "responseDate", rep.getResponseDate());
marshal(rep.getRequest(), writer);
Object message = rep.getMessage();
if( message instanceof List )
{
List col = (List) message;
startNode(writer, rep.getMessageNodeName(), col, true);
}
else
{
marshal(rep.getMessage(), writer);
}
marshal(rep.getError(), writer);
}
示例12: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(final Object original, final HierarchicalStreamWriter writer, final MarshallingContext context) {
final Object source = serializationMethodInvoker.callWriteReplace(original);
if (source != original && context instanceof ReferencingMarshallingContext) {
((ReferencingMarshallingContext<?>)context).replace(original, source);
}
if (source.getClass() != original.getClass()) {
final String attributeName = mapper.aliasForSystemAttribute("resolves-to");
if (attributeName != null) {
writer.addAttribute(attributeName, mapper.serializedClass(source.getClass()));
}
context.convertAnother(source);
} else {
doMarshal(source, writer, context);
}
}
示例13: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
final BitSet bitSet = (BitSet)source;
final StringBuilder buffer = new StringBuilder();
boolean seenFirst = false;
for (int i = 0; i < bitSet.length(); i++) {
if (bitSet.get(i)) {
if (seenFirst) {
buffer.append(',');
} else {
seenFirst = true;
}
buffer.append(i);
}
}
writer.setValue(buffer.toString());
}
示例14: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
final Properties properties = (Properties)source;
final Map<Object, Object> map = sort ? new TreeMap<Object, Object>(properties) : properties;
for (final Map.Entry<Object, Object> entry : map.entrySet()) {
writer.startNode("property");
writer.addAttribute("name", entry.getKey().toString());
writer.addAttribute("value", entry.getValue().toString());
writer.endNode();
}
if (defaultsField != null) {
final Properties defaults = (Properties)Fields.read(defaultsField, properties);
if (defaults != null) {
writer.startNode("defaults");
marshal(defaults, writer, context);
writer.endNode();
}
}
}
示例15: marshal
import com.thoughtworks.xstream.converters.MarshallingContext; //导入依赖的package包/类
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
final int length = Array.getLength(source);
for (int i = 0; i < length; ++i) {
final Object item = Array.get(source, i);
final Class<?> itemType = item == null ? Mapper.Null.class : arrayType.getComponentType().isPrimitive()
? Primitives.unbox(item.getClass())
: item.getClass();
ExtendedHierarchicalStreamWriterHelper.startNode(writer, itemName, itemType);
if (!itemType.equals(arrayType.getComponentType())) {
final String attributeName = mapper.aliasForSystemAttribute("class");
if (attributeName != null) {
writer.addAttribute(attributeName, mapper.serializedClass(itemType));
}
}
if (item != null) {
context.convertAnother(item);
}
writer.endNode();
}
}