public class FieldTA extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Defines the text and page number for a table of authorities entry, which is used by a TOA field.
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getEntryCategory()
Gets the integral entry category, which is a number that corresponds to the order of categories.
|
java.lang.String |
getLongCitation()
Gets the long citation for the entry.
|
java.lang.String |
getPageRangeBookmarkName()
Gets the name of the bookmark that marks a range of pages that is inserted as the entry's page number.
|
java.lang.String |
getShortCitation()
Gets the short citation for the entry.
|
int |
getSwitchType(java.lang.String switchName) |
boolean |
isBold()
Gets whether to apply bold formatting to the page number for the entry.
|
void |
isBold(boolean value)
Sets whether to apply bold formatting to the page number for the entry.
|
boolean |
isItalic()
Gets whether to apply italic formatting to the page number for the entry.
|
void |
isItalic(boolean value)
Sets whether to apply italic formatting to the page number for the entry.
|
void |
setEntryCategory(java.lang.String value)
Sets the integral entry category, which is a number that corresponds to the order of categories.
|
void |
setLongCitation(java.lang.String value)
Sets the long citation for the entry.
|
void |
setPageRangeBookmarkName(java.lang.String value)
Sets the name of the bookmark that marks a range of pages that is inserted as the entry's page number.
|
void |
setShortCitation(java.lang.String value)
Sets the short citation for the entry.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic boolean isBold()
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
public void isBold(boolean value)
throws java.lang.Exception
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
value - Whether to apply bold formatting to the page number for the entry.java.lang.Exceptionpublic java.lang.String getEntryCategory()
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
public void setEntryCategory(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
value - The integral entry category, which is a number that corresponds to the order of categories.java.lang.Exceptionpublic boolean isItalic()
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
public void isItalic(boolean value)
throws java.lang.Exception
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
value - Whether to apply italic formatting to the page number for the entry.java.lang.Exceptionpublic java.lang.String getLongCitation()
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
public void setLongCitation(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
value - The long citation for the entry.java.lang.Exceptionpublic java.lang.String getPageRangeBookmarkName()
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
public void setPageRangeBookmarkName(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
value - The name of the bookmark that marks a range of pages that is inserted as the entry's page number.java.lang.Exceptionpublic java.lang.String getShortCitation()
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
public void setShortCitation(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to build and customize a table of authorities using TOA and TA fields.
public void fieldTOA() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a TOA field, which will create an entry for each TA field in the document,
// displaying long citations and page numbers for each entry.
FieldToa fieldToa = (FieldToa) builder.insertField(FieldType.FIELD_TOA, false);
// Set the entry category for our table. This TOA will now only include TA fields
// that have a matching value in their EntryCategory property.
fieldToa.setEntryCategory("1");
// Moreover, the Table of Authorities category at index 1 is "Cases",
// which will show up as our table's title if we set this variable to true.
fieldToa.setUseHeading(true);
// We can further filter TA fields by naming a bookmark that they will need to be within the TOA bounds.
fieldToa.setBookmarkName("MyBookmark");
// By default, a dotted line page-wide tab appears between the TA field's citation
// and its page number. We can replace it with any text we put on this property.
// Inserting a tab character will preserve the original tab.
fieldToa.setEntrySeparator(" \t p.");
// If we have multiple TA entries that share the same long citation,
// all their respective page numbers will show up on one row.
// We can use this property to specify a string that will separate their page numbers.
fieldToa.setPageNumberListSeparator(" & p. ");
// We can set this to true to get our table to display the word "passim"
// if there are five or more page numbers in one row.
fieldToa.setUsePassim(true);
// One TA field can refer to a range of pages.
// We can specify a string here to appear between the start and end page numbers for such ranges.
fieldToa.setPageRangeSeparator(" to ");
// The format from the TA fields will carry over into our table.
// We can disable this by setting the RemoveEntryFormatting flag.
fieldToa.setRemoveEntryFormatting(true);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setName("Arial Black");
Assert.assertEquals(fieldToa.getFieldCode(), " TOA \\c 1 \\h \\b MyBookmark \\e \" \t p.\" \\l \" & p. \" \\p \\g \" to \" \\f");
builder.insertBreak(BreakType.PAGE_BREAK);
// This TA field will not appear as an entry in the TOA since it is outside
// the bookmark's bounds that the TOA's BookmarkName property specifies.
FieldTA fieldTA = insertToaEntry(builder, "1", "Source 1");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 1\"");
// This TA field is inside the bookmark,
// but the entry category does not match that of the table, so the TA field will not include it.
builder.startBookmark("MyBookmark");
fieldTA = insertToaEntry(builder, "2", "Source 2");
// This entry will appear in the table.
fieldTA = insertToaEntry(builder, "1", "Source 3");
// A TOA table does not display short citations,
// but we can use them as a shorthand to refer to bulky source names that multiple TA fields reference.
fieldTA.setShortCitation("S.3");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\s S.3");
// We can format the page number to make it bold/italic using the following properties.
// We will still see these effects if we set our table to ignore formatting.
fieldTA = insertToaEntry(builder, "1", "Source 2");
fieldTA.isBold(true);
fieldTA.isItalic(true);
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 2\" \\b \\i");
// We can configure TA fields to get their TOA entries to refer to a range of pages that a bookmark spans across.
// Note that this entry refers to the same source as the one above to share one row in our table.
// This row will have the page number of the entry above and the page range of this entry,
// with the table's page list and page number range separators between page numbers.
fieldTA = insertToaEntry(builder, "1", "Source 3");
fieldTA.setPageRangeBookmarkName("MyMultiPageBookmark");
builder.startBookmark("MyMultiPageBookmark");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.insertBreak(BreakType.PAGE_BREAK);
builder.endBookmark("MyMultiPageBookmark");
Assert.assertEquals(fieldTA.getFieldCode(), " TA \\c 1 \\l \"Source 3\" \\r MyMultiPageBookmark");
// If we have enabled the "Passim" feature of our table, having 5 or more TA entries with the same source will invoke it.
for (int i = 0; i < 5; i++) {
insertToaEntry(builder, "1", "Source 4");
}
builder.endBookmark("MyBookmark");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TOA.TA.docx");
}
private static FieldTA insertToaEntry(DocumentBuilder builder, String entryCategory, String longCitation) throws Exception {
FieldTA field = (FieldTA) builder.insertField(FieldType.FIELD_TOA_ENTRY, false);
field.setEntryCategory(entryCategory);
field.setLongCitation(longCitation);
builder.insertBreak(BreakType.PAGE_BREAK);
return field;
}
value - The short citation for the entry.java.lang.Exceptionpublic int getSwitchType(java.lang.String switchName)