public class FieldToa extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Builds a table of authorities (that is, a list of the references in a legal document, such as references to cases, statutes, and rules, along with the numbers of the pages on which the references appear) using the entries specified by TA fields.
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 |
getBookmarkName()
Gets the name of the bookmark that marks the portion of the document used to build the table.
|
java.lang.String |
getEntryCategory()
Gets the integral category for entries included in the table.
|
java.lang.String |
getEntrySeparator()
Gets the character sequence that is used to separate a table of authorities entry and its page number.
|
java.lang.String |
getPageNumberListSeparator()
Gets the character sequence that is used to separate two page numbers in a page number list.
|
java.lang.String |
getPageRangeSeparator()
Gets the character sequence that is used to separate the start and end of a page range.
|
boolean |
getRemoveEntryFormatting()
Gets whether to remove the formatting of the entry text in the document from the entry in the table of authorities.
|
java.lang.String |
getSequenceName()
Gets the name of a sequence whose number is included with the page number.
|
java.lang.String |
getSequenceSeparator()
Gets the character sequence that is used to separate sequence numbers and page numbers.
|
int |
getSwitchType(java.lang.String switchName) |
boolean |
getUseHeading()
Gets whether to include the category heading for the entries in a table of authorities.
|
boolean |
getUsePassim()
Gets whether to replace five or more different page references to the same authority with "passim", which is used to indicate that a word or passage occurs frequently in the work cited.
|
void |
setBookmarkName(java.lang.String value)
Sets the name of the bookmark that marks the portion of the document used to build the table.
|
void |
setEntryCategory(java.lang.String value)
Sets the integral category for entries included in the table.
|
void |
setEntrySeparator(java.lang.String value)
Sets the character sequence that is used to separate a table of authorities entry and its page number.
|
void |
setPageNumberListSeparator(java.lang.String value)
Sets the character sequence that is used to separate two page numbers in a page number list.
|
void |
setPageRangeSeparator(java.lang.String value)
Sets the character sequence that is used to separate the start and end of a page range.
|
void |
setRemoveEntryFormatting(boolean value)
Sets whether to remove the formatting of the entry text in the document from the entry in the table of authorities.
|
void |
setSequenceName(java.lang.String value)
Sets the name of a sequence whose number is included with the page number.
|
void |
setSequenceSeparator(java.lang.String value)
Sets the character sequence that is used to separate sequence numbers and page numbers.
|
void |
setUseHeading(boolean value)
Sets whether to include the category heading for the entries in a table of authorities.
|
void |
setUsePassim(boolean value)
Sets whether to replace five or more different page references to the same authority with "passim", which is used to indicate that a word or passage occurs frequently in the work cited.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic int getSwitchType(java.lang.String switchName)
public java.lang.String getBookmarkName()
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 setBookmarkName(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 the portion of the document used to build the table.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 category for entries included in the table.java.lang.Exceptionpublic java.lang.String getSequenceSeparator()
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 setSequenceSeparator(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 character sequence that is used to separate sequence numbers and page numbers.java.lang.Exceptionpublic java.lang.String getEntrySeparator()
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 setEntrySeparator(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 character sequence that is used to separate a table of authorities entry and its page number.java.lang.Exceptionpublic boolean getRemoveEntryFormatting()
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 setRemoveEntryFormatting(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 remove the formatting of the entry text in the document from the entry in the table of authorities.java.lang.Exceptionpublic java.lang.String getPageRangeSeparator()
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 setPageRangeSeparator(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 character sequence that is used to separate the start and end of a page range.java.lang.Exceptionpublic boolean getUseHeading()
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 setUseHeading(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 include the category heading for the entries in a table of authorities.java.lang.Exceptionpublic java.lang.String getPageNumberListSeparator()
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 setPageNumberListSeparator(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 character sequence that is used to separate two page numbers in a page number list.java.lang.Exceptionpublic boolean getUsePassim()
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 setUsePassim(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 replace five or more different page references to the same authority with "passim", which is used to indicate that a word or passage occurs frequently in the work cited.java.lang.Exceptionpublic java.lang.String getSequenceName()
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 setSequenceName(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 a sequence whose number is included with the page number.java.lang.Exception