public interface IRevisionCriteria
Example:
public void revisionSpecifiedCriteria() throws Exception
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This does not count as a revision. ");
// To register our edits as revisions, we need to declare an author, and then start tracking them.
doc.startTrackRevisions("John Doe", new Date());
builder.write("This is insertion revision #1. ");
doc.stopTrackRevisions();
doc.startTrackRevisions("Jane Doe", new Date());
builder.write("This is insertion revision #2. ");
// Remove a run "This does not count as a revision.".
doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
doc.stopTrackRevisions();
Assert.assertEquals(3, doc.getRevisions().getCount());
// We have two revisions from different authors, so we need to accept only one.
doc.getRevisions().accept(new RevisionCriteria("John Doe", RevisionType.INSERTION));
Assert.assertEquals(2, doc.getRevisions().getCount());
// Reject revision with different author name and revision type.
doc.getRevisions().reject(new RevisionCriteria("Jane Doe", RevisionType.DELETION));
Assert.assertEquals(1, doc.getRevisions().getCount());
doc.save(getArtifactsDir() + "Revision.RevisionSpecifiedCriteria.docx");
}
/// <summary>
/// Control when certain revision should be accepted/rejected.
/// </summary>
public static class RevisionCriteria implements IRevisionCriteria
{
private String AuthorName;
private int _RevisionType;
public RevisionCriteria(String authorName, int revisionType)
{
AuthorName = authorName;
_RevisionType = revisionType;
}
public boolean isMatch(Revision revision)
{
return AuthorName.equals(revision.getAuthor()) && revision.getRevisionType() == _RevisionType;
}
}
| Method Summary | ||
|---|---|---|
abstract boolean | isMatch(Revision revision) | |
| Checks whether or not specified revision matches criteria. | ||
| Method Detail |
|---|
isMatch | |
public abstract boolean isMatch(Revision revision) throws java.lang.Exception | |
revision - The True if the revision matches criteria, otherwise False.Example:
Shows how to accept or reject revision based on criteria.
public void revisionSpecifiedCriteria() throws Exception
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This does not count as a revision. ");
// To register our edits as revisions, we need to declare an author, and then start tracking them.
doc.startTrackRevisions("John Doe", new Date());
builder.write("This is insertion revision #1. ");
doc.stopTrackRevisions();
doc.startTrackRevisions("Jane Doe", new Date());
builder.write("This is insertion revision #2. ");
// Remove a run "This does not count as a revision.".
doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
doc.stopTrackRevisions();
Assert.assertEquals(3, doc.getRevisions().getCount());
// We have two revisions from different authors, so we need to accept only one.
doc.getRevisions().accept(new RevisionCriteria("John Doe", RevisionType.INSERTION));
Assert.assertEquals(2, doc.getRevisions().getCount());
// Reject revision with different author name and revision type.
doc.getRevisions().reject(new RevisionCriteria("Jane Doe", RevisionType.DELETION));
Assert.assertEquals(1, doc.getRevisions().getCount());
doc.save(getArtifactsDir() + "Revision.RevisionSpecifiedCriteria.docx");
}
/// <summary>
/// Control when certain revision should be accepted/rejected.
/// </summary>
public static class RevisionCriteria implements IRevisionCriteria
{
private String AuthorName;
private int _RevisionType;
public RevisionCriteria(String authorName, int revisionType)
{
AuthorName = authorName;
_RevisionType = revisionType;
}
public boolean isMatch(Revision revision)
{
return AuthorName.equals(revision.getAuthor()) && revision.getRevisionType() == _RevisionType;
}
}