com.aspose.words
Class OdsoFieldMapData

java.lang.Object
    extended by com.aspose.words.OdsoFieldMapData
All Implemented Interfaces:
java.lang.Cloneable

public class OdsoFieldMapData 
extends java.lang.Object

Specifies how a column in the external data source shall be mapped to the predefined merge fields within the document.

Microsoft Word provides some predefined merge field names that it allows to insert into a document as MERGEFIELD or use in the ADDRESSBLOCK or GREETINGLINE fields. The information specified in OdsoFieldMapData allows to map one column in the external data source to a single predefined merge field.

Example:

Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "OdsoData.doc");

// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection fieldMapDataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();

Assert.assertEquals(fieldMapDataCollection.getCount(), 30);
int index = 0;

for (OdsoFieldMapData data : fieldMapDataCollection) {
    System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));

    if (data.getType() != OdsoFieldMappingType.NULL) {
        System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
    } else {
        System.out.println("\tNo valid column to field mapping data present.");
    }

    Assert.assertNotEquals(data, data.deepClone());
}
See Also:
OdsoFieldMapDataCollection, Odso

Constructor Summary
OdsoFieldMapData()
          
 
Property Getters/Setters Summary
intgetColumn()
voidsetColumn(int value)
           Specifies the zero-based index of the column within an external data source which shall be mapped to the local name of a specific MERGEFIELD field. The default value is 0.
java.lang.StringgetMappedName()
voidsetMappedName(java.lang.String value)
           Specifies the predefined merge field name which shall be mapped to the column number specified by the Column property within this field mapping. The default value is an empty string.
java.lang.StringgetName()
voidsetName(java.lang.String value)
           Specifies the column name within an external data source for the column whose index is specified by the Column property. The default value is an empty string.
intgetType()
voidsetType(int value)
           Specifies if a given mail merge field has been mapped to a column in the given external data source or not. The default value is OdsoFieldMappingType.DEFAULT. The value of the property is OdsoFieldMappingType integer constant.
 
Method Summary
OdsoFieldMapDatadeepClone()
           Returns a deep clone of this object.
 

Constructor Detail

OdsoFieldMapData

public OdsoFieldMapData()

Property Getters/Setters Detail

getColumn/setColumn

public int getColumn() / public void setColumn(int value)
Specifies the zero-based index of the column within an external data source which shall be mapped to the local name of a specific MERGEFIELD field. The default value is 0.

Example:

Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "OdsoData.doc");

// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection fieldMapDataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();

Assert.assertEquals(fieldMapDataCollection.getCount(), 30);
int index = 0;

for (OdsoFieldMapData data : fieldMapDataCollection) {
    System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));

    if (data.getType() != OdsoFieldMappingType.NULL) {
        System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
    } else {
        System.out.println("\tNo valid column to field mapping data present.");
    }

    Assert.assertNotEquals(data, data.deepClone());
}

getMappedName/setMappedName

public java.lang.String getMappedName() / public void setMappedName(java.lang.String value)
Specifies the predefined merge field name which shall be mapped to the column number specified by the Column property within this field mapping. The default value is an empty string.

Example:

Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "OdsoData.doc");

// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection fieldMapDataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();

Assert.assertEquals(fieldMapDataCollection.getCount(), 30);
int index = 0;

for (OdsoFieldMapData data : fieldMapDataCollection) {
    System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));

    if (data.getType() != OdsoFieldMappingType.NULL) {
        System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
    } else {
        System.out.println("\tNo valid column to field mapping data present.");
    }

    Assert.assertNotEquals(data, data.deepClone());
}

getName/setName

public java.lang.String getName() / public void setName(java.lang.String value)
Specifies the column name within an external data source for the column whose index is specified by the Column property. The default value is an empty string.

Example:

Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "OdsoData.doc");

// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection fieldMapDataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();

Assert.assertEquals(fieldMapDataCollection.getCount(), 30);
int index = 0;

for (OdsoFieldMapData data : fieldMapDataCollection) {
    System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));

    if (data.getType() != OdsoFieldMappingType.NULL) {
        System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
    } else {
        System.out.println("\tNo valid column to field mapping data present.");
    }

    Assert.assertNotEquals(data, data.deepClone());
}

getType/setType

public int getType() / public void setType(int value)
Specifies if a given mail merge field has been mapped to a column in the given external data source or not. The default value is OdsoFieldMappingType.DEFAULT. The value of the property is OdsoFieldMappingType integer constant.

Example:

Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "OdsoData.doc");

// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection fieldMapDataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();

Assert.assertEquals(fieldMapDataCollection.getCount(), 30);
int index = 0;

for (OdsoFieldMapData data : fieldMapDataCollection) {
    System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));

    if (data.getType() != OdsoFieldMappingType.NULL) {
        System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
    } else {
        System.out.println("\tNo valid column to field mapping data present.");
    }

    Assert.assertNotEquals(data, data.deepClone());
}

Method Detail

deepClone

public OdsoFieldMapData deepClone()
Returns a deep clone of this object.

Example:

Shows how to access the collection of data that maps data source columns to merge fields.
Document doc = new Document(getMyDir() + "OdsoData.doc");

// This collection defines how columns from an external data source will be mapped to predefined MERGEFIELD,
// ADDRESSBLOCK and GREETINGLINE fields during a mail merge
OdsoFieldMapDataCollection fieldMapDataCollection = doc.getMailMergeSettings().getOdso().getFieldMapDatas();

Assert.assertEquals(fieldMapDataCollection.getCount(), 30);
int index = 0;

for (OdsoFieldMapData data : fieldMapDataCollection) {
    System.out.println(MessageFormat.format("Field map data index #{0}, type \"{1}\":", index++, data.getType()));

    if (data.getType() != OdsoFieldMappingType.NULL) {
        System.out.println(MessageFormat.format("\tColumn named {0}, number {1} in the data source mapped to merge field named {2}.", data.getName(), data.getColumn(), data.getMappedName()));
    } else {
        System.out.println("\tNo valid column to field mapping data present.");
    }

    Assert.assertNotEquals(data, data.deepClone());
}

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.