public class FieldAddressBlock extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Represents an address block. An address block is a block of text specifying information appropriate for a postal mailing address, in the order required by the destination country.
Examples:
Shows how to get mail merge field names used by the field.
Document doc = new Document(getMyDir() + "Field sample - ADDRESSBLOCK.docx");
String[] addressFieldsExpect = {"Company", "First Name", "Middle Name", "Last Name", "Suffix", "Address 1", "City", "State", "Country or Region", "Postal Code"};
FieldAddressBlock addressBlockField = (FieldAddressBlock) doc.getRange().getFields().get(0);
String[] addressBlockFieldNames = addressBlockField.getFieldNames();
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getExcludedCountryOrRegionName()
Gets the excluded country/region name.
|
java.lang.String[] |
getFieldNames()
Returns a collection of mail merge field names used by the field.
|
boolean |
getFormatAddressOnCountryOrRegion()
Gets whether to format the address according to the country/region of the recipient as defined by POST*CODE (Universal Postal Union 2006).
|
java.lang.String |
getIncludeCountryOrRegionName()
Gets whether to include the name of the country/region.
|
java.lang.String |
getLanguageId()
Gets the language ID used to format the address.
|
java.lang.String |
getMergeFormat() |
java.lang.String |
getNameAndAddressFormat()
Gets the name and address format.
|
int |
getSwitchType(java.lang.String switchName) |
Document |
iFormattableMergeField_FetchDocument() |
void |
setExcludedCountryOrRegionName(java.lang.String value)
Sets the excluded country/region name.
|
void |
setFormatAddressOnCountryOrRegion(boolean value)
Sets whether to format the address according to the country/region of the recipient as defined by POST*CODE (Universal Postal Union 2006).
|
void |
setIncludeCountryOrRegionName(java.lang.String value)
Sets whether to include the name of the country/region.
|
void |
setLanguageId(java.lang.String value)
Sets the language ID used to format the address.
|
void |
setNameAndAddressFormat(java.lang.String value)
Sets the name and address format.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic boolean getFormatAddressOnCountryOrRegion()
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
public void setFormatAddressOnCountryOrRegion(boolean value)
throws java.lang.Exception
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
value - Whether to format the address according to the country/region of the recipient as defined by POST*CODE (Universal Postal Union 2006).java.lang.Exceptionpublic java.lang.String getIncludeCountryOrRegionName()
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
public void setIncludeCountryOrRegionName(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
value - Whether to include the name of the country/region.java.lang.Exceptionpublic java.lang.String getExcludedCountryOrRegionName()
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
public void setExcludedCountryOrRegionName(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
value - The excluded country/region name.java.lang.Exceptionpublic java.lang.String getNameAndAddressFormat()
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
public void setNameAndAddressFormat(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
value - The name and address format.java.lang.Exceptionpublic java.lang.String getLanguageId()
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
public void setLanguageId(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADDRESSBLOCK field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
FieldAddressBlock field = (FieldAddressBlock) builder.insertField(FieldType.FIELD_ADDRESS_BLOCK, true);
Assert.assertEquals(" ADDRESSBLOCK ", field.getFieldCode());
// Setting this to "2" will include all countries and regions,
// unless it is the one specified in the ExcludedCountryOrRegionName property.
field.setIncludeCountryOrRegionName("2");
field.setFormatAddressOnCountryOrRegion(true);
field.setExcludedCountryOrRegionName("United States");
field.setNameAndAddressFormat("<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>");
// By default, this property will contain the language ID of the first character of the document.
// We can set a different culture for the field to format the result with like this.
field.setLanguageId("1033");
Assert.assertEquals(
" ADDRESSBLOCK \\c 2 \\d \\e \"United States\" \\f \"<Title> <Forename> <Surname> <Address Line 1> <Region> <Postcode> <Country>\" \\l 1033",
field.getFieldCode());
value - The language ID used to format the address.java.lang.Exceptionpublic java.lang.String[] getFieldNames()
throws java.lang.Exception
Examples:
Shows how to get mail merge field names used by the field.
Document doc = new Document(getMyDir() + "Field sample - ADDRESSBLOCK.docx");
String[] addressFieldsExpect = {"Company", "First Name", "Middle Name", "Last Name", "Suffix", "Address 1", "City", "State", "Country or Region", "Postal Code"};
FieldAddressBlock addressBlockField = (FieldAddressBlock) doc.getRange().getFields().get(0);
String[] addressBlockFieldNames = addressBlockField.getFieldNames();
java.lang.Exceptionpublic int getSwitchType(java.lang.String switchName)
public Document iFormattableMergeField_FetchDocument()
public java.lang.String getMergeFormat()