Java Code Examples for com.thoughtworks.xstream.converters.MarshallingContext#convertAnother()
The following examples show how to use
com.thoughtworks.xstream.converters.MarshallingContext#convertAnother() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReferenceAgentConverter.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public void marshal(final Object arg0, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ReferenceAgent refSavedAgt = (ReferenceAgent) arg0; // writer.startNode("agent"); // context.convertAnother(refSavedAgt.getAgt()); // writer.endNode(); // writer.startNode("attributeName"); // writer.setValue("" + refSavedAgt.getAttributeName()); // writer.endNode(); writer.startNode("attributeValue"); context.convertAnother(refSavedAgt.getAttributeValue()); writer.endNode(); }
Example 2
Source File: ActivationDataFlavorConverter.java From lams with GNU General Public License v2.0 | 6 votes |
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ActivationDataFlavor dataFlavor = (ActivationDataFlavor)source; final String mimeType = dataFlavor.getMimeType(); if (mimeType != null) { writer.startNode("mimeType"); writer.setValue(mimeType); writer.endNode(); } final String name = dataFlavor.getHumanPresentableName(); if (name != null) { writer.startNode("humanRepresentableName"); writer.setValue(name); writer.endNode(); } final Class representationClass = dataFlavor.getRepresentationClass(); if (representationClass != null) { writer.startNode("representationClass"); context.convertAnother(representationClass); writer.endNode(); } }
Example 3
Source File: FontConverter.java From lams with GNU General Public License v2.0 | 6 votes |
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Font font = (Font)source; Map attributes = font.getAttributes(); if (mapper != null) { String classAlias = mapper.aliasForSystemAttribute("class"); for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry)iter.next(); String name = textAttributeConverter.toString(entry.getKey()); Object value = entry.getValue(); Class type = value != null ? value.getClass() : Mapper.Null.class; ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, type); writer.addAttribute(classAlias, mapper.serializedClass(type)); if (value != null) { context.convertAnother(value); } writer.endNode(); } } else { writer.startNode("attributes"); // <attributes> context.convertAnother(attributes); writer.endNode(); // </attributes> } }
Example 4
Source File: PbBlankXMLConverter.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * writes the argument <code>value</code> to the XML file specified through <code>writer</code> * * @pre <code>value</code> is a valid <code>PbBlank</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>PbBlank</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 */ public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { PbBlank pbBlank = (PbBlank) value; writer.startNode("name"); writer.setValue(pbBlank.getName()); writer.endNode(); writer.startNode("ratios"); context.convertAnother(pbBlank.getRatios()); writer.endNode(); writer.startNode("rhoCorrelations"); context.convertAnother(pbBlank.getRhoCorrelations()); writer.endNode(); }
Example 5
Source File: GamaPairConverter.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void marshal(final Object arg0, final HierarchicalStreamWriter arg1, final MarshallingContext arg2) { final GamaPair mp = (GamaPair) arg0; // System.out.println("ConvertAnother : GamaPair " + mp.getClass()); DEBUG.OUT("ConvertAnother : GamaPair " + mp.getClass()); arg2.convertAnother(new GamaPairReducer(mp)); // System.out.println("END -- ConvertAnother : GamaPair " + mp.getClass()); DEBUG.OUT("END -- ConvertAnother : GamaPair " + mp.getClass()); }
Example 6
Source File: InitialPbModelXMLConverter.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * * @param value * @param writer * @param context */ @Override public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { InitialPbModel initialPbModel = (InitialPbModel) value; writer.startNode("name"); writer.setValue(initialPbModel.getName()); writer.endNode(); writer.startNode("reference"); writer.setValue(initialPbModel.getReference()); writer.endNode(); writer.startNode("calculated"); writer.setValue(Boolean.toString(initialPbModel.isCalculated())); writer.endNode(); writer.startNode("ratios"); context.convertAnother(initialPbModel.getRatios()); writer.endNode(); writer.startNode("correlationCoefficients"); context.convertAnother(initialPbModel.getCorrelationCoefficients()); writer.endNode(); }
Example 7
Source File: MapConverter.java From yes-cart with Apache License 2.0 | 5 votes |
protected void writeItem(String nodeName, Object item, MarshallingContext context, HierarchicalStreamWriter writer) { // PUBLISHED API METHOD! If changing signature, ensure backwards compatibility. if (item != null) { ExtendedHierarchicalStreamWriterHelper.startNode(writer, nodeName, item.getClass()); context.convertAnother(item); writer.endNode(); } }
Example 8
Source File: AnnotationReflectionConverter.java From lams with GNU General Public License v2.0 | 5 votes |
protected void marshallField(final MarshallingContext context, Object newObj, Field field) { XStreamConverter annotation = annotationProvider.getAnnotation( field, XStreamConverter.class); if (annotation != null) { Class<? extends ConverterMatcher> type = annotation.value(); ensureCache(type); context.convertAnother(newObj, cachedConverters.get(type)); } else { context.convertAnother(newObj); } }
Example 9
Source File: MineralStandardModelXMLConverter.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * * @param value * @param writer * @param context */ @Override public void marshal ( Object value, HierarchicalStreamWriter writer, MarshallingContext context ) { MineralStandardModel mineralStandard = (MineralStandardModel) value; writer.startNode( "name" ); writer.setValue( mineralStandard.getName() ); writer.endNode(); writer.startNode( "mineralStandardName" ); writer.setValue( mineralStandard.getMineralStandardName() ); writer.endNode(); writer.startNode( "standardMineralName" ); writer.setValue( mineralStandard.getStandardMineralName() ); writer.endNode(); writer.startNode( "trueAge" ); context.convertAnother( mineralStandard.getTrueAge() ); writer.endNode(); writer.startNode( "radiogenicIsotopeRatios" ); context.convertAnother( ValueModel.compressArrayOfValueModels( mineralStandard.getRadiogenicIsotopeRatios() ) ); writer.endNode(); writer.startNode( "measuredAge" ); context.convertAnother( mineralStandard.getMeasuredAge() ); writer.endNode(); writer.startNode( "comment" ); writer.setValue( mineralStandard.getComment() ); writer.endNode(); }
Example 10
Source File: EdgeConverter.java From depan with Apache License 2.0 | 5 votes |
@Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { GraphEdge edge = (GraphEdge) source; Relation relation = edge.getRelation(); writer.startNode(RELATION_TAG); Class<?> actualType = relation.getClass(); Class<?> defaultType = mapper.defaultImplementationOf(BasicEdge.class); if (!actualType.equals(defaultType)) { writer.addAttribute( mapper.aliasForAttribute("class"), mapper.serializedClass(actualType)); } context.convertAnother(relation); writer.endNode(); writer.startNode(HEAD_TAG); context.convertAnother(edge.getHead().getId()); writer.endNode(); writer.startNode(TAIL_TAG); context.convertAnother(edge.getTail().getId()); writer.endNode(); }
Example 11
Source File: AbstractMappingConverter.java From depan with Apache License 2.0 | 5 votes |
protected void marshalObject(Object item, HierarchicalStreamWriter writer, MarshallingContext context) { String nodeLabel = mapper.serializedClass(item.getClass()); writer.startNode(nodeLabel); context.convertAnother(item); writer.endNode(); }
Example 12
Source File: GraphModelConverter.java From depan with Apache License 2.0 | 5 votes |
protected void marshalObject(Object item, HierarchicalStreamWriter writer, MarshallingContext context) { String nodeLabel = mapper.serializedClass(item.getClass()); writer.startNode(nodeLabel); context.convertAnother(item); writer.endNode(); }
Example 13
Source File: ReportCategoryXMLConverter.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * writes the argument <code>value</code> to the XML file specified through <code>writer</code> * * @pre <code>value</code> is a valid <code>reportSettings</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>reportSettings</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 ) { ReportCategory reportCategory = (ReportCategory) value; writer.startNode( "displayName" ); writer.setValue( reportCategory.getDisplayName() ); writer.endNode(); writer.startNode( "positionIndex" ); writer.setValue( Integer.toString( reportCategory.getPositionIndex() ) ); writer.endNode(); writer.startNode( "categoryColumns" ); context.convertAnother( reportCategory.getCategoryColumns() ); writer.endNode(); writer.startNode( "categoryColor" ); writer.setValue( Integer.toString(reportCategory.getCategoryColor().getRGB() )); writer.endNode(); writer.startNode( "visible" ); writer.setValue( Boolean.toString( reportCategory.isVisible() ) ); writer.endNode(); writer.startNode( "legacyData" ); writer.setValue( Boolean.toString( reportCategory.isLegacyData() ) ); writer.endNode(); }
Example 14
Source File: TracerXMLConverter.java From ET_Redux with Apache License 2.0 | 4 votes |
/** * writes the argument <code>value</code> to the XML file specified through <code>writer</code> * * @pre <code>value</code> is a valid <code>Tracer</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>Tracer</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 */ public void marshal ( Object value, HierarchicalStreamWriter writer, MarshallingContext context ) { Tracer tracer = (Tracer) value; writer.startNode( "tracerName" ); writer.setValue( tracer.getTracerName() ); writer.endNode(); writer.startNode( "versionNumber" ); writer.setValue( Integer.toString( tracer.getVersionNumber() ) ); writer.endNode(); writer.startNode( "tracerType" ); writer.setValue( tracer.getTracerType() ); writer.endNode(); writer.startNode( "labName" ); writer.setValue( tracer.getLabName() ); writer.endNode(); writer.startNode( "dateCertified" ); writer.setValue( tracer.getDateCertified() ); writer.endNode(); // prepare ratios to be custom-sorted ValueModel[] temp = new ValueModel[TracerRatiosEnum.getNames().length]; for (int i = 0; i < TracerRatiosEnum.getNames().length; i ++) { temp[i] = tracer.getRatioByName( TracerRatiosEnum.getNames()[i] ); } writer.startNode( "ratios" ); context.convertAnother( temp ); writer.endNode(); temp = new ValueModel[TracerIsotopes.getNames().length]; for (int i = 0; i < TracerIsotopes.getNames().length; i ++) { temp[i] = tracer.getIsotopeConcByName( TracerIsotopes.getNames()[i] ); } writer.startNode( "isotopeConcentrations" ); context.convertAnother( temp ); writer.endNode(); }
Example 15
Source File: DetritalUThModelXMLConverter.java From ET_Redux with Apache License 2.0 | 4 votes |
/** * writes the argument * <code>value</code> to the XML file specified through * <code>writer</code> * * @pre * <code>value</code> is a valid * <code>PbBlank</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>PbBlank</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 ) { AbstractRatiosDataModel detritalUraniumAndThoriumModel = (DetritalUraniumAndThoriumModel) value; writer.startNode( "modelName" ); writer.setValue( detritalUraniumAndThoriumModel.getModelName() ); writer.endNode(); writer.startNode( "versionNumber" ); writer.setValue( Integer.toString( detritalUraniumAndThoriumModel.getVersionNumber() ) ); writer.endNode(); writer.startNode( "minorVersionNumber" ); writer.setValue( Integer.toString( detritalUraniumAndThoriumModel.getMinorVersionNumber() ) ); writer.endNode(); writer.startNode( "labName" ); writer.setValue( detritalUraniumAndThoriumModel.getLabName() ); writer.endNode(); writer.startNode( "dateCertified" ); writer.setValue( detritalUraniumAndThoriumModel.getDateCertified() ); writer.endNode(); writer.startNode( "reference" ); writer.setValue( detritalUraniumAndThoriumModel.getReference() ); writer.endNode(); writer.startNode( "comment" ); writer.setValue( detritalUraniumAndThoriumModel.getComment() ); writer.endNode(); writer.startNode( "ratios" ); context.convertAnother( detritalUraniumAndThoriumModel.getData() ); writer.endNode(); writer.startNode( "rhos" ); context.convertAnother( detritalUraniumAndThoriumModel.getRhosVarUnctForXMLSerialization() ); writer.endNode(); }
Example 16
Source File: InitialPbModelETXMLConverter.java From ET_Redux with Apache License 2.0 | 4 votes |
/** * * @param value * @param writer * @param context */ @Override public void marshal ( Object value, HierarchicalStreamWriter writer, MarshallingContext context ) { AbstractRatiosDataModel initialPbModelET = (InitialPbModelET) value; writer.startNode( "modelName" ); writer.setValue( initialPbModelET.getModelName() ); writer.endNode(); writer.startNode( "versionNumber" ); writer.setValue( Integer.toString( initialPbModelET.getVersionNumber() ) ); writer.endNode(); writer.startNode( "minorVersionNumber" ); writer.setValue( Integer.toString( initialPbModelET.getMinorVersionNumber() ) ); writer.endNode(); writer.startNode( "labName" ); writer.setValue( initialPbModelET.getLabName() ); writer.endNode(); writer.startNode( "dateCertified" ); writer.setValue( initialPbModelET.getDateCertified() ); writer.endNode(); writer.startNode( "reference" ); writer.setValue( initialPbModelET.getReference() ); writer.endNode(); writer.startNode( "comment" ); writer.setValue( initialPbModelET.getComment() ); writer.endNode(); writer.startNode( "ratios" ); context.convertAnother( initialPbModelET.getData() ); writer.endNode(); writer.startNode( "rhos" ); context.convertAnother( initialPbModelET.getRhosVarUnctForXMLSerialization() ); writer.endNode(); }
Example 17
Source File: PbBlankICModelXMLConverter.java From ET_Redux with Apache License 2.0 | 4 votes |
/** * writes the argument * <code>value</code> to the XML file specified through * <code>writer</code> * * @pre * <code>value</code> is a valid * <code>PbBlank</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>PbBlank</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 ) { AbstractRatiosDataModel pbBlankICModel = (PbBlankICModel) value; writer.startNode( "modelName" ); writer.setValue( pbBlankICModel.getModelName() ); writer.endNode(); writer.startNode( "versionNumber" ); writer.setValue( Integer.toString( pbBlankICModel.getVersionNumber() ) ); writer.endNode(); writer.startNode( "minorVersionNumber" ); writer.setValue( Integer.toString( pbBlankICModel.getMinorVersionNumber() ) ); writer.endNode(); writer.startNode( "labName" ); writer.setValue( pbBlankICModel.getLabName() ); writer.endNode(); writer.startNode( "dateCertified" ); writer.setValue( pbBlankICModel.getDateCertified() ); writer.endNode(); writer.startNode( "reference" ); writer.setValue( pbBlankICModel.getReference() ); writer.endNode(); writer.startNode( "comment" ); writer.setValue( pbBlankICModel.getComment() ); writer.endNode(); writer.startNode( "ratios" ); context.convertAnother( pbBlankICModel.getData() ); writer.endNode(); writer.startNode( "rhos" ); context.convertAnother( pbBlankICModel.getRhosVarUnctForXMLSerialization() ); writer.endNode(); }
Example 18
Source File: HibernateCollectionConverterImpl.java From yes-cart with Apache License 2.0 | 4 votes |
@Override public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { if (((AbstractPersistentCollection) source).wasInitialized()) { context.convertAnother(new ArrayList((Collection) source)); } }
Example 19
Source File: HibernateProxyConverter.java From onedev with MIT License | 4 votes |
@Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Object implementation = ((HibernateProxy)source).getHibernateLazyInitializer().getImplementation(); context.convertAnother(implementation); }
Example 20
Source File: MineralStandardUPbModelXMLConverter.java From ET_Redux with Apache License 2.0 | 4 votes |
/** * * @param value * @param writer * @param context */ @Override public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { AbstractRatiosDataModel mineralStandardUPbModel = (MineralStandardUPbModel) value; writer.startNode("modelName"); writer.setValue(mineralStandardUPbModel.getModelName()); writer.endNode(); writer.startNode("versionNumber"); writer.setValue(Integer.toString(mineralStandardUPbModel.getVersionNumber())); writer.endNode(); writer.startNode("minorVersionNumber"); writer.setValue(Integer.toString(mineralStandardUPbModel.getMinorVersionNumber())); writer.endNode(); writer.startNode("labName"); writer.setValue(mineralStandardUPbModel.getLabName()); writer.endNode(); writer.startNode("dateCertified"); writer.setValue(mineralStandardUPbModel.getDateCertified()); writer.endNode(); writer.startNode("reference"); writer.setValue(mineralStandardUPbModel.getReference()); writer.endNode(); writer.startNode("comment"); writer.setValue(mineralStandardUPbModel.getComment()); writer.endNode(); writer.startNode("mineralStandardName"); writer.setValue(((MineralStandardUPbModel) mineralStandardUPbModel).getMineralStandardName()); writer.endNode(); writer.startNode("mineralName"); writer.setValue(((MineralStandardUPbModel) mineralStandardUPbModel).getMineralName()); writer.endNode(); if (!((MineralStandardUPbModel) mineralStandardUPbModel).getInitialPbModelET().equals(MineralStandardUPbModel.getNoneInstance())) { writer.startNode("initialPbModelET"); context.convertAnother(((MineralStandardUPbModel) mineralStandardUPbModel).getInitialPbModelET()); writer.endNode(); } writer.startNode("ratios"); context.convertAnother(mineralStandardUPbModel.getData()); writer.endNode(); writer.startNode("rhos"); context.convertAnother(mineralStandardUPbModel.getRhosVarUnctForXMLSerialization()); writer.endNode(); // dec 2014 writer.startNode("concentrationsPPM"); context.convertAnother(((MineralStandardUPbModel) mineralStandardUPbModel).getConcentrationsPPM()); writer.endNode(); }