public final class DocumentPrivilege extends Object implements Comparable<Object>
Represents the privileges for accessing Pdf file. Refer toPdfFileSecurity
. There are 4
ways using this class: 1.Using predefined privilege directly. 2.Based on a predefined privilege
and change some specifical permissions. 3.Based on a predefined privilege and change some
specifical Adobe Professional permissions combination. 4.Mixes the way2 and way3.
//Way1: Using predefined privilege directly. DocumentPrivilege privilege = DocumentPrivilege.getPrint(); //Way2: Based on a predefined privilege and change some specifical permissions. DocumentPrivilege privilege = DocumentPrivilege.getAllowAll(); privilege.setAllowPrint(false); privilege.setAllowModifyContents(false); //Way3: Based on a predefined privilege and change some specifical Adobe Professional permissions combination. DocumentPrivilege privilege = DocumentPrivilege.getForbidAll(); privilege.setChangeAllowLevel(1); privilege.setPrintAllowLevel(2); //Way4: Mixes the way2 and way3 DocumentPrivilege privilege = DocumentPrivilege.getForbidAll(); privilege.setChangeAllowLevel(1); privilege.setAllowPrint(true);
Constructor and Description |
---|
DocumentPrivilege(int value)
Constructor
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Object obj)
Compares two
DocumentPrivilege objects. |
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
static DocumentPrivilege |
getAllowAll()
All allowed.
|
static DocumentPrivilege |
getAssembly()
Allows assemblying file.
|
static DocumentPrivilege |
getCopy()
Allows copying file.
|
static DocumentPrivilege |
getDegradedPrinting()
Allows degraded printing.
|
static DocumentPrivilege |
getFillIn()
Allows filling forms in file.
|
static DocumentPrivilege |
getForbidAll()
All Forbidded.
|
static DocumentPrivilege |
getModifyAnnotations()
Allows modifying annotations of file.
|
static DocumentPrivilege |
getModifyContents()
Allows modifying file.
|
static DocumentPrivilege |
getPrint()
Allows printing file.
|
static DocumentPrivilege |
getScreenReaders()
Allows to reader on screen only.
|
int |
getValue()
Gets value
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isAllowAssembly()
Sets the permission which allow assembly or not. true is allow and false is forbidden.
|
boolean |
isAllowCopy()
Sets the permission which allow copy or not. true is allow and false is forbidden.
|
boolean |
isAllowDegradedPrinting()
Sets the permission which allow degraded printing or not. true is allow and false is
forbidden.
|
boolean |
isAllowFillIn()
Sets the permission which allow fill in forms or not. true is allow and false is forbidden.
|
boolean |
isAllowModifyAnnotations()
Sets the permission which allow modify annotations or not. true is allow and false is
forbidden.
|
boolean |
isAllowModifyContents()
Sets the permission which allow modify contents or not. true is allow and false is forbidden.
|
boolean |
isAllowPrint()
Sets the permission which allow print or not. true is allow and false is forbidden.
|
boolean |
isAllowScreenReaders()
Sets the permission which allow screen readers or not. true is allow and false is forbidden.
|
void |
setAllowAssembly(boolean value)
Sets the permission which allow assembly or not. true is allow and false is forbidden.
|
void |
setAllowCopy(boolean value)
Sets the permission which allow copy or not. true is allow and false is forbidden.
|
void |
setAllowDegradedPrinting(boolean value)
Sets the permission which allow degraded printing or not. true is allow and false is
forbidden.
|
void |
setAllowFillIn(boolean value)
Sets the permission which allow fill in forms or not. true is allow and false is forbidden.
|
void |
setAllowModifyAnnotations(boolean value)
Sets the permission which allow modify annotations or not. true is allow and false is
forbidden.
|
void |
setAllowModifyContents(boolean value)
Sets the permission which allow modify contents or not. true is allow and false is forbidden.
|
void |
setAllowPrint(boolean value)
Sets the permission which allow print or not. true is allow and false is forbidden.
|
void |
setAllowScreenReaders(boolean value)
Sets the permission which allow screen readers or not. true is allow and false is forbidden.
|
void |
setChangeAllowLevel(int value)
Sets the change level of document's privilege.
|
void |
setCopyAllowLevel(int value)
Sets the copy level of document's privilege.
|
void |
setPrintAllowLevel(int value)
Sets the print level of document's privilege.
|
public DocumentPrivilege(int value)
value
- int valuepublic int getValue()
Gets value
public boolean isAllowPrint()
Sets the permission which allow print or not. true is allow and false is forbidden.
public void setAllowPrint(boolean value)
Sets the permission which allow print or not. true is allow and false is forbidden.
value
- boolean valuepublic boolean isAllowDegradedPrinting()
Sets the permission which allow degraded printing or not. true is allow and false is forbidden.
public void setAllowDegradedPrinting(boolean value)
Sets the permission which allow degraded printing or not. true is allow and false is forbidden.
value
- boolean valuepublic boolean isAllowModifyContents()
Sets the permission which allow modify contents or not. true is allow and false is forbidden.
public void setAllowModifyContents(boolean value)
Sets the permission which allow modify contents or not. true is allow and false is forbidden.
value
- boolean valuepublic boolean isAllowCopy()
Sets the permission which allow copy or not. true is allow and false is forbidden.
public void setAllowCopy(boolean value)
Sets the permission which allow copy or not. true is allow and false is forbidden.
value
- boolean valuepublic boolean isAllowModifyAnnotations()
Sets the permission which allow modify annotations or not. true is allow and false is forbidden.
public void setAllowModifyAnnotations(boolean value)
Sets the permission which allow modify annotations or not. true is allow and false is forbidden.
value
- boolean valuepublic boolean isAllowFillIn()
Sets the permission which allow fill in forms or not. true is allow and false is forbidden.
public void setAllowFillIn(boolean value)
Sets the permission which allow fill in forms or not. true is allow and false is forbidden.
value
- boolean valuepublic boolean isAllowScreenReaders()
Sets the permission which allow screen readers or not. true is allow and false is forbidden.
public void setAllowScreenReaders(boolean value)
Sets the permission which allow screen readers or not. true is allow and false is forbidden.
value
- boolean valuepublic boolean isAllowAssembly()
Sets the permission which allow assembly or not. true is allow and false is forbidden.
public void setAllowAssembly(boolean value)
Sets the permission which allow assembly or not. true is allow and false is forbidden.
value
- boolean valuepublic void setPrintAllowLevel(int value)
Sets the print level of document's privilege. Just as the Adobe Professional's Printing Allowed settings. 0: None. 1: Low Resolution (150 dpi). 2: High Resolution.
value
- int valuepublic void setChangeAllowLevel(int value)
Sets the change level of document's privilege. Just as the Adobe Professional's Changes Allowed settings. 0: None. 1: Inserting, Deleting and Rotating pages. 2: Filling in form fields and signing existing signature fields. 3: Commenting, filling in form fields, and signing existing signature fields. 4: Any except extracting pages.
value
- int valuepublic void setCopyAllowLevel(int value)
Sets the copy level of document's privilege. Just as the Adobe Professional's permission settings. 0: None. 1: Enable text access for screen reader devices for the visually impaired. 2: Enable copying of text, images and other content.
value
- int valuepublic int compareTo(Object obj)
Compares two DocumentPrivilege
objects.
compareTo
in interface Comparable<Object>
obj
- The object to compare with.public int hashCode()
java.util.Hashtable
.
The general contract of hashCode
is:
hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
public boolean equals(Object obj)
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y) consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.
equals
in class Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.hashCode()
,
Hashtable
public static DocumentPrivilege getDegradedPrinting()
Allows degraded printing.
public static DocumentPrivilege getPrint()
Allows printing file.
public static DocumentPrivilege getModifyContents()
Allows modifying file.
public static DocumentPrivilege getCopy()
Allows copying file.
public static DocumentPrivilege getModifyAnnotations()
Allows modifying annotations of file.
public static DocumentPrivilege getFillIn()
Allows filling forms in file.
public static DocumentPrivilege getScreenReaders()
Allows to reader on screen only.
public static DocumentPrivilege getAssembly()
Allows assemblying file.
public static DocumentPrivilege getAllowAll()
All allowed.
public static DocumentPrivilege getForbidAll()
All Forbidded.