Sonar fixes, direct array parameter

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1717359 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2015-12-01 00:23:21 +00:00
parent f0ed3cbbab
commit cc77b04a94
12 changed files with 33 additions and 26 deletions

View File

@ -91,7 +91,7 @@ public class DataSpaceMapUtils {
DataSpaceMapEntry entries[]; DataSpaceMapEntry entries[];
public DataSpaceMap(DataSpaceMapEntry entries[]) { public DataSpaceMap(DataSpaceMapEntry entries[]) {
this.entries = entries; this.entries = entries.clone();
} }
public DataSpaceMap(LittleEndianInput is) { public DataSpaceMap(LittleEndianInput is) {
@ -113,13 +113,13 @@ public class DataSpaceMapUtils {
} }
public static class DataSpaceMapEntry implements EncryptionRecord { public static class DataSpaceMapEntry implements EncryptionRecord {
int referenceComponentType[]; final int referenceComponentType[];
String referenceComponent[]; final String referenceComponent[];
String dataSpaceName; final String dataSpaceName;
public DataSpaceMapEntry(int referenceComponentType[], String referenceComponent[], String dataSpaceName) { public DataSpaceMapEntry(int referenceComponentType[], String referenceComponent[], String dataSpaceName) {
this.referenceComponentType = referenceComponentType; this.referenceComponentType = referenceComponentType.clone();
this.referenceComponent = referenceComponent; this.referenceComponent = referenceComponent.clone();
this.dataSpaceName = dataSpaceName; this.dataSpaceName = dataSpaceName;
} }
@ -152,7 +152,7 @@ public class DataSpaceMapUtils {
String transformer[]; String transformer[];
public DataSpaceDefinition(String transformer[]) { public DataSpaceDefinition(String transformer[]) {
this.transformer = transformer; this.transformer = transformer.clone();
} }
public DataSpaceDefinition(LittleEndianInput is) { public DataSpaceDefinition(LittleEndianInput is) {

View File

@ -114,15 +114,15 @@ public abstract class Decryptor {
} }
protected void setVerifier(byte[] verifier) { protected void setVerifier(byte[] verifier) {
this.verifier = verifier; this.verifier = (verifier == null) ? null : verifier.clone();
} }
protected void setIntegrityHmacKey(byte[] integrityHmacKey) { protected void setIntegrityHmacKey(byte[] integrityHmacKey) {
this.integrityHmacKey = integrityHmacKey; this.integrityHmacKey = (integrityHmacKey == null) ? null : integrityHmacKey.clone();
} }
protected void setIntegrityHmacValue(byte[] integrityHmacValue) { protected void setIntegrityHmacValue(byte[] integrityHmacValue) {
this.integrityHmacValue = integrityHmacValue; this.integrityHmacValue = (integrityHmacValue == null) ? null : integrityHmacValue.clone();
} }
protected int getBlockSizeInBytes() { protected int getBlockSizeInBytes() {

View File

@ -135,7 +135,7 @@ public abstract class EncryptionHeader {
} }
protected void setKeySalt(byte salt[]) { protected void setKeySalt(byte salt[]) {
this.keySalt = salt; this.keySalt = (salt == null) ? null : salt.clone();
} }
/** /**

View File

@ -100,19 +100,19 @@ public abstract class EncryptionVerifier {
} }
protected void setSalt(byte[] salt) { protected void setSalt(byte[] salt) {
this.salt = salt; this.salt = (salt == null) ? null : salt.clone();
} }
protected void setEncryptedVerifier(byte[] encryptedVerifier) { protected void setEncryptedVerifier(byte[] encryptedVerifier) {
this.encryptedVerifier = encryptedVerifier; this.encryptedVerifier = (encryptedVerifier == null) ? null : encryptedVerifier.clone();
} }
protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) {
this.encryptedVerifierHash = encryptedVerifierHash; this.encryptedVerifierHash = (encryptedVerifierHash == null) ? null : encryptedVerifierHash.clone();
} }
protected void setEncryptedKey(byte[] encryptedKey) { protected void setEncryptedKey(byte[] encryptedKey) {
this.encryptedKey = encryptedKey; this.encryptedKey = (encryptedKey == null) ? null : encryptedKey.clone();
} }
protected void setSpinCount(int spinCount) { protected void setSpinCount(int spinCount) {

View File

@ -111,7 +111,7 @@ public class AgileEncryptionHeader extends EncryptionHeader {
} }
protected void setEncryptedHmacKey(byte[] encryptedHmacKey) { protected void setEncryptedHmacKey(byte[] encryptedHmacKey) {
this.encryptedHmacKey = encryptedHmacKey; this.encryptedHmacKey = (encryptedHmacKey == null) ? null : encryptedHmacKey.clone();
} }
public byte[] getEncryptedHmacValue() { public byte[] getEncryptedHmacValue() {
@ -119,6 +119,6 @@ public class AgileEncryptionHeader extends EncryptionHeader {
} }
protected void setEncryptedHmacValue(byte[] encryptedHmacValue) { protected void setEncryptedHmacValue(byte[] encryptedHmacValue) {
this.encryptedHmacValue = encryptedHmacValue; this.encryptedHmacValue = (encryptedHmacValue == null) ? null : encryptedHmacValue.clone();
} }
} }

View File

@ -43,7 +43,7 @@ public class DigestInfo implements Serializable {
* @param description * @param description
*/ */
public DigestInfo(byte[] digestValue, HashAlgorithm hashAlgo, String description) { public DigestInfo(byte[] digestValue, HashAlgorithm hashAlgo, String description) {
this.digestValue = digestValue; this.digestValue = digestValue.clone();
this.hashAlgo = hashAlgo; this.hashAlgo = hashAlgo;
this.description = description; this.description = description;
} }

View File

@ -46,7 +46,7 @@ public class TextPFException9 {
private final Short autoNumberStartNumber; private final Short autoNumberStartNumber;
private final static Short DEFAULT_START_NUMBER = 1; private final static Short DEFAULT_START_NUMBER = 1;
private final int recordLength; private final int recordLength;
public TextPFException9(final byte[] source, final int startIndex) { public TextPFException9(final byte[] source, final int startIndex) { // NOSONAR
//this.mask1 = source[startIndex]; //this.mask1 = source[startIndex];
//this.mask2 = source[startIndex + 1]; //this.mask2 = source[startIndex + 1];
this.mask3 = source[startIndex + 2]; this.mask3 = source[startIndex + 2];

View File

@ -247,7 +247,7 @@ public abstract class RecordContainer extends Record
* @param records the new child records * @param records the new child records
*/ */
public void setChildRecord(Record[] records) { public void setChildRecord(Record[] records) {
this._children = records; this._children = records.clone();
} }
/* =============================================================== /* ===============================================================

View File

@ -153,12 +153,16 @@ public final class SlideListWithText extends RecordContainer {
/** /**
* Get access to the SlideAtomsSets of the children of this record * Get access to the SlideAtomsSets of the children of this record
*/ */
public SlideAtomsSet[] getSlideAtomsSets() { return slideAtomsSets; } public SlideAtomsSet[] getSlideAtomsSets() {
return slideAtomsSets;
}
/** /**
* Get access to the SlideAtomsSets of the children of this record * Get access to the SlideAtomsSets of the children of this record
*/ */
public void setSlideAtomsSets( SlideAtomsSet[] sas ) { slideAtomsSets = sas; } public void setSlideAtomsSets( SlideAtomsSet[] sas ) {
slideAtomsSets = sas.clone();
}
/** /**
* Return the value we were given at creation * Return the value we were given at creation

View File

@ -17,10 +17,13 @@
package org.apache.poi.hslf.record; package org.apache.poi.hslf.record;
import java.io.*; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianByteArrayInputStream; import org.apache.poi.util.LittleEndianByteArrayInputStream;
@ -136,7 +139,7 @@ public final class TextSpecInfoAtom extends RecordAtom {
try { try {
run.writeOut(bos); run.writeOut(bos);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new HSLFException(e);
} }
} }
_data = bos.toByteArray(); _data = bos.toByteArray();

View File

@ -305,7 +305,7 @@ public class TextSpecInfoRun {
* @param smartTagsBytes the unparsed smart tags, null to unset * @param smartTagsBytes the unparsed smart tags, null to unset
*/ */
public void setSmartTagsBytes(byte[] smartTagsBytes) { public void setSmartTagsBytes(byte[] smartTagsBytes) {
this.smartTagsBytes = smartTagsBytes; this.smartTagsBytes = (smartTagsBytes == null) ? null : smartTagsBytes.clone();
mask = smartTagFld.setBoolean(mask, smartTagsBytes != null); mask = smartTagFld.setBoolean(mask, smartTagsBytes != null);
} }

View File

@ -84,7 +84,7 @@ public abstract class HSLFPictureData implements PictureData {
} }
public void setRawData(byte[] data){ public void setRawData(byte[] data){
rawdata = data; rawdata = (data == null) ? null : data.clone();
} }
/** /**