Granularity
Contents
[
Hide
]Inheritance: java.lang.Object
public class Granularity
Specifies the granularity of changes to track when comparing two documents.
Examples:
Shows to specify a granularity while comparing documents.
Document docA = new Document();
DocumentBuilder builderA = new DocumentBuilder(docA);
builderA.writeln("Alpha Lorem ipsum dolor sit amet, consectetur adipiscing elit");
Document docB = new Document();
DocumentBuilder builderB = new DocumentBuilder(docB);
builderB.writeln("Lorems ipsum dolor sit amet consectetur - \"adipiscing\" elit");
// Specify whether changes are tracking
// by character ('Granularity.CharLevel'), or by word ('Granularity.WordLevel').
CompareOptions compareOptions = new CompareOptions();
compareOptions.setGranularity(granularity);
docA.compare(docB, "author", new Date(), compareOptions);
// The first document's collection of revision groups contains all the differences between documents.
RevisionGroupCollection groups = docA.getRevisions().getGroups();
Assert.assertEquals(5, groups.getCount());
Fields
Field | Description |
---|---|
CHAR_LEVEL | Specifies changes at the character level. |
WORD_LEVEL | Specifies changes at the word level. |
length |
Methods
Method | Description |
---|---|
fromName(String granularityName) | |
getName(int granularity) | |
getValues() | |
toString(int granularity) |
CHAR_LEVEL
public static int CHAR_LEVEL
Specifies changes at the character level.
WORD_LEVEL
public static int WORD_LEVEL
Specifies changes at the word level.
length
public static int length
fromName(String granularityName)
public static int fromName(String granularityName)
Parameters:
Parameter | Type | Description |
---|---|---|
granularityName | java.lang.String |
Returns: int
getName(int granularity)
public static String getName(int granularity)
Parameters:
Parameter | Type | Description |
---|---|---|
granularity | int |
Returns: java.lang.String
getValues()
public static int[] getValues()
Returns: int[]
toString(int granularity)
public static String toString(int granularity)
Parameters:
Parameter | Type | Description |
---|---|---|
granularity | int |
Returns: java.lang.String