"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdfbox/src/main/java/org/apache/pdfbox/cos/COSInteger.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

COSInteger.java  (pdfbox-2.0.23-src):COSInteger.java  (pdfbox-2.0.24-src)
skipping to change at line 71 skipping to change at line 71
*/ */
public static final COSInteger TWO = get(2); public static final COSInteger TWO = get(2);
/** /**
* Constant for the number three. * Constant for the number three.
* @since Apache PDFBox 1.1.0 * @since Apache PDFBox 1.1.0
*/ */
public static final COSInteger THREE = get(3); public static final COSInteger THREE = get(3);
/** /**
* Constant for an out of range value which is bigger than Log.MAX_VALUE.
*/
protected static final COSInteger OUT_OF_RANGE_MAX = getInvalid(true);
/**
* Constant for an out of range value which is smaller than Log.MIN_VALUE.
*/
protected static final COSInteger OUT_OF_RANGE_MIN = getInvalid(false);
/**
* Returns a COSInteger instance with the given value. * Returns a COSInteger instance with the given value.
* *
* @param val integer value * @param val integer value
* @return COSInteger instance * @return COSInteger instance
*/ */
public static COSInteger get(long val) public static COSInteger get(long val)
{ {
if (LOW <= val && val <= HIGH) if (LOW <= val && val <= HIGH)
{ {
int index = (int) val - LOW; int index = (int) val - LOW;
// no synchronization needed // no synchronization needed
if (STATIC[index] == null) if (STATIC[index] == null)
{ {
STATIC[index] = new COSInteger(val); STATIC[index] = new COSInteger(val, true);
} }
return STATIC[index]; return STATIC[index];
} }
return new COSInteger(val); return new COSInteger(val, true);
}
private static COSInteger getInvalid(boolean maxValue)
{
return maxValue ? new COSInteger(Long.MAX_VALUE, false)
: new COSInteger(Long.MIN_VALUE, false);
} }
private final long value; private final long value;
private final boolean isValid;
/** /**
* constructor. * constructor.
* *
* @param val The integer value of this object. * @param val The integer value of this object.
*/ */
private COSInteger( long val ) private COSInteger(long val, boolean valid)
{ {
value = val; value = val;
isValid = valid;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean equals(Object o) public boolean equals(Object o)
{ {
return o instanceof COSInteger && ((COSInteger)o).intValue() == intValue (); return o instanceof COSInteger && ((COSInteger)o).intValue() == intValue ();
} }
skipping to change at line 180 skipping to change at line 198
* *
* @return The int value of this object, * @return The int value of this object,
*/ */
@Override @Override
public long longValue() public long longValue()
{ {
return value; return value;
} }
/** /**
* Indicates whether this instance represents a valid value.
*
* @return true if the value is valid
*/
public boolean isValid()
{
return isValid;
}
/**
* visitor pattern double dispatch method. * visitor pattern double dispatch method.
* *
* @param visitor The object to notify when visiting this object. * @param visitor The object to notify when visiting this object.
* @return any object, depending on the visitor implementation, or null * @return any object, depending on the visitor implementation, or null
* @throws IOException If an error occurs while visiting this object. * @throws IOException If an error occurs while visiting this object.
*/ */
@Override @Override
public Object accept(ICOSVisitor visitor) throws IOException public Object accept(ICOSVisitor visitor) throws IOException
{ {
return visitor.visitFromInt(this); return visitor.visitFromInt(this);
 End of changes. 7 change blocks. 
3 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)