mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Remove clone
This commit is contained in:
@@ -27,7 +27,7 @@ public class PwDateTest extends TestCase {
|
|||||||
public void testDate() {
|
public void testDate() {
|
||||||
PwDate jDate = new PwDate(System.currentTimeMillis());
|
PwDate jDate = new PwDate(System.currentTimeMillis());
|
||||||
|
|
||||||
PwDate intermediate = jDate.clone();
|
PwDate intermediate = new PwDate(jDate);
|
||||||
|
|
||||||
PwDate cDate = new PwDate(intermediate.getCDate(), 0);
|
PwDate cDate = new PwDate(intermediate.getCDate(), 0);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class AutoType implements Cloneable, Parcelable {
|
public class AutoType implements Parcelable {
|
||||||
private static final long OBF_OPT_NONE = 0;
|
private static final long OBF_OPT_NONE = 0;
|
||||||
|
|
||||||
public boolean enabled = true;
|
public boolean enabled = true;
|
||||||
@@ -79,18 +79,6 @@ public class AutoType implements Cloneable, Parcelable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public AutoType clone() {
|
|
||||||
AutoType auto;
|
|
||||||
try {
|
|
||||||
auto = (AutoType) super.clone();
|
|
||||||
} catch (CloneNotSupportedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
auto.windowSeqPairs = (HashMap<String, String>) windowSeqPairs.clone();
|
|
||||||
return auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void put(String key, String value) {
|
public void put(String key, String value) {
|
||||||
windowSeqPairs.put(key, value);
|
windowSeqPairs.put(key, value);
|
||||||
}
|
}
|
||||||
@@ -98,5 +86,4 @@ public class AutoType implements Cloneable, Parcelable {
|
|||||||
public Set<Map.Entry<String, String>> entrySet() {
|
public Set<Map.Entry<String, String>> entrySet() {
|
||||||
return windowSeqPairs.entrySet();
|
return windowSeqPairs.entrySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ import java.util.Date;
|
|||||||
* @author bpellin
|
* @author bpellin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PwDate implements Cloneable, Parcelable {
|
public class PwDate implements Parcelable {
|
||||||
|
|
||||||
private static final int DATE_SIZE = 5;
|
private static final int DATE_SIZE = 5;
|
||||||
|
|
||||||
private Date jDate;
|
private Date jDate = null;
|
||||||
private boolean jDateBuilt = false;
|
private boolean jDateBuilt = false;
|
||||||
transient private byte[] cDate;
|
transient private byte[] cDate = null;
|
||||||
transient private boolean cDateBuilt = false;
|
transient private boolean cDateBuilt = false;
|
||||||
|
|
||||||
public static final Date NEVER_EXPIRE = getNeverExpire();
|
public static final Date NEVER_EXPIRE = getNeverExpire();
|
||||||
@@ -80,9 +80,18 @@ public class PwDate implements Cloneable, Parcelable {
|
|||||||
cDateBuilt = true;
|
cDateBuilt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwDate(PwDate date) {
|
public PwDate(PwDate source) {
|
||||||
jDate = new Date(date.jDate.getTime());
|
if (source.jDate != null) {
|
||||||
jDateBuilt = date.jDateBuilt;
|
this.jDate = new Date(source.jDate.getTime());
|
||||||
|
}
|
||||||
|
this.jDateBuilt = source.jDateBuilt;
|
||||||
|
|
||||||
|
if (source.cDate != null) {
|
||||||
|
int dateLength = source.cDate.length;
|
||||||
|
this.cDate = new byte[dateLength];
|
||||||
|
System.arraycopy(source.cDate, 0, this.cDate, 0, dateLength);
|
||||||
|
}
|
||||||
|
this.cDateBuilt = source.cDateBuilt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PwDate(Date date) {
|
public PwDate(Date date) {
|
||||||
@@ -128,25 +137,6 @@ public class PwDate implements Cloneable, Parcelable {
|
|||||||
return new PwDate[size];
|
return new PwDate[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
|
||||||
public PwDate clone() {
|
|
||||||
PwDate copy = new PwDate();
|
|
||||||
|
|
||||||
if ( cDateBuilt ) {
|
|
||||||
byte[] newC = new byte[DATE_SIZE];
|
|
||||||
System.arraycopy(cDate, 0, newC, 0, DATE_SIZE);
|
|
||||||
copy.cDate = newC;
|
|
||||||
copy.cDateBuilt = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( jDateBuilt ) {
|
|
||||||
copy.jDate = (Date) jDate.clone();
|
|
||||||
copy.jDateBuilt = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
public Date getDate() {
|
||||||
if ( ! jDateBuilt ) {
|
if ( ! jDateBuilt ) {
|
||||||
@@ -273,5 +263,4 @@ public class PwDate implements Cloneable, Parcelable {
|
|||||||
(cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND));
|
(cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,34 +163,6 @@ public class PwEntryV3 extends PwEntry<PwGroupV3, PwEntryV3> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PwEntryV3 clone() {
|
|
||||||
// Attributes in parent
|
|
||||||
PwEntryV3 newEntry = (PwEntryV3) super.clone();
|
|
||||||
|
|
||||||
// Attributes here
|
|
||||||
// newEntry.parent stay the same in copy
|
|
||||||
// newEntry.groupId stay the same in copy
|
|
||||||
// newEntry.title stay the same in copy
|
|
||||||
// newEntry.username stay the same in copy
|
|
||||||
if (password != null) {
|
|
||||||
int passLen = password.length;
|
|
||||||
password = new byte[passLen];
|
|
||||||
System.arraycopy(password, 0, newEntry.password, 0, passLen);
|
|
||||||
}
|
|
||||||
// newEntry.url stay the same in copy
|
|
||||||
// newEntry.additional stay the same in copy
|
|
||||||
|
|
||||||
// newEntry.binaryDesc stay the same in copy
|
|
||||||
if ( binaryData != null ) {
|
|
||||||
int descLen = binaryData.length;
|
|
||||||
newEntry.binaryData = new byte[descLen];
|
|
||||||
System.arraycopy(binaryData, 0, newEntry.binaryData, 0, descLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return Type.ENTRY;
|
return Type.ENTRY;
|
||||||
|
|||||||
@@ -161,33 +161,6 @@ public class PwEntryV4 extends PwEntry<PwGroupV4, PwEntryV4> implements ITimeLog
|
|||||||
tags = source.tags;
|
tags = source.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public PwEntryV4 clone() {
|
|
||||||
// Attributes in parent
|
|
||||||
PwEntryV4 newEntry = (PwEntryV4) super.clone();
|
|
||||||
|
|
||||||
// Attributes here
|
|
||||||
newEntry.customIcon = new PwIconCustom(this.customIcon);
|
|
||||||
// newEntry.usageCount stay the same in copy
|
|
||||||
newEntry.parentGroupLastMod = this.parentGroupLastMod.clone();
|
|
||||||
|
|
||||||
newEntry.fields = new ExtraFields(this.fields);
|
|
||||||
// TODO customData make copy from hashmap
|
|
||||||
newEntry.binaries = (HashMap<String, ProtectedBinary>) this.binaries.clone();
|
|
||||||
// newEntry.foregroundColor stay the same in copy
|
|
||||||
// newEntry.backgroupColor stay the same in copy
|
|
||||||
// newEntry.overrideURL stay the same in copy
|
|
||||||
newEntry.autoType = autoType.clone();
|
|
||||||
newEntry.history = (ArrayList<PwEntryV4>) this.history.clone();
|
|
||||||
|
|
||||||
// newEntry.url stay the same in copy
|
|
||||||
// newEntry.additional stay the same in copy
|
|
||||||
// newEntry.tags stay the same in copy
|
|
||||||
|
|
||||||
return newEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
|
|||||||
@@ -78,16 +78,6 @@ public class PwGroupV3 extends PwGroup<Integer, PwGroupV3, PwEntryV3> {
|
|||||||
flags = source.flags;
|
flags = source.flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public PwGroupV3 clone() {
|
|
||||||
// name is clone automatically (IMMUTABLE)
|
|
||||||
// newGroup.groupId stay the same in copy
|
|
||||||
// newGroup.level stay the same in copy
|
|
||||||
// newGroup.flags stay the same in copy
|
|
||||||
return (PwGroupV3) super.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return Type.GROUP;
|
return Type.GROUP;
|
||||||
|
|||||||
@@ -126,30 +126,6 @@ public class PwGroupV4 extends PwGroup<UUID, PwGroupV4, PwEntryV4> implements IT
|
|||||||
lastTopVisibleEntry = source.lastTopVisibleEntry;
|
lastTopVisibleEntry = source.lastTopVisibleEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PwGroupV4 clone() {
|
|
||||||
// Attributes in parent
|
|
||||||
PwGroupV4 newGroup = (PwGroupV4) super.clone();
|
|
||||||
|
|
||||||
// Attributes here
|
|
||||||
// name is clone automatically (IMMUTABLE)
|
|
||||||
newGroup.customIcon = new PwIconCustom(this.customIcon);
|
|
||||||
// newGroup.usageCount stay the same in copy
|
|
||||||
newGroup.locationChangeDate = this.locationChangeDate.clone();
|
|
||||||
// TODO customData make copy from hashmap newGroup.customData = (HashMap<String, String>) this.customData.clone();
|
|
||||||
|
|
||||||
// newGroup.expires stay the same in copy
|
|
||||||
|
|
||||||
// newGroup.notes stay the same in copy
|
|
||||||
// newGroup.isExpanded stay the same in copy
|
|
||||||
// newGroup.defaultAutoTypeSequence stay the same in copy
|
|
||||||
// newGroup.enableAutoType stay the same in copy
|
|
||||||
// newGroup.enableSearching stay the same in copy
|
|
||||||
// newGroup.lastTopVisibleEntry stay the same in copy
|
|
||||||
|
|
||||||
return newGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package com.kunzisoft.keepass.database.element;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public abstract class PwIcon implements Parcelable, Cloneable {
|
public abstract class PwIcon implements Parcelable {
|
||||||
|
|
||||||
public static final int UNKNOWN = -1;
|
public static final int UNKNOWN = -1;
|
||||||
|
|
||||||
@@ -38,9 +38,6 @@ public abstract class PwIcon implements Parcelable, Cloneable {
|
|||||||
|
|
||||||
public abstract int getIconId();
|
public abstract int getIconId();
|
||||||
|
|
||||||
@Override
|
|
||||||
protected abstract PwIcon clone() throws CloneNotSupportedException;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -88,11 +88,6 @@ public class PwIconCustom extends PwIcon {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PwIconCustom clone() throws CloneNotSupportedException {
|
|
||||||
return new PwIconCustom(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
|
|||||||
@@ -76,11 +76,6 @@ public class PwIconStandard extends PwIcon {
|
|||||||
return iconId == 0;
|
return iconId == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PwIconStandard clone() throws CloneNotSupportedException {
|
|
||||||
return new PwIconStandard(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
|
|||||||
@@ -87,24 +87,6 @@ public abstract class PwNode
|
|||||||
this.expireDate = new PwDate(source.expireDate);
|
this.expireDate = new PwDate(source.expireDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PwNode clone() {
|
|
||||||
PwNode newNode;
|
|
||||||
try {
|
|
||||||
newNode = (PwNode) super.clone();
|
|
||||||
newNode.nodeId = nodeId.clone();
|
|
||||||
// newNode.parent stay the same in copy
|
|
||||||
newNode.icon = icon.clone();
|
|
||||||
newNode.creation = creation.clone();
|
|
||||||
newNode.lastMod = lastMod.clone();
|
|
||||||
newNode.lastAccess = lastAccess.clone();
|
|
||||||
newNode.expireDate = expireDate.clone();
|
|
||||||
} catch (CloneNotSupportedException e) {
|
|
||||||
throw new RuntimeException("Clone should be supported");
|
|
||||||
}
|
|
||||||
return newNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdType getId() {
|
public IdType getId() {
|
||||||
return getNodeId().getId();
|
return getNodeId().getId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package com.kunzisoft.keepass.database.element;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public abstract class PwNodeId<Id> implements Cloneable, Parcelable {
|
public abstract class PwNodeId<Id> implements Parcelable {
|
||||||
|
|
||||||
public PwNodeId() {}
|
public PwNodeId() {}
|
||||||
|
|
||||||
@@ -37,9 +37,4 @@ public abstract class PwNodeId<Id> implements Cloneable, Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract Id getId();
|
public abstract Id getId();
|
||||||
|
|
||||||
@Override
|
|
||||||
public PwNodeId clone() throws CloneNotSupportedException {
|
|
||||||
return (PwNodeId) super.clone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ public class PwNodeIdInt extends PwNodeId<Integer> {
|
|||||||
this(new Random().nextInt());
|
this(new Random().nextInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PwNodeIdInt(PwNodeIdInt source) {
|
||||||
|
this(source.id);
|
||||||
|
}
|
||||||
|
|
||||||
public PwNodeIdInt(int groupId) {
|
public PwNodeIdInt(int groupId) {
|
||||||
super();
|
super();
|
||||||
this.id = groupId;
|
this.id = groupId;
|
||||||
@@ -59,11 +63,6 @@ public class PwNodeIdInt extends PwNodeId<Integer> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
|
||||||
public PwNodeIdInt clone() throws CloneNotSupportedException {
|
|
||||||
return (PwNodeIdInt) super.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object compare) {
|
public boolean equals(Object compare) {
|
||||||
if ( ! (compare instanceof PwNodeIdInt) ) {
|
if ( ! (compare instanceof PwNodeIdInt) ) {
|
||||||
|
|||||||
@@ -30,7 +30,11 @@ public class PwNodeIdUUID extends PwNodeId<UUID> {
|
|||||||
public PwNodeIdUUID() {
|
public PwNodeIdUUID() {
|
||||||
this(UUID.randomUUID());
|
this(UUID.randomUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PwNodeIdUUID(PwNodeIdUUID source) {
|
||||||
|
this(source.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
public PwNodeIdUUID(UUID uuid) {
|
public PwNodeIdUUID(UUID uuid) {
|
||||||
super();
|
super();
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
@@ -59,11 +63,6 @@ public class PwNodeIdUUID extends PwNodeId<UUID> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
|
||||||
public PwNodeIdUUID clone() throws CloneNotSupportedException {
|
|
||||||
return (PwNodeIdUUID) super.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object id) {
|
public boolean equals(Object id) {
|
||||||
if ( ! (id instanceof PwNodeIdUUID) ) {
|
if ( ! (id instanceof PwNodeIdUUID) ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user