SonarCube fix - make members private

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1773315 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-12-09 00:39:49 +00:00
parent d520b11b59
commit 49fc21b812
11 changed files with 64 additions and 47 deletions

View File

@ -37,7 +37,7 @@ public abstract class Bitmap extends HSLFPictureData {
@Override
public byte[] getData(){
byte[] rawdata = getRawData();
int prefixLen = 16*uidInstanceCount+1;
int prefixLen = 16*getUIDInstanceCount()+1;
byte[] imgdata = new byte[rawdata.length-prefixLen];
System.arraycopy(rawdata, prefixLen, imgdata, 0, imgdata.length);
return imgdata;
@ -45,9 +45,10 @@ public abstract class Bitmap extends HSLFPictureData {
@Override
public void setData(byte[] data) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int i=0; i<uidInstanceCount; i++) {
byte[] checksum = getChecksum(data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(checksum);
if (getUIDInstanceCount() == 2) {
out.write(checksum);
}
out.write(0);

View File

@ -41,7 +41,7 @@ public final class DIB extends Bitmap {
* @return DIB signature ({@code 0x7A80} or {@code 0x7A90})
*/
public int getSignature(){
return (uidInstanceCount == 1 ? 0x7A80 : 0x7A90);
return (getUIDInstanceCount() == 1 ? 0x7A80 : 0x7A90);
}
/**
@ -50,10 +50,10 @@ public final class DIB extends Bitmap {
public void setSignature(int signature) {
switch (signature) {
case 0x7A80:
uidInstanceCount = 1;
setUIDInstanceCount(1);
break;
case 0x7A90:
uidInstanceCount = 2;
setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for DIB");

View File

@ -74,7 +74,7 @@ public final class EMF extends Metafile {
byte[] checksum = getChecksum(data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(checksum);
if (uidInstanceCount == 2) {
if (getUIDInstanceCount() == 2) {
out.write(checksum);
}
header.write(out);
@ -94,7 +94,7 @@ public final class EMF extends Metafile {
* @return EMF signature ({@code 0x3D40} or {@code 0x3D50})
*/
public int getSignature(){
return (uidInstanceCount == 1 ? 0x3D40 : 0x3D50);
return (getUIDInstanceCount() == 1 ? 0x3D40 : 0x3D50);
}
/**
@ -103,10 +103,10 @@ public final class EMF extends Metafile {
public void setSignature(int signature) {
switch (signature) {
case 0x3D40:
uidInstanceCount = 1;
setUIDInstanceCount(1);
break;
case 0x3D50:
uidInstanceCount = 2;
setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for EMF");

View File

@ -47,8 +47,8 @@ public final class JPEG extends Bitmap {
*/
public int getSignature(){
return (colorSpace == ColorSpace.rgb)
? (uidInstanceCount == 1 ? 0x46A0 : 0x46B0)
: (uidInstanceCount == 1 ? 0x6E20 : 0x6E30);
? (getUIDInstanceCount() == 1 ? 0x46A0 : 0x46B0)
: (getUIDInstanceCount() == 1 ? 0x6E20 : 0x6E30);
}
/**
@ -57,19 +57,19 @@ public final class JPEG extends Bitmap {
public void setSignature(int signature) {
switch (signature) {
case 0x46A0:
uidInstanceCount = 1;
setUIDInstanceCount(1);
colorSpace = ColorSpace.rgb;
break;
case 0x46B0:
uidInstanceCount = 2;
setUIDInstanceCount(2);
colorSpace = ColorSpace.rgb;
break;
case 0x6E20:
uidInstanceCount = 1;
setUIDInstanceCount(1);
colorSpace = ColorSpace.cymk;
break;
case 0x6E30:
uidInstanceCount = 2;
setUIDInstanceCount(2);
colorSpace = ColorSpace.cymk;
break;
default:

View File

@ -152,7 +152,7 @@ public abstract class Metafile extends HSLFPictureData {
@Override
public Dimension getImageDimension() {
int prefixLen = 16*uidInstanceCount;
int prefixLen = 16*getUIDInstanceCount();
Header header = new Header();
header.read(getRawData(), prefixLen);
return new Dimension(

View File

@ -43,7 +43,7 @@ public final class PICT extends Metafile {
byte[] macheader = new byte[512];
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(macheader);
int pos = CHECKSUM_SIZE*uidInstanceCount;
int pos = CHECKSUM_SIZE*getUIDInstanceCount();
byte[] pict = read(rawdata, pos);
out.write(pict);
return out.toByteArray();
@ -105,7 +105,7 @@ public final class PICT extends Metafile {
byte[] checksum = getChecksum(data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(checksum);
if (uidInstanceCount == 2) {
if (getUIDInstanceCount() == 2) {
out.write(checksum);
}
header.write(out);
@ -125,7 +125,7 @@ public final class PICT extends Metafile {
* @return PICT signature ({@code 0x5420} or {@code 0x5430})
*/
public int getSignature(){
return (uidInstanceCount == 1 ? 0x5420 : 0x5430);
return (getUIDInstanceCount() == 1 ? 0x5420 : 0x5430);
}
/**
@ -134,10 +134,10 @@ public final class PICT extends Metafile {
public void setSignature(int signature) {
switch (signature) {
case 0x5420:
uidInstanceCount = 1;
setUIDInstanceCount(1);
break;
case 0x5430:
uidInstanceCount = 2;
setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for PICT");

View File

@ -50,7 +50,7 @@ public final class PNG extends Bitmap {
* @return PNG signature ({@code 0x6E00} or {@code 0x6E10})
*/
public int getSignature(){
return (uidInstanceCount == 1 ? 0x6E00 : 0x6E10);
return (getUIDInstanceCount() == 1 ? 0x6E00 : 0x6E10);
}
/**
@ -59,10 +59,10 @@ public final class PNG extends Bitmap {
public void setSignature(int signature) {
switch (signature) {
case 0x6E00:
uidInstanceCount = 1;
setUIDInstanceCount(1);
break;
case 0x6E10:
uidInstanceCount = 2;
setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for PNG");

View File

@ -41,9 +41,9 @@ public final class WMF extends Metafile {
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream is = new ByteArrayInputStream( rawdata );
Header header = new Header();
header.read(rawdata, CHECKSUM_SIZE*uidInstanceCount);
long len = is.skip(header.getSize() + CHECKSUM_SIZE*uidInstanceCount);
assert(len == header.getSize() + CHECKSUM_SIZE*uidInstanceCount);
header.read(rawdata, CHECKSUM_SIZE*getUIDInstanceCount());
long len = is.skip(header.getSize() + CHECKSUM_SIZE*getUIDInstanceCount());
assert(len == header.getSize() + CHECKSUM_SIZE*getUIDInstanceCount());
ImageHeaderWMF aldus = new ImageHeaderWMF(header.getBounds());
aldus.write(out);
@ -78,7 +78,8 @@ public final class WMF extends Metafile {
byte[] checksum = getChecksum(data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int i=0; i<uidInstanceCount; i++) {
out.write(checksum);
if (getUIDInstanceCount() == 2) {
out.write(checksum);
}
header.write(out);
@ -96,7 +97,7 @@ public final class WMF extends Metafile {
* WMF signature is either {@code 0x2160} or {@code 0x2170}
*/
public int getSignature(){
return (uidInstanceCount == 1 ? 0x2160 : 0x2170);
return (getUIDInstanceCount() == 1 ? 0x2160 : 0x2170);
}
/**
@ -105,10 +106,10 @@ public final class WMF extends Metafile {
public void setSignature(int signature) {
switch (signature) {
case 0x2160:
uidInstanceCount = 1;
setUIDInstanceCount(1);
break;
case 0x2170:
uidInstanceCount = 2;
setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for WMF");

View File

@ -47,8 +47,7 @@ import org.apache.poi.util.Units;
* Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.
*/
public final class HSLFFill {
// For logging
protected POILogger logger = POILogFactory.getLogger(this.getClass());
private static final POILogger LOG = POILogFactory.getLogger(HSLFFill.class);
/**
* Fill with a solid color
@ -107,7 +106,7 @@ public final class HSLFFill {
/**
* The shape this background applies to
*/
protected HSLFShape shape;
private HSLFShape shape;
/**
* Construct a <code>Fill</code> object for a shape.
@ -141,7 +140,7 @@ public final class HSLFFill {
case FILL_PICTURE:
return getTexturePaint();
default:
logger.log(POILogger.WARN, "unsuported fill type: " + fillType);
LOG.log(POILogger.WARN, "unsuported fill type: " + fillType);
return null;
}
}
@ -255,7 +254,7 @@ public final class HSLFFill {
protected EscherBSERecord getEscherBSERecord(int idx){
HSLFSheet sheet = shape.getSheet();
if(sheet == null) {
logger.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet");
LOG.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet");
return null;
}
HSLFSlideShow ppt = sheet.getSlideShow();
@ -263,7 +262,7 @@ public final class HSLFFill {
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
if(bstore == null) {
logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
return null;
}
List<EscherRecord> lst = bstore.getChildRecords();
@ -362,7 +361,7 @@ public final class HSLFFill {
java.util.List<EscherRecord> lst = bstore.getChildRecords();
int idx = p.getPropertyValue();
if (idx == 0){
logger.log(POILogger.WARN, "no reference to picture data found ");
LOG.log(POILogger.WARN, "no reference to picture data found ");
} else {
EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1);
for (HSLFPictureData pd : pict) {

View File

@ -65,10 +65,13 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
enum PathInfo {
lineTo(0),curveTo(1),moveTo(2),close(3),end(4),escape(5),clientEscape(6);
int flag;
private final int flag;
PathInfo(int flag) {
this.flag = flag;
}
public int getFlag() {
return flag;
}
static PathInfo valueOf(int flag) {
for (PathInfo v : values()) {
if (v.flag == flag) {
@ -104,10 +107,13 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
FILL_COLOR(0X0015),
LINE_COLOR(0X0016);
int flag;
private final int flag;
EscapeInfo(int flag) {
this.flag = flag;
}
public int getFlag() {
return flag;
}
static EscapeInfo valueOf(int flag) {
for (EscapeInfo v : values()) {
if (v.flag == flag) {
@ -125,10 +131,13 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
CURVES_CLOSED(3),
COMPLEX(4);
int flag;
private final int flag;
ShapePath(int flag) {
this.flag = flag;
}
public int getFlag() {
return flag;
}
static ShapePath valueOf(int flag) {
for (ShapePath v : values()) {
if (v.flag == flag) {

View File

@ -30,8 +30,6 @@ import org.apache.poi.util.*;
/**
* A class that represents image data contained in a slide show.
*
* @author Yegor Kozlov
*/
public abstract class HSLFPictureData implements PictureData {
@ -47,17 +45,17 @@ public abstract class HSLFPictureData implements PictureData {
/**
* The offset to the picture in the stream
*/
protected int offset;
private int offset;
/**
* The instance type/signatures defines if one or two UID instances will be included
*/
protected int uidInstanceCount = 1;
private int uidInstanceCount = 1;
/**
* The 1-based index within the pictures stream
*/
protected int index = -1;
private int index = -1;
/**
* Blip signature.
@ -73,6 +71,15 @@ public abstract class HSLFPictureData implements PictureData {
return uidInstanceCount;
}
/**
* The instance type/signatures defines if one or two UID instances will be included
*
* @param uidInstanceCount the number of uid sequences
*/
protected void setUIDInstanceCount(int uidInstanceCount) {
this.uidInstanceCount = uidInstanceCount;
}
/**
* Returns the raw binary data of this Picture excluding the first 8 bytes
* which hold image signature and size of the image data.