cleanup in eis/nosql world
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISCollectionChangeRecord.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISCollectionChangeRecord.java
index e6f59e9..1e0cedb 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISCollectionChangeRecord.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISCollectionChangeRecord.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -29,13 +29,13 @@
public class EISCollectionChangeRecord extends CollectionChangeRecord implements org.eclipse.persistence.sessions.changesets.EISCollectionChangeRecord {
/** The added stuff. */
- private List adds;
+ private List adds; //either ObjectChangeSet or String (simple type)
/** The removed stuff. */
- private List removes;
+ private List removes; //either ObjectChangeSet or String (simple type)
/** The stuff whose Map keys have changed. */
- private List changedMapKeys;
+ private List changedMapKeys; //either ObjectChangeSet or String (simple type)
/**
* Construct a ChangeRecord that can be used to represent the changes to
@@ -78,7 +78,7 @@
@Override
public List getAdds() {
if (adds == null) {
- adds = new ArrayList(2);// keep it as small as possible
+ adds = new ArrayList<>(2);// keep it as small as possible
}
return adds;
}
@@ -92,7 +92,7 @@
@Override
public List getChangedMapKeys() {
if (changedMapKeys == null) {
- changedMapKeys = new ArrayList(2);// keep it as small as possible
+ changedMapKeys = new ArrayList<>(2);// keep it as small as possible
}
return changedMapKeys;
}
@@ -106,7 +106,7 @@
@Override
public List getRemoves() {
if (removes == null) {
- removes = new ArrayList(2);// keep it as small as possible
+ removes = new ArrayList<>(2);// keep it as small as possible
}
return removes;
}
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISDOMRecord.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISDOMRecord.java
index 293dcbd..6bdbe91 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISDOMRecord.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISDOMRecord.java
@@ -120,7 +120,7 @@
try {
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try{
- setDOM((Element)AccessController.doPrivileged(new PrivilegedMethodInvoker(domMethod, record, null)));
+ setDOM(AccessController.doPrivileged(new PrivilegedMethodInvoker<>(domMethod, record, null)));
}catch (PrivilegedActionException ex){
throw (Exception)ex.getCause();
}
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISDescriptor.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISDescriptor.java
index be5ef3b..c8ae8a4 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISDescriptor.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISDescriptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -264,7 +264,7 @@
if (!(fieldValue instanceof List)) {
return getObjectBuilder().createRecord(0, null);
}
- List nestedRows = (List)fieldValue;
+ List<?> nestedRows = (List<?>)fieldValue;
if (nestedRows.isEmpty()) {
return getObjectBuilder().createRecord(0, null);
} else {
@@ -284,14 +284,14 @@
public Vector buildNestedRowsFromFieldValue(Object fieldValue, AbstractSession session) {
if (!isXMLFormat()) {
if (!(fieldValue instanceof List)) {
- return new Vector();
+ return new Vector<>();
}
- return new Vector((List)fieldValue);
+ return new Vector<>((List<?>)fieldValue);
}
// BUG#2667762 if the tag was empty this could be a string of whitespace.
if (!(fieldValue instanceof Vector)) {
- return new Vector(0);
+ return new Vector<>(0);
}
return (Vector)fieldValue;
}
@@ -305,7 +305,7 @@
@Override
public Vector buildDirectValuesFromFieldValue(Object fieldValue) {
if (!(fieldValue instanceof Vector)) {
- Vector fieldValues = new Vector(1);
+ Vector<Object> fieldValues = new Vector<>(1);
fieldValues.add(fieldValue);
return fieldValues;
}
@@ -329,7 +329,7 @@
*/
@Override
public Object buildFieldValueFromNestedRow(AbstractRecord nestedRow, AbstractSession session) throws DatabaseException {
- Vector nestedRows = new Vector(1);
+ Vector<AbstractRecord> nestedRows = new Vector<>(1);
nestedRows.add(nestedRow);
return this.buildFieldValueFromNestedRows(nestedRows, "", session);
}
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISException.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISException.java
index 8786ce0..388e86f 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISException.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -178,7 +178,7 @@
return EISException.createResourceException(args, COULD_NOT_DELETE_FILE);
}
- public static EISException incorrectLoginInstanceProvided(Class loginClass) {
+ public static EISException incorrectLoginInstanceProvided(Class<?> loginClass) {
Object[] args = { loginClass };
EISException exception = new EISException(ExceptionMessageGenerator.buildMessage(EISException.class, INCORRECT_LOGIN_INSTANCE_PROVIDED, args));
exception.setErrorCode(INCORRECT_LOGIN_INSTANCE_PROVIDED);
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISMappedRecord.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISMappedRecord.java
index 4634fc1..462c224 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISMappedRecord.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISMappedRecord.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -45,8 +45,8 @@
* getFields() is sued internally in a few places, so try to make that work for mapped records.
*/
@Override
- public Vector getFields() {
- return new Vector(getRecord().keySet());
+ public Vector<DatabaseField> getFields() {
+ return new Vector<>(getRecord().keySet());
}
/**
@@ -122,12 +122,12 @@
public Object get(DatabaseField field) {
Object value = get(field.getName());
if (value instanceof Map) {
- Vector nestedRows = new Vector(1);
+ Vector<EISMappedRecord> nestedRows = new Vector<>(1);
nestedRows.add(new EISMappedRecord((Map)value, getAccessor()));
value = nestedRows;
} else if (value instanceof List) {
- List values = (List)value;
- Vector nestedValues = new Vector(values.size());
+ List<?> values = (List<?>)value;
+ Vector<Object> nestedValues = new Vector<>(values.size());
for (int index = 0; index < values.size(); index++) {
Object nestedValue = values.get(index);
if (nestedValue instanceof Map) {
@@ -194,7 +194,7 @@
writer.write(Helper.getShortClassName(getClass()));
writer.write("(");
- for (Iterator keysIterator = keySet().iterator(); keysIterator.hasNext();) {
+ for (Iterator<?> keysIterator = keySet().iterator(); keysIterator.hasNext();) {
Object key = keysIterator.next();
writer.write(Helper.cr());
writer.write("\t");
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISObjectPersistenceXMLProject.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISObjectPersistenceXMLProject.java
index dc90641..7ef2aad 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISObjectPersistenceXMLProject.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISObjectPersistenceXMLProject.java
@@ -178,12 +178,12 @@
@Override
public Object getAttributeValueFromObject(Object object) {
XMLInteraction interaction = (XMLInteraction)object;
- Vector argumentNames = interaction.getArgumentNames();
- Vector arguments = interaction.getArguments();
+ Vector<String> argumentNames = interaction.getArgumentNames();
+ Vector<?> arguments = interaction.getArguments();
Vector<InteractionArgument> interactionArguments = new Vector<>(arguments.size());
for (int index = 0; index < arguments.size(); index++) {
InteractionArgument interactionArgument = new InteractionArgument();
- interactionArgument.setArgumentName((String)argumentNames.get(index));
+ interactionArgument.setArgumentName(argumentNames.get(index));
Object argument = arguments.get(index);
if (argument instanceof DatabaseField) {
interactionArgument.setKey(argument);
@@ -198,12 +198,13 @@
@Override
public void setAttributeValueInObject(Object object, Object value) {
XMLInteraction interaction = (XMLInteraction)object;
- Vector interactionArguments = (Vector)value;
- Vector arguments = new Vector(interactionArguments.size());
- Vector argumentNames = new Vector(interactionArguments.size());
- Vector values = new Vector(interactionArguments.size());
+ @SuppressWarnings({"unchecked"})
+ Vector<InteractionArgument> interactionArguments = (Vector<InteractionArgument>)value;
+ Vector<DatabaseField> arguments = new Vector<>(interactionArguments.size());
+ Vector<String> argumentNames = new Vector<>(interactionArguments.size());
+ Vector<Object> values = new Vector<>(interactionArguments.size());
for (int index = 0; index < interactionArguments.size(); index++) {
- InteractionArgument interactionArgument = (InteractionArgument)interactionArguments.get(index);
+ InteractionArgument interactionArgument = interactionArguments.get(index);
if (interactionArgument.getKey() != null) {
arguments.add(new DatabaseField((String)interactionArgument.getKey()));
}
@@ -236,13 +237,13 @@
@Override
public Object getAttributeValueFromObject(Object object) {
XMLInteraction interaction = (XMLInteraction)object;
- Vector arguments = interaction.getOutputArguments();
- Vector argumentNames = interaction.getOutputArgumentNames();
+ Vector<DatabaseField> arguments = interaction.getOutputArguments();
+ Vector<String> argumentNames = interaction.getOutputArgumentNames();
Vector<InteractionArgument> interactionArguments = new Vector<>(arguments.size());
for (int index = 0; index < arguments.size(); index++) {
InteractionArgument interactionArgument = new InteractionArgument();
- interactionArgument.setKey(((DatabaseField)arguments.get(index)).getName());
- interactionArgument.setArgumentName((String)argumentNames.get(index));
+ interactionArgument.setKey(arguments.get(index).getName());
+ interactionArgument.setArgumentName(argumentNames.get(index));
interactionArguments.add(interactionArgument);
}
return interactionArguments;
@@ -251,11 +252,12 @@
@Override
public void setAttributeValueInObject(Object object, Object value) {
XMLInteraction interaction = (XMLInteraction)object;
- Vector interactionArguments = (Vector)value;
+ @SuppressWarnings({"unchecked"})
+ Vector<InteractionArgument> interactionArguments = (Vector<InteractionArgument>)value;
Vector<DatabaseField> arguments = new Vector<>(interactionArguments.size());
Vector<String> argumentNames = new Vector<>(interactionArguments.size());
for (int index = 0; index < interactionArguments.size(); index++) {
- InteractionArgument interactionArgument = (InteractionArgument)interactionArguments.get(index);
+ InteractionArgument interactionArgument = interactionArguments.get(index);
arguments.add(new DatabaseField((String)interactionArgument.getKey()));
argumentNames.add(interactionArgument.getArgumentName());
}
@@ -389,12 +391,13 @@
@Override
public void setAttributeValueInObject(Object object, Object value) {
EISOneToOneMapping mapping = (EISOneToOneMapping)object;
- List associations = (List)value;
- mapping.setSourceToTargetKeyFields(new HashMap(associations.size() + 1));
- mapping.setTargetToSourceKeyFields(new HashMap(associations.size() + 1));
- Iterator iterator = associations.iterator();
+ @SuppressWarnings({"unchecked"})
+ List<Association> associations = (List<Association>)value;
+ mapping.setSourceToTargetKeyFields(new HashMap<>(associations.size() + 1));
+ mapping.setTargetToSourceKeyFields(new HashMap<>(associations.size() + 1));
+ Iterator<Association> iterator = associations.iterator();
while (iterator.hasNext()) {
- Association association = (Association)iterator.next();
+ Association association = iterator.next();
mapping.getSourceToTargetKeyFields().put((DatabaseField)association.getKey(), (DatabaseField)association.getValue());
mapping.getTargetToSourceKeyFields().put((DatabaseField)association.getValue(), (DatabaseField)association.getKey());
}
@@ -459,7 +462,7 @@
@Override
public void setAttributeValueInObject(Object object, Object value) {
- if ((value != null) && value instanceof ReadQuery) {
+ if (value instanceof ReadQuery) {
((ForeignReferenceMapping)object).setCustomSelectionQuery((ReadQuery)value);
}
}
@@ -555,7 +558,7 @@
@Override
public void setAttributeValueInObject(Object object, Object value) {
- if ((value != null) && value instanceof ReadQuery) {
+ if (value instanceof ReadQuery) {
((ForeignReferenceMapping)object).setCustomSelectionQuery((ReadQuery)value);
}
}
@@ -581,7 +584,7 @@
@Override
public void setAttributeValueInObject(Object object, Object value) {
- if ((value != null) && value instanceof ModifyQuery) {
+ if (value instanceof ModifyQuery) {
((EISOneToManyMapping)object).setCustomDeleteAllQuery((ModifyQuery)value);
}
}
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISOrderedCollectionChangeRecord.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISOrderedCollectionChangeRecord.java
index 1cf6146..ab05636 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISOrderedCollectionChangeRecord.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISOrderedCollectionChangeRecord.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -29,19 +29,19 @@
public class EISOrderedCollectionChangeRecord extends CollectionChangeRecord implements org.eclipse.persistence.sessions.changesets.EISOrderedCollectionChangeRecord {
/** The added stuff. */
- private List adds;
+ private List adds; // either ObjectChangeSet or String (simple type)
/** The indexes into the new collection of the elements that were added. */
private int[] addIndexes;
/** The moved stuff. */
- private List moves;
+ private List moves; // either ObjectChangeSet or String (simple type)
/** The index pairs of the elements that were moved (before and after indexes). */
private int[][] moveIndexPairs;
/** The removed stuff. */
- private List removes;
+ private List removes; // either ObjectChangeSet or String (simple type)
/** The indexes into the old collection of the elements that were removed. */
private int[] removeIndexes;
@@ -137,7 +137,7 @@
@Override
public List getAdds() {
if (adds == null) {
- adds = new ArrayList(2);// keep it as small as possible
+ adds = new ArrayList<>(2);// keep it as small as possible
}
return adds;
}
@@ -207,7 +207,7 @@
@Override
public List getMoves() {
if (moves == null) {
- moves = new ArrayList(2);// keep it as small as possible
+ moves = new ArrayList<>(2);// keep it as small as possible
}
return moves;
}
@@ -310,7 +310,7 @@
@Override
public List getRemoves() {
if (removes == null) {
- removes = new ArrayList(2);// keep it as small as possible
+ removes = new ArrayList<>(2);// keep it as small as possible
}
return removes;
}
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISPlatform.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISPlatform.java
index d17c7d2..0f88006 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISPlatform.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/EISPlatform.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -234,7 +234,7 @@
/**
* Allow the platform to handle record to row conversion.
*/
- public Vector buildRows(jakarta.resource.cci.Record record, EISInteraction interaction, EISAccessor accessor) {
+ public Vector<AbstractRecord> buildRows(jakarta.resource.cci.Record record, EISInteraction interaction, EISAccessor accessor) {
jakarta.resource.cci.Record output = record;
if (getRecordConverter() != null) {
output = getRecordConverter().converterFromAdapterRecord(output);
@@ -277,7 +277,8 @@
*/
public void setDOMInRecord(Element dom, jakarta.resource.cci.Record record, EISInteraction call, EISAccessor accessor) {
if (domMethod == null) {
- Class[] argumentTypes = new Class[1];
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ Class<?>[] argumentTypes = (Class<?>[]) new Class[1];
argumentTypes[0] = Element.class;
try {
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
@@ -302,7 +303,7 @@
arguments[0] = dom;
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try{
- AccessController.doPrivileged(new PrivilegedMethodInvoker(domMethod, record, arguments));
+ AccessController.doPrivileged(new PrivilegedMethodInvoker<>(domMethod, record, arguments));
}catch (PrivilegedActionException ex){
throw (Exception)ex.getCause();
}
@@ -334,7 +335,7 @@
@Override
public void appendParameter(Call call, Writer writer, Object parameter) {
if (parameter instanceof Vector) {
- Vector records = (Vector)parameter;
+ Vector<?> records = (Vector<?>)parameter;
// May be a collection of record.
for (int index = 0; index < records.size(); index++) {
@@ -345,7 +346,7 @@
// For some reason the transform always prints the XML header, so trim it off.
int start = xml.indexOf('>');
- xml = xml.substring(start + 1, xml.length());
+ xml = xml.substring(start + 1);
try {
writer.write(xml);
} catch (IOException exception) {
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/EISInteraction.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/EISInteraction.java
index d576aac..e715ae8 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/EISInteraction.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/EISInteraction.java
@@ -44,7 +44,7 @@
protected String inputRecordName;
/** Adapter specific properties may be added. */
- protected Map properties;
+ protected Map<String, Object> properties;
/** Holds database row of input values. */
protected AbstractRecord inputRow;
@@ -56,10 +56,10 @@
* Defines the output argument names as defined in the output record for the interaction.
* This is shared as indexed interaction may still have mapped results.
*/
- protected Vector outputArgumentNames;
+ protected Vector<String> outputArgumentNames;
/** Defines the field values the output arguments of the interaction map to. These are order dependent with the names. */
- protected Vector outputArguments;
+ protected Vector<DatabaseField> outputArguments;
/** Path to the desired output record if nested. */
protected String outputResultPath;
@@ -154,10 +154,10 @@
/**
* The argument names for the output record.
*/
- public Vector getOutputArgumentNames() {
+ public Vector<String> getOutputArgumentNames() {
// This is lazy initialized to conserv space on calls that have no parameters.
if (outputArgumentNames == null) {
- outputArgumentNames = new Vector();
+ outputArgumentNames = new Vector<>();
}
return outputArgumentNames;
}
@@ -165,10 +165,10 @@
/**
* The argument fields to the interaction that map into the output record.
*/
- public Vector getOutputArguments() {
+ public Vector<DatabaseField> getOutputArguments() {
// This is lazy initialized to conserv space on calls that have no parameters.
if (outputArguments == null) {
- outputArguments = new Vector();
+ outputArguments = new Vector<>();
}
return outputArguments;
}
@@ -176,14 +176,14 @@
/**
* The output arguments.
*/
- public void setOutputArguments(Vector outputArguments) {
+ public void setOutputArguments(Vector<DatabaseField> outputArguments) {
this.outputArguments = outputArguments;
}
/**
* Set the output argument names.
*/
- public void setOutputArgumentNames(Vector outputArgumentNames) {
+ public void setOutputArgumentNames(Vector<String> outputArgumentNames) {
this.outputArgumentNames = outputArgumentNames;
}
@@ -223,8 +223,9 @@
// Handle nested collections.
if (element instanceof List) {
// Convert each element in the list.
- List values = (List)element;
- List elements = new Vector(values.size());
+ @SuppressWarnings({"unchecked"})
+ List<Object> values = (List<Object>)element;
+ List<Object> elements = new Vector<>(values.size());
for (int index = 0; index < values.size(); index++) {
elements.add(createRecordElement(elementName, values.get(index), accessor));
}
@@ -292,7 +293,7 @@
writer.write(Helper.cr());
writer.write("\tinput => [");
if (!getParameters().isEmpty()) {
- for (Iterator iterator = getParameters().iterator(); iterator.hasNext();) {
+ for (Iterator<?> iterator = getParameters().iterator(); iterator.hasNext();) {
Object parameter = iterator.next();
writer.write(String.valueOf(parameter));
if (iterator.hasNext()) {
@@ -320,12 +321,12 @@
setInputRow(modifyRow);
}
if (hasArguments()) {
- List parametersValues = new ArrayList(getArguments().size());
+ List<Object> parametersValues = new ArrayList<>(getArguments().size());
for (int index = 0; index < getArguments().size(); index++) {
Object argument = getArguments().elementAt(index);
// The argument is either a value or a databasefield that needs to be translated.
- if ((argument != null) && (argument instanceof DatabaseField)) {
+ if (argument instanceof DatabaseField) {
DatabaseField field = (DatabaseField)argument;
Object value = translationRow.get(field);
@@ -359,11 +360,11 @@
* This handles IndexedRecords used as sets of result records,
* and a single MappedRecord with a list of result records.
*/
- public Vector buildRows(jakarta.resource.cci.Record record, EISAccessor accessor) {
- Vector rows = null;
+ public Vector<AbstractRecord> buildRows(jakarta.resource.cci.Record record, EISAccessor accessor) {
+ Vector<AbstractRecord> rows = null;
if (record instanceof IndexedRecord) {
IndexedRecord indexedRecord = (IndexedRecord)record;
- rows = new Vector(indexedRecord.size());
+ rows = new Vector<>(indexedRecord.size());
for (int index = 0; index < indexedRecord.size(); index++) {
Object element = indexedRecord.get(index);
if (element instanceof jakarta.resource.cci.Record) {
@@ -387,24 +388,24 @@
} else if (element instanceof MappedRecord) {
mappedRecord = (MappedRecord)element;
} else if (element instanceof List) {
- List elements = (List)element;
- rows = new Vector(elements.size());
+ List<?> elements = (List<?>)element;
+ rows = new Vector<>(elements.size());
for (int index = 0; index < elements.size(); index++) {
Object elementValue = elements.get(index);
if (elementValue instanceof jakarta.resource.cci.Record) {
rows.addElement(buildRow((jakarta.resource.cci.Record)elementValue, accessor));
} else {
- rows.add(elementValue);
+ rows.add((AbstractRecord) elementValue);
}
}
return rows;
}
}
- rows = new Vector(1);
+ rows = new Vector<>(1);
AbstractRecord row = new EISMappedRecord(mappedRecord, accessor);
rows.add(row);
} else {
- rows = new Vector(1);
+ rows = new Vector<>(1);
}
return rows;
}
@@ -452,9 +453,9 @@
/**
* Returns the adapter specific properties.
*/
- public Map getProperties() {
+ public Map<String, Object> getProperties() {
if (properties == null) {
- properties = new HashMap(5);
+ properties = new HashMap<>(5);
}
return properties;
}
@@ -478,7 +479,7 @@
/**
* Set the adapter specific properties.
*/
- public void setProperties(Map properties) {
+ public void setProperties(Map<String, Object> properties) {
this.properties = properties;
}
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/IndexedInteraction.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/IndexedInteraction.java
index e18ad92..1e8192e 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/IndexedInteraction.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/IndexedInteraction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -81,7 +81,7 @@
* The output arguments in order of occurance in the record.
*/
@Override
- public Vector getOutputArguments() {
+ public Vector<DatabaseField> getOutputArguments() {
return super.getOutputArguments();
}
@@ -97,7 +97,7 @@
* The output arguments in order of occurance in the record.
*/
@Override
- public void setOutputArguments(Vector outputArguments) {
+ public void setOutputArguments(Vector<DatabaseField> outputArguments) {
super.setOutputArguments(outputArguments);
}
@@ -132,7 +132,7 @@
IndexedRecord indexedRecord = (IndexedRecord)record;
row = new DatabaseRecord(indexedRecord.size());
for (int index = 0; index < indexedRecord.size(); index++) {
- DatabaseField field = (DatabaseField)getOutputArguments().get(index);
+ DatabaseField field = getOutputArguments().get(index);
row.put(field, indexedRecord.get(index));
}
} else if (record instanceof MappedRecord) {
@@ -145,7 +145,7 @@
} else if (getOutputArgumentNames().size() > 1) {
row = new DatabaseRecord(getOutputArgumentNames().size());
for (int index = 0; index < getOutputArgumentNames().size(); index++) {
- DatabaseField field = (DatabaseField)getOutputArguments().get(index);
+ DatabaseField field = getOutputArguments().get(index);
row.put(field, mappedRecord.get(getOutputArgumentNames().get(index)));
}
return row;
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/MappedInteraction.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/MappedInteraction.java
index f86d214..19809e4 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/MappedInteraction.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/MappedInteraction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -32,7 +32,7 @@
*/
public class MappedInteraction extends EISInteraction {
protected String inputResultPath;
- protected Vector argumentNames;
+ protected Vector<String> argumentNames;
/**
* Default constructor.
@@ -104,10 +104,10 @@
/**
* The argument names for the input record.
*/
- public Vector getArgumentNames() {
+ public Vector<String> getArgumentNames() {
// This is lazy initialized to conserv space on calls that have no parameters.
if (argumentNames == null) {
- argumentNames = new Vector();
+ argumentNames = new Vector<>();
}
return argumentNames;
}
@@ -116,7 +116,7 @@
* INTERNAL:
* The argument names for the input record.
*/
- public void setArgumentNames(Vector argumentNames) {
+ public void setArgumentNames(Vector<String> argumentNames) {
this.argumentNames = argumentNames;
}
@@ -142,7 +142,7 @@
} else {
record = accessor.getRecordFactory().createMappedRecord(getInputRecordName());
for (int index = 0; index < getArgumentNames().size(); index++) {
- String parameterName = (String)getArgumentNames().get(index);
+ String parameterName = getArgumentNames().get(index);
Object parameter = getParameters().get(index);
// If no arguments were passed to the call execution find the parameter from the row.
@@ -202,7 +202,7 @@
if (hasOutputArguments()) {
row = new DatabaseRecord(getOutputArgumentNames().size());
for (int index = 0; index < getOutputArgumentNames().size(); index++) {
- DatabaseField field = (DatabaseField)getOutputArguments().get(index);
+ DatabaseField field = getOutputArguments().get(index);
row.put(field, mappedRecord.get(getOutputArgumentNames().get(index)));
}
return row;
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/QueryStringInteraction.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/QueryStringInteraction.java
index 1c6b6c9..17221ca 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/QueryStringInteraction.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/QueryStringInteraction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -106,7 +106,7 @@
writer.write(Helper.cr());
writer.write("\tparameters => [");
if (hasParameters()) {
- for (Iterator iterator = getParameters().iterator(); iterator.hasNext();) {
+ for (Iterator<?> iterator = getParameters().iterator(); iterator.hasNext();) {
Object parameter = iterator.next();
writer.write(String.valueOf(parameter));
if (iterator.hasNext()) {
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/XMLInteraction.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/XMLInteraction.java
index 52300c9..da80b9b 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/XMLInteraction.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/XMLInteraction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -16,6 +16,7 @@
import java.io.*;
import java.util.*;
+
import org.eclipse.persistence.internal.oxm.XMLObjectBuilder;
import org.eclipse.persistence.internal.sessions.AbstractRecord;
import org.eclipse.persistence.internal.sessions.AbstractSession;
@@ -157,7 +158,7 @@
} else {
XMLRecord parameterRow = createXMLRecord(getInputRootElementName());
for (int index = 0; index < getArgumentNames().size(); index++) {
- String parameterName = (String)getArgumentNames().get(index);
+ String parameterName = getArgumentNames().get(index);
Object parameter = getParameters().get(index);
// If no arguments were passed to the call execution find the paramter from the row.
@@ -189,7 +190,7 @@
} else if (hasOutputArguments()) {
row = createXMLRecord(getOutputRootElementName());
for (int index = 0; index < getOutputArgumentNames().size(); index++) {
- DatabaseField field = (DatabaseField)getOutputArguments().get(index);
+ DatabaseField field = getOutputArguments().get(index);
row.put(field, row.get(getOutputArgumentNames().get(index)));
}
}
@@ -200,20 +201,21 @@
* Build a collection of database rows from the Record returned from the interaction.
*/
@Override
- public Vector buildRows(jakarta.resource.cci.Record record, EISAccessor accessor) {
- Vector rows = null;
+ public Vector<AbstractRecord> buildRows(jakarta.resource.cci.Record record, EISAccessor accessor) {
+ Vector<AbstractRecord> rows = null;
if (record == null) {
- return new Vector(0);
+ return new Vector<>(0);
}
AbstractRecord row = accessor.getEISPlatform().createDatabaseRowFromDOMRecord(record, this, accessor);
if (getOutputResultPath().length() > 0) {
- Vector values = (Vector)row.getValues(getOutputResultPath());
+ @SuppressWarnings({"unchecked"})
+ Vector<AbstractRecord> values = (Vector<AbstractRecord>)row.getValues(getOutputResultPath());
if (values == null) {
- values = new Vector(0);
+ values = new Vector<>(0);
}
rows = values;
} else {
- rows = new Vector(1);
+ rows = new Vector<>(1);
rows.add(row);
}
return rows;
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/XQueryInteraction.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/XQueryInteraction.java
index 8c83acd..81b8427 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/XQueryInteraction.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/interactions/XQueryInteraction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -115,7 +115,7 @@
}
XMLRecord parameterRow = createXMLRecord(getInputRootElementName());
for (int index = 0; index < getArgumentNames().size(); index++) {
- String parameterName = (String)getArgumentNames().get(index);
+ String parameterName = getArgumentNames().get(index);
Object parameter = getInputRow().get(parameterName);
parameterRow.put(parameterName, parameter);
}
@@ -153,7 +153,7 @@
writer.write(Helper.cr());
writer.write("\tinput => [");
if (hasParameters()) {
- for (Iterator iterator = getParameters().iterator(); iterator.hasNext();) {
+ for (Iterator<?> iterator = getParameters().iterator(); iterator.hasNext();) {
Object parameter = iterator.next();
writer.write(String.valueOf(parameter));
if (iterator.hasNext()) {
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISCompositeDirectCollectionMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISCompositeDirectCollectionMapping.java
index 5b0520b..0f3d6a5 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISCompositeDirectCollectionMapping.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISCompositeDirectCollectionMapping.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToManyMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToManyMapping.java
index 4301620..86223a2 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToManyMapping.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToManyMapping.java
@@ -118,9 +118,9 @@
public EISOneToManyMapping() {
this.isForeignKeyRelationship = false;
- this.sourceForeignKeyFields = new ArrayList(1);
- this.targetForeignKeyFields = new ArrayList(1);
- this.sourceForeignKeysToTargetKeys = new HashMap(2);
+ this.sourceForeignKeyFields = new ArrayList<>(1);
+ this.targetForeignKeyFields = new ArrayList<>(1);
+ this.sourceForeignKeysToTargetKeys = new HashMap<>(2);
this.deleteAllQuery = new DeleteAllQuery();
}
@@ -286,7 +286,7 @@
*/
public void setSourceForeignKeysToTargetKeys(Map<DatabaseField, DatabaseField> sourceToTargetKeyFields) {
this.sourceForeignKeysToTargetKeys = sourceToTargetKeyFields;
- if ((sourceToTargetKeyFields != null) && (sourceToTargetKeyFields.keySet() != null) && (sourceToTargetKeyFields.keySet().size() > 0)) {
+ if ((sourceToTargetKeyFields != null) && (sourceToTargetKeyFields.keySet().size() > 0)) {
this.setIsForeignKeyRelationship(true);
}
}
@@ -761,9 +761,10 @@
* Clone the appropriate attributes.
*/
@Override
+ @SuppressWarnings({"unchecked"})
public Object clone() {
EISOneToManyMapping clone = (EISOneToManyMapping)super.clone();
- clone.setSourceForeignKeysToTargetKeys((Map)((HashMap)getSourceForeignKeysToTargetKeys()).clone());
+ clone.setSourceForeignKeysToTargetKeys((Map<DatabaseField, DatabaseField>)((HashMap<DatabaseField, DatabaseField>)getSourceForeignKeysToTargetKeys()).clone());
return clone;
}
@@ -771,10 +772,10 @@
* Return all the fields mapped by the mapping.
*/
@Override
- protected Vector collectFields() {
+ protected Vector<DatabaseField> collectFields() {
if (isForeignKeyRelationship()) {
if (this.getForeignKeyGroupingElement() != null) {
- Vector fields = new Vector(1);
+ Vector<DatabaseField> fields = new Vector<>(1);
fields.addElement(this.getForeignKeyGroupingElement());
return fields;
} else {
@@ -983,7 +984,7 @@
return getAttributeValueFromObject(cached);
}
} else if (!this.isCacheable && !isTargetProtected && cacheKey != null) {
- return this.indirectionPolicy.buildIndirectObject(new ValueHolder(null));
+ return this.indirectionPolicy.buildIndirectObject(new ValueHolder<>(null));
}
}
if (((EISDescriptor) this.getDescriptor()).isXMLFormat()) {
@@ -1011,7 +1012,7 @@
EISOneToManyQueryBasedValueHolder valueholder = new EISOneToManyQueryBasedValueHolder(this, targetQuery, row, sourceQuery.getSession());
return getIndirectionPolicy().buildIndirectObject(valueholder);
} else {
- Vector subRows = getForeignKeyRows(row, executionSession);
+ Vector<AbstractRecord> subRows = getForeignKeyRows(row, executionSession);
if (subRows == null) {
return null;
@@ -1025,12 +1026,12 @@
subRow.setSession(executionSession);
Object object = getIndirectionPolicy().valueFromQuery(targetQuery, subRow, sourceQuery.getSession());
if (object instanceof Collection) {
- java.util.Iterator iter = ((Collection)object).iterator();
+ java.util.Iterator<?> iter = ((Collection<?>)object).iterator();
while (iter.hasNext()) {
cp.addInto(iter.next(), results, executionSession);
}
} else if (object instanceof java.util.Map) {
- java.util.Iterator iter = ((java.util.Map)object).values().iterator();
+ java.util.Iterator<?> iter = ((java.util.Map<?, ?>)object).values().iterator();
while (iter.hasNext()) {
cp.addInto(iter.next(), results, executionSession);
}
@@ -1049,18 +1050,20 @@
/**
* INTERNAL:
*/
+ @SuppressWarnings({"unchecked"})
public Vector getForeignKeyRows(AbstractRecord row, AbstractSession session) {
- Vector subRows = new Vector();
+ Vector<AbstractRecord> subRows = new Vector<>();
if (getForeignKeyGroupingElement() == null) {
if (this.getSourceForeignKeyFields().size() > 0) {
Object values = row.getValues(this.getSourceForeignKeyFields().get(0));
if (values != null) {
if (values instanceof Vector) {
- int valuesSize = ((Vector)values).size();
+ Vector<?> vals = (Vector<?>) values;
+ int valuesSize = vals.size();
for (int j = 0; j < valuesSize; j++) {
AbstractRecord newRecord = this.descriptor.getObjectBuilder().createRecord(session);
- newRecord.put(this.getSourceForeignKeyFields().get(0), ((Vector)values).get(j));
+ newRecord.put(this.getSourceForeignKeyFields().get(0), vals.get(j));
subRows.add(newRecord);
}
} else {
@@ -1071,7 +1074,7 @@
}
}
} else {
- subRows = (Vector)row.getValues(getForeignKeyGroupingElement());
+ subRows = (Vector<AbstractRecord>)row.getValues(getForeignKeyGroupingElement());
}
return subRows;
}
@@ -1113,9 +1116,9 @@
// extract the keys from the objects
Object attributeValue = this.getRealCollectionAttributeValueFromObject(object, session);
- Vector nestedRows = new Vector(cp.sizeFor(attributeValue));
if (getForeignKeyGroupingElement() != null) {
+ Vector<AbstractRecord> nestedRows = new Vector<>(cp.sizeFor(attributeValue));
for (Object iter = cp.iteratorFor(attributeValue); cp.hasNext(iter);) {
AbstractRecord nestedRow = extractKeyRowFromReferenceObject(cp.next(iter, session), session, row);
nestedRows.add(nestedRow);
@@ -1124,7 +1127,7 @@
} else {
DatabaseField singleField = getSourceForeignKeyFields().get(0);
DatabaseField pkField = getSourceForeignKeysToTargetKeys().get(singleField);
- List foreignKeys = new ArrayList(cp.sizeFor(attributeValue));
+ List<Object> foreignKeys = new ArrayList<>(cp.sizeFor(attributeValue));
for (Object iter = cp.iteratorFor(attributeValue); cp.hasNext(iter);) {
Object singleValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(cp.next(iter, session), pkField, session);
foreignKeys.add(singleValue);
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToManyMappingHelper.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToManyMappingHelper.java
index a0c6b1a..4b9dd19 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToManyMappingHelper.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToManyMappingHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToOneMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToOneMapping.java
index 48a9b73..50c062a 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToOneMapping.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/eis/mappings/EISOneToOneMapping.java
@@ -79,7 +79,7 @@
/** Maps the source foreign/primary key fields to the target primary/foreign key fields. */
- protected Map sourceToTargetKeyFields;
+ protected Map<DatabaseField, DatabaseField> sourceToTargetKeyFields;
/** Maps the target primary/foreign key fields to the source foreign/primary key fields. */
protected Map<DatabaseField, DatabaseField> targetToSourceKeyFields;
@@ -93,8 +93,8 @@
this.foreignKeyFields = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(1);
- this.sourceToTargetKeyFields = new HashMap(2);
- this.targetToSourceKeyFields = new HashMap(2);
+ this.sourceToTargetKeyFields = new HashMap<>(2);
+ this.targetToSourceKeyFields = new HashMap<>(2);
}
/**
@@ -149,9 +149,9 @@
public Object clone() {
EISOneToOneMapping clone = (EISOneToOneMapping)super.clone();
clone.setForeignKeyFields(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getForeignKeyFields().size()));
- clone.setSourceToTargetKeyFields(new HashMap(getSourceToTargetKeyFields().size()));
- clone.setTargetToSourceKeyFields(new HashMap(getTargetToSourceKeyFields().size()));
- Map setOfFields = new HashMap(getTargetToSourceKeyFields().size());
+ clone.setSourceToTargetKeyFields(new HashMap<>(getSourceToTargetKeyFields().size()));
+ clone.setTargetToSourceKeyFields(new HashMap<>(getTargetToSourceKeyFields().size()));
+ Map<DatabaseField, DatabaseField> setOfFields = new HashMap<>(getTargetToSourceKeyFields().size());
for (Enumeration<DatabaseField> enumtr = getForeignKeyFields().elements(); enumtr.hasMoreElements();) {
DatabaseField field = enumtr.nextElement();
@@ -167,7 +167,7 @@
DatabaseField sourceField = sourceKeyIterator.next();
DatabaseField targetField = getSourceToTargetKeyFields().get(sourceField);
- DatabaseField targetClone = (DatabaseField)setOfFields.get(targetField);
+ DatabaseField targetClone = setOfFields.get(targetField);
if (targetClone == null) {
targetClone = targetField.clone();
setOfFields.put(targetField, targetClone);
@@ -187,13 +187,13 @@
DatabaseField targetField = targetKeyIterator.next();
DatabaseField sourceField = getTargetToSourceKeyFields().get(targetField);
- DatabaseField targetClone = (DatabaseField)setOfFields.get(targetField);
+ DatabaseField targetClone = setOfFields.get(targetField);
if (targetClone == null) {
targetClone = targetField.clone();
setOfFields.put(targetField, targetClone);
}
- DatabaseField sourceClone = (DatabaseField)setOfFields.get(sourceField);
+ DatabaseField sourceClone = setOfFields.get(sourceField);
if (sourceClone == null) {
sourceClone = sourceField.clone();
setOfFields.put(sourceField, sourceClone);
@@ -260,8 +260,8 @@
* The foreign keys primary keys are stored as database fields in the hashtable.
*/
protected void initializeForeignKeys(AbstractSession session) {
- HashMap newSourceToTargetKeyFields = new HashMap(getSourceToTargetKeyFields().size());
- HashMap newTargetToSourceKeyFields = new HashMap(getTargetToSourceKeyFields().size());
+ Map<DatabaseField, DatabaseField> newSourceToTargetKeyFields = new HashMap<>(getSourceToTargetKeyFields().size());
+ Map<DatabaseField, DatabaseField> newTargetToSourceKeyFields = new HashMap<>(getTargetToSourceKeyFields().size());
Iterator<Map.Entry<DatabaseField, DatabaseField>> iterator = getSourceToTargetKeyFields().entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<DatabaseField, DatabaseField> entry = iterator.next();
@@ -370,7 +370,7 @@
}
return result;
} else if (!this.isCacheable && !isTargetProtected && cacheKey != null) {
- return this.indirectionPolicy.buildIndirectObject(new ValueHolder(null));
+ return this.indirectionPolicy.buildIndirectObject(new ValueHolder<>(null));
}
}
// If any field in the foreign key is null then it means there are no referenced objects
@@ -529,7 +529,7 @@
* @param sourceToTargetKeyFields
* The mapping from source keys to target keys
*/
- public void setSourceToTargetKeyFields(Map sourceToTargetKeyFields) {
+ public void setSourceToTargetKeyFields(Map<DatabaseField, DatabaseField> sourceToTargetKeyFields) {
this.sourceToTargetKeyFields = sourceToTargetKeyFields;
}
@@ -539,7 +539,7 @@
* @param targetToSourceKeyFields
* The mapping from target keys to source keys
*/
- public void setTargetToSourceKeyFields(Map targetToSourceKeyFields) {
+ public void setTargetToSourceKeyFields(Map<DatabaseField, DatabaseField> targetToSourceKeyFields) {
this.targetToSourceKeyFields = targetToSourceKeyFields;
}
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/indirection/EISOneToManyQueryBasedValueHolder.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/indirection/EISOneToManyQueryBasedValueHolder.java
index 41743bd..c882f19 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/indirection/EISOneToManyQueryBasedValueHolder.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/indirection/EISOneToManyQueryBasedValueHolder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -40,23 +40,23 @@
@Override
protected Object instantiate(AbstractSession session) throws DatabaseException {
- Vector rows = this.mapping.getForeignKeyRows(this.getRow(), session);
+ Vector<AbstractRecord> rows = this.mapping.getForeignKeyRows(this.getRow(), session);
int size = rows.size();
ContainerPolicy cp = ((ReadAllQuery)this.getQuery()).getContainerPolicy();
Object returnValue = cp.containerInstance(size);
for (int i = 0; i < size; i++) {
- AbstractRecord nextRow = (AbstractRecord)rows.get(i);
+ AbstractRecord nextRow = rows.get(i);
Object results = session.executeQuery(getQuery(), nextRow);
if (results instanceof Collection) {
- Iterator iter = ((Collection)results).iterator();
+ Iterator<?> iter = ((Collection<?>)results).iterator();
while (iter.hasNext()) {
cp.addInto(iter.next(), returnValue, session);
}
} else if (results instanceof java.util.Map) {
- Iterator iter = ((java.util.Map)results).values().iterator();
+ Iterator<?> iter = ((java.util.Map<?, ?>)results).values().iterator();
while (iter.hasNext()) {
cp.addInto(iter.next(), returnValue, session);
}
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DatabaseMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DatabaseMapping.java
index c6e525d..66b2b85 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DatabaseMapping.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DatabaseMapping.java
@@ -108,7 +108,7 @@
public enum WriteType { INSERT, UPDATE, UNDEFINED }
/** Used to reduce memory for mappings with no fields. */
- protected static final Vector NO_FIELDS = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(0);
+ protected static final Vector<DatabaseField> NO_FIELDS = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(0);
/** Used to share integer instance to reduce memory. */
protected static final Integer NO_WEIGHT = Integer.MAX_VALUE;
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/changesets/EISOrderedCollectionChangeRecord.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/changesets/EISOrderedCollectionChangeRecord.java
index 114192c..97c0cf1 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/changesets/EISOrderedCollectionChangeRecord.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/changesets/EISOrderedCollectionChangeRecord.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/factories/ProjectClassGenerator.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/factories/ProjectClassGenerator.java
index f3c6d21..e4ad603 100644
--- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/factories/ProjectClassGenerator.java
+++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/sessions/factories/ProjectClassGenerator.java
@@ -991,7 +991,7 @@
}
for (int index = interaction.getArgumentNames().size();
index < interaction.getArgumentNames().size(); index++) {
- String argumentName = (String)interaction.getArgumentNames().get(index);
+ String argumentName = interaction.getArgumentNames().get(index);
String argument = (String)interaction.getArguments().get(index);
method.addLine(variableName + ".addArgument(\"" + argumentName + "\", \"" + argument + "\");");
}
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/xmlfile/XMLFileInteraction.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/xmlfile/XMLFileInteraction.java
index cf9d60d..13bfc28 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/xmlfile/XMLFileInteraction.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/xmlfile/XMLFileInteraction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -115,7 +115,7 @@
Object result = fileRecord.getValues(buildField(spec));
EISDOMRecord output = new EISDOMRecord();
if (result instanceof List) {
- List results = (List)result;
+ List<?> results = (List<?>)result;
output.setDOM(output.createNewDocument("results"));
for (int index = 0; index < results.size(); index++) {
output.add(new DatabaseField("result"), results.get(index));
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/xmlfile/XMLFileTransaction.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/xmlfile/XMLFileTransaction.java
index b458155..ebf6faf 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/xmlfile/XMLFileTransaction.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/xmlfile/XMLFileTransaction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -37,7 +37,7 @@
*/
public class XMLFileTransaction implements LocalTransaction {
protected boolean isInTransaction;
- protected Map domFiles;
+ protected Map<String, EISDOMRecord> domFiles;
protected XMLFileConnection connection;
/**
@@ -54,7 +54,7 @@
@Override
public void begin() {
this.isInTransaction = true;
- this.domFiles = new HashMap(10);
+ this.domFiles = new HashMap<>(10);
}
/**
@@ -71,10 +71,10 @@
public void commit() throws ResourceException {
try {
// store any dom to their files
- for (Iterator doms = domFiles.entrySet().iterator(); doms.hasNext();) {
- Map.Entry entry = (Map.Entry)doms.next();
- String fileName = (String)entry.getKey();
- EISDOMRecord record = (EISDOMRecord)entry.getValue();
+ for (Iterator<Map.Entry<String, EISDOMRecord>> doms = domFiles.entrySet().iterator(); doms.hasNext();) {
+ Map.Entry<String, EISDOMRecord> entry = doms.next();
+ String fileName = entry.getKey();
+ EISDOMRecord record = entry.getValue();
try (Writer fileWriter = new FileWriter(fileName)) {
record.transformToWriter(fileWriter);
@@ -84,7 +84,7 @@
} catch (Exception exception) {
throw new ResourceException(exception.toString());
}
- this.domFiles = new HashMap(10);
+ this.domFiles = new HashMap<>(10);
this.isInTransaction = false;
}
@@ -94,7 +94,7 @@
@Override
public void rollback() {
// throw away doms
- this.domFiles = new HashMap(10);
+ this.domFiles = new HashMap<>(10);
this.isInTransaction = false;
}
@@ -104,7 +104,7 @@
*/
public EISDOMRecord retrieveDOMRecord(File file) throws Exception {
// Check for transactional copy.
- EISDOMRecord fileRecord = (EISDOMRecord)this.domFiles.get(file.getPath());
+ EISDOMRecord fileRecord = this.domFiles.get(file.getPath());
if (fileRecord == null) {
// If the file exists parse it, otherwise create a new record.
if (file.exists()) {
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CompositeFieldMetaData.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CompositeFieldMetaData.java
index 884696b..8ff4f3c 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CompositeFieldMetaData.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CompositeFieldMetaData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -30,7 +30,7 @@
public class CompositeFieldMetaData extends ElementaryFieldMetaData implements CompositeObject {
/** collection containing this fields subordinate fields */
- protected Vector myCompositeFields;
+ protected Vector<FieldMetaData> myCompositeFields;
public CompositeFieldMetaData() {
super.initialize();
@@ -47,17 +47,17 @@
initialize();
}
- public CompositeFieldMetaData(String fieldName, RecordMetaData record, Vector fields) {
+ public CompositeFieldMetaData(String fieldName, RecordMetaData record, Vector<FieldMetaData> fields) {
super.initialize(fieldName, record);
initialize(fields);
}
@Override
protected void initialize() {
- myCompositeFields = new Vector();
+ myCompositeFields = new Vector<>();
}
- protected void initialize(Vector fields) {
+ protected void initialize(Vector<FieldMetaData> fields) {
myCompositeFields = fields;
}
@@ -77,9 +77,9 @@
fieldCopy.setFieldRedefined(myFieldRedefined.deepCopy());
}
fieldCopy.setDependentFieldName(myDependentFieldName);
- Enumeration fieldsEnum = myCompositeFields.elements();
+ Enumeration<FieldMetaData> fieldsEnum = myCompositeFields.elements();
while (fieldsEnum.hasMoreElements()) {
- FieldMetaData field = (FieldMetaData)fieldsEnum.nextElement();
+ FieldMetaData field = fieldsEnum.nextElement();
fieldCopy.addField(field.deepCopy());
}
return fieldCopy;
@@ -91,10 +91,10 @@
*/
@Override
public int getSize() {
- Enumeration fieldsEnum = myCompositeFields.elements();
+ Enumeration<FieldMetaData> fieldsEnum = myCompositeFields.elements();
int size = 0;
while (fieldsEnum.hasMoreElements()) {
- FieldMetaData field = (FieldMetaData)fieldsEnum.nextElement();
+ FieldMetaData field = fieldsEnum.nextElement();
if (!field.isFieldRedefine()) {
size += field.getSize();
}
@@ -166,7 +166,7 @@
* returns a collection of subordinate fields
*/
@Override
- public Vector getFields() {
+ public Vector<FieldMetaData> getFields() {
return myCompositeFields;
}
@@ -174,7 +174,7 @@
* sets the composite field attribute to the new collection
*/
@Override
- public void setFields(Vector newCompositeFields) {
+ public void setFields(Vector<FieldMetaData> newCompositeFields) {
myCompositeFields = newCompositeFields;
}
@@ -191,9 +191,9 @@
*/
@Override
public FieldMetaData getFieldNamed(String fieldName) {
- Enumeration fieldsEnum = getFields().elements();
+ Enumeration<FieldMetaData> fieldsEnum = getFields().elements();
while (fieldsEnum.hasMoreElements()) {
- FieldMetaData field = (FieldMetaData)fieldsEnum.nextElement();
+ FieldMetaData field = fieldsEnum.nextElement();
if (field.getName().equals(fieldName)) {
return field;
}
@@ -206,7 +206,7 @@
*/
@Override
public Object extractValueFromArray(byte[] recordData) {
- ArrayList fieldValue = new ArrayList(getFields().size());
+ List<CobolRow> fieldValue = new ArrayList<>(getFields().size());
if (this.isArray()) {
int offset = this.getOffset();
for (int i = this.getArraySize(); i > 0; i--) {
@@ -231,9 +231,9 @@
* writes individual fields on given row
*/
public void writeCompositeOnRow(CobolRow row, byte[] recordData) {
- Enumeration fields = getFields().elements();
+ Enumeration<FieldMetaData> fields = getFields().elements();
while (fields.hasMoreElements()) {
- FieldMetaData currentField = (FieldMetaData)fields.nextElement();
+ FieldMetaData currentField = fields.nextElement();
currentField.writeOnRow(row, recordData);
}
}
@@ -264,25 +264,26 @@
@Override
public void writeOnArray(CobolRow row, byte[] recordData) {
Object obj = row.get(this.getName());
- List fieldValue = (List)obj;
+ @SuppressWarnings({"unchecked"})
+ List<CobolRow> fieldValue = (List<CobolRow>)obj;
if (this.isArray()) {
//check for array first adjust size if necessary
if (this.dependsOn()) {
adjustArraySize(row);
}
int offset = this.getOffset();
- Iterator elements = fieldValue.iterator();
+ Iterator<CobolRow> elements = fieldValue.iterator();
for (int i = this.getArraySize(); i > 0; i--) {
//must change offset to write to the appropriate section of the byte array
CompositeFieldMetaData fieldCopy = (CompositeFieldMetaData)this.deepCopy();
fieldCopy.setOffset(offset);
fieldCopy.resetChildOffsets();
- CobolRow compositeRow = (CobolRow)elements.next();
+ CobolRow compositeRow = elements.next();
fieldCopy.writeCompositeOnArray(compositeRow, recordData);
offset += this.getSize();
}
} else {
- CobolRow compositeRow = (CobolRow)fieldValue.get(0);
+ CobolRow compositeRow = fieldValue.get(0);
this.writeCompositeOnArray(compositeRow, recordData);
}
}
@@ -291,9 +292,9 @@
* This method is used by fields that are array values to write themselves to arrays
*/
protected void writeCompositeOnArray(CobolRow row, byte[] recordData) {
- Enumeration fields = getFields().elements();
+ Enumeration<FieldMetaData> fields = getFields().elements();
while (fields.hasMoreElements()) {
- FieldMetaData currentField = (FieldMetaData)fields.nextElement();
+ FieldMetaData currentField = fields.nextElement();
currentField.writeOnArray(row, recordData);
}
}
@@ -303,10 +304,10 @@
* is changed.
*/
protected void resetChildOffsets() {
- Enumeration childFieldsEnum = myCompositeFields.elements();
+ Enumeration<FieldMetaData> childFieldsEnum = myCompositeFields.elements();
int offset = this.getOffset();
while (childFieldsEnum.hasMoreElements()) {
- FieldMetaData field = (FieldMetaData)childFieldsEnum.nextElement();
+ FieldMetaData field = childFieldsEnum.nextElement();
field.setOffset(offset);
if (field.isComposite()) {
((CompositeFieldMetaData)field).resetChildOffsets();
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CompositeObject.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CompositeObject.java
index 76242b3..32f4095 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CompositeObject.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CompositeObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -23,17 +23,17 @@
public interface CompositeObject {
/** this method returns the name of the object */
- public String getName();
+ String getName();
/** this method returns a Vector of fields that the object contains */
- public Vector getFields();
+ Vector<FieldMetaData> getFields();
/** this method sets the fields to the new values */
- public void setFields(Vector fields);
+ void setFields(Vector<FieldMetaData> fields);
/** this method adds a field to the fields Vector */
- public void addField(FieldMetaData field);
+ void addField(FieldMetaData field);
/** this method returns a field, if such a field exists, by the given name */
- public FieldMetaData getFieldNamed(String fieldName);
+ FieldMetaData getFieldNamed(String fieldName);
}
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CopyBookParser.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CopyBookParser.java
index bf304c5..8e305b3 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CopyBookParser.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/CopyBookParser.java
@@ -55,9 +55,9 @@
* as an argument then parses this stream looking for "01" level record entries. It returns
* a <code>Vector</code> containing <code>RecordMetaData</code> for each "01" record defintion
* encountered in the stream.
- */
- public Vector parse(InputStream stream) throws Exception {
- Vector records;
+ */
+ public Vector<RecordMetaData> parse(InputStream stream) throws Exception {
+ Vector<RecordMetaData> records;
currentLineNumber = 0;
//read file and prepare for parsing
try {
@@ -71,7 +71,7 @@
//calculate the field offsets from the records
for (int i = 0; i < records.size(); i++) {
- setOffsetsForComposite((CompositeObject)records.elementAt(i), 0);
+ setOffsetsForComposite(records.elementAt(i), 0);
}
} catch (IOException exception) {
throw CopyBookParseException.ioException(exception);
@@ -84,12 +84,12 @@
* each line looking for a "01" level record definition, when it is encountered, it builds the
* hierarchical structure for the <code>RecordMetaData</code>
*/
- private Vector buildStructure(String fileString) throws Exception {
- Vector records = new Vector();
+ private Vector<RecordMetaData> buildStructure(String fileString) throws Exception {
+ Vector<RecordMetaData> records = new Vector<>();
StringTokenizer lineTokenizer = new StringTokenizer(fileString, System.getProperty("line.separator"), false);
RecordMetaData record = new RecordMetaData();
- Vector recordLines = new Vector();
- Vector lineNums = new Vector();
+ Vector<String> recordLines = new Vector<>();
+ Vector<Integer> lineNums = new Vector<>();
//first pass removes all non-record data and brings all lines together
while (lineTokenizer.hasMoreTokens() && !"procedure division.".equalsIgnoreCase(currentLine)) {
@@ -117,13 +117,13 @@
//second pass will build the structure
int nestingLevel = maximumNestingLevels;
- Stack parents = new Stack();
- Hashtable parentsToLevels = new Hashtable();
- Enumeration recordsEnum = recordLines.elements();
- Enumeration recordLineNums = lineNums.elements();
+ Stack<CompositeObject> parents = new Stack<>();
+ Hashtable<Object, Integer> parentsToLevels = new Hashtable<>();
+ Enumeration<String> recordsEnum = recordLines.elements();
+ Enumeration<Integer> recordLineNums = lineNums.elements();
while (recordsEnum.hasMoreElements()) {
- currentLine = (String)recordsEnum.nextElement();
- currentLineNumber = (Integer) recordLineNums.nextElement();
+ currentLine = recordsEnum.nextElement();
+ currentLineNumber = recordLineNums.nextElement();
StringTokenizer lineTokens = new StringTokenizer(currentLine);
if (lineTokens.hasMoreTokens()) {
String firstToken = lineTokens.nextToken();
@@ -133,31 +133,31 @@
//process record
if (levelNumber == 1) {
nestingLevel = maximumNestingLevels;
- parents = new Stack();
- parentsToLevels = new Hashtable();
+ parents = new Stack<>();
+ parentsToLevels = new Hashtable<>();
component = buildRecord(lineTokens);
record = (RecordMetaData)component;
- records.addElement(component);
+ records.addElement(record);
}
//process subordinate field
else if (levelNumber >= nestingLevel) {
component = buildField(lineTokens);
- ((CompositeObject)parents.peek()).addField((FieldMetaData)component);
+ parents.peek().addField((FieldMetaData)component);
}
//field is no longer subordinate skip back to original level
else {
- while ((Integer) parentsToLevels.get(parents.peek()) >= levelNumber) {
+ while (parentsToLevels.get(parents.peek()) >= levelNumber) {
parents.pop();
}
component = buildField(lineTokens);
- ((CompositeObject)parents.peek()).addField((FieldMetaData)component);
+ parents.peek().addField((FieldMetaData)component);
}
nestingLevel = levelNumber;
if (component instanceof FieldMetaData) {
((FieldMetaData)component).setRecord(record);
}
if (component instanceof CompositeObject) {
- parents.push(component);
+ parents.push((CompositeObject) component);
parentsToLevels.put(component, levelNumber);
}
}
@@ -173,13 +173,13 @@
private void setOffsetsForComposite(CompositeObject object, int offset) {
int currentOffset = offset;
int previousFieldSize = 0;
- Vector fields = object.getFields();
- Enumeration fieldEnum = fields.elements();
+ Vector<FieldMetaData> fields = object.getFields();
+ Enumeration<FieldMetaData> fieldEnum = fields.elements();
FieldMetaData previousField = null;
//loop through fields setting their offsets and redefines if it applies
while (fieldEnum.hasMoreElements()) {
- FieldMetaData field = (FieldMetaData)fieldEnum.nextElement();
+ FieldMetaData field = fieldEnum.nextElement();
//if its a redefine, must first see if it larger and reset offset accordingly
if (field.isFieldRedefine()) {
@@ -208,7 +208,7 @@
* This method processes "01" level lines building a <code>RecordMetaData</code> and
* returning it.
*/
- private RecordMetaData buildRecord(StringTokenizer lineTokens) throws Exception {
+ private RecordMetaData buildRecord(StringTokenizer lineTokens) {
RecordMetaData record;
if (lineTokens.hasMoreTokens()) {
String recordName = lineTokens.nextToken();
@@ -290,11 +290,11 @@
* This method handles the "depending" statement returning the name of the field that
* this field depends on.
*/
- private String handleDependeningStatement(String[] tokens, int index) throws Exception {
+ private String handleDependeningStatement(String[] tokens, int index) {
String fieldName = null;
try {
- fieldName = tokens[index];
if (index < tokens.length) {
+ fieldName = tokens[index];
if (fieldName.equalsIgnoreCase("on")) {
fieldName = tokens[++index];
}
@@ -313,10 +313,11 @@
*/
private int handleOccursStatement(String[] tokens, int index) throws Exception {
try {
- Integer size = Helper.integerFromString(tokens[index]);
+ int size = 0;
if (index < tokens.length) {
+ size = Helper.integerFromString(tokens[index]);
if (tokens[++index].equalsIgnoreCase("to")) {
- Integer newSize = Helper.integerFromString(tokens[++index]);
+ int newSize = Helper.integerFromString(tokens[++index]);
if (size > 0) {
newSize = newSize - size;
}
@@ -395,7 +396,7 @@
currentChar = picChars[index];
}
try {
- Integer value = Integer.valueOf(number.toString());
+ int value = Integer.parseInt(number.toString());
size += value;
} catch (NumberFormatException exception) {
throw invalidCopyBookException("In pic statement a valid integer must be enclosed by the parenthesis.", exception);
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/ElementaryFieldMetaData.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/ElementaryFieldMetaData.java
index 2626b83..4e9307a 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/ElementaryFieldMetaData.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/ElementaryFieldMetaData.java
@@ -363,7 +363,7 @@
Object value;
if (this.isArray()) {
int offset = this.getOffset();
- ArrayList fieldValue = new ArrayList(this.getArraySize());
+ List<String> fieldValue = new ArrayList<>(this.getArraySize());
for (int i = this.getArraySize(); i > 0; i--) {
FieldMetaData fieldCopy = this.deepCopy();
fieldCopy.setOffset(offset);
@@ -425,12 +425,13 @@
adjustArraySize(row);
}
int offset = this.getOffset();
- Iterator elements = ((List)value).iterator();
+ @SuppressWarnings({"unchecked"})
+ Iterator<String> elements = ((List<String>)value).iterator();
for (int i = this.getArraySize(); i > 0; i--) {
FieldMetaData fieldCopy = this.deepCopy();
fieldCopy.setOffset(offset);
converter = new ByteConverter(fieldCopy, recordData);
- String elementValue = (String)elements.next();
+ String elementValue = elements.next();
converter.setBytesToValue(elementValue);
offset += mySize;
}
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/FieldMetaData.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/FieldMetaData.java
index c3fd90c..fd0dd7a 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/FieldMetaData.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/FieldMetaData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -22,103 +22,103 @@
*/
public interface FieldMetaData {
//types
- public static final int NUMERIC = 1;
- public static final int ALPHA_NUMERIC = 2;
- public static final int COMPOSITE = 3;
- public static final int ALPHABETIC = 4;
- public static final int BINARY = 5;
- public static final int MANTISSA = 6;
- public static final int PACKED_DECIMAL = 7;
- public static final int VOID = 0;
+ int NUMERIC = 1;
+ int ALPHA_NUMERIC = 2;
+ int COMPOSITE = 3;
+ int ALPHABETIC = 4;
+ int BINARY = 5;
+ int MANTISSA = 6;
+ int PACKED_DECIMAL = 7;
+ int VOID = 0;
/** this method returns an new instance with the same values */
- public FieldMetaData deepCopy();
+ FieldMetaData deepCopy();
/** this method returns true if the field is signed */
- public boolean isSigned();
+ boolean isSigned();
/** this method sets the signed attribute for the field */
- public void setIsSigned(boolean signed);
+ void setIsSigned(boolean signed);
/** this method will return the name of the field */
- public String getName();
+ String getName();
/** this method will set the name of the field */
- public void setName(String newName);
+ void setName(String newName);
/** this method will return the associated record */
- public RecordMetaData getRecord();
+ RecordMetaData getRecord();
/** this method will set the assoicated record */
- public void setRecord(RecordMetaData newRecord);
+ void setRecord(RecordMetaData newRecord);
/** this method will return the size in bytes of the field */
- public int getSize();
+ int getSize();
/** this method will set the size of the field */
- public void setSize(int size);
+ void setSize(int size);
/** this method returns true if the field is composite, false otherwise */
- public boolean isComposite();
+ boolean isComposite();
/** this method returns the offset, in bytes, of the field in the record */
- public int getOffset();
+ int getOffset();
/** this method sets the offset of the field */
- public void setOffset(int offset);
+ void setOffset(int offset);
/** this method returns the type of the field */
- public int getType();
+ int getType();
/** this method sets the type of the field */
- public void setType(int type);
+ void setType(int type);
/** this method sets whether this is a field redefine or not */
- public boolean isFieldRedefine();
+ boolean isFieldRedefine();
/** this method sets the boolean for field redefine to true */
- public void setIsFieldRedefine(boolean status);
+ void setIsFieldRedefine(boolean status);
/** this method sets the redefined field */
- public void setFieldRedefined(FieldMetaData field);
+ void setFieldRedefined(FieldMetaData field);
/** this method returns the field that is redefined */
- public FieldMetaData getFieldRedefined();
+ FieldMetaData getFieldRedefined();
/** this method returns true is the field has a preset decimal position */
- public boolean hasDecimal();
+ boolean hasDecimal();
/** this method returns the decimal position index */
- public int getDecimalPosition();
+ int getDecimalPosition();
/** this method sets the decimal position to the new index */
- public void setDecimalPosition(int newPosition);
+ void setDecimalPosition(int newPosition);
/** this method returns true if this field is an array */
- public boolean isArray();
+ boolean isArray();
/** this method returns the array size */
- public int getArraySize();
+ int getArraySize();
/** this method sets the array size for the field */
- public void setArraySize(int newSize);
+ void setArraySize(int newSize);
/** this method returns true if the array size depends on another field */
- public boolean dependsOn();
+ boolean dependsOn();
/** this method returns the name of the dependent field name */
- public String getDependentFieldName();
+ String getDependentFieldName();
/** this method sets the dependent field name */
- public void setDependentFieldName(String fieldName);
+ void setDependentFieldName(String fieldName);
/** this method will extract the field's value from a byte array */
- public Object extractValueFromArray(byte[] recordData);
+ Object extractValueFromArray(byte[] recordData);
/** this method will write itself on the give row extracting the data from the given
byte array */
- public void writeOnRow(CobolRow row, byte[] recordData);
+ void writeOnRow(CobolRow row, byte[] recordData);
/** this method will write itself on the given byte array from the data in the row */
- public void writeOnArray(CobolRow row, byte[] recordData);
+ void writeOnArray(CobolRow row, byte[] recordData);
}
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/RecordMetaData.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/RecordMetaData.java
index 33fa924..70abbd3 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/RecordMetaData.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/eis/cobol/RecordMetaData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -22,7 +22,7 @@
public class RecordMetaData implements CompositeObject {
/** a collection of fields that the record contains */
- private Vector myFields;
+ private Vector<FieldMetaData> myFields;
/** the name of the record */
private String myName;
@@ -36,20 +36,20 @@
initialize(name);
}
- public RecordMetaData(String name, Vector fields) {
+ public RecordMetaData(String name, Vector<FieldMetaData> fields) {
initialize(name, fields);
}
private void initialize() {
- myFields = new Vector();
+ myFields = new Vector<>();
}
private void initialize(String name) {
myName = name;
- myFields = new Vector();
+ myFields = new Vector<>();
}
- private void initialize(String name, Vector fields) {
+ private void initialize(String name, Vector<FieldMetaData> fields) {
myName = name;
myFields = fields;
}
@@ -67,13 +67,13 @@
/** getter for myFields */
@Override
- public Vector getFields() {
+ public Vector<FieldMetaData> getFields() {
return myFields;
}
/** setter for myFields */
@Override
- public void setFields(Vector newFields) {
+ public void setFields(Vector<FieldMetaData> newFields) {
myFields = newFields;
}
@@ -91,9 +91,9 @@
/** retrieves the <code>FieldMetaData</code> with the corresponding name if it exists */
@Override
public FieldMetaData getFieldNamed(String fieldName) {
- Enumeration fieldsEnum = getFields().elements();
+ Enumeration<FieldMetaData> fieldsEnum = getFields().elements();
while (fieldsEnum.hasMoreElements()) {
- FieldMetaData field = (FieldMetaData)fieldsEnum.nextElement();
+ FieldMetaData field = fieldsEnum.nextElement();
if (field.getName().equals(fieldName)) {
return field;
}
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/mongo/MongoDatabaseInteraction.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/mongo/MongoDatabaseInteraction.java
index daa0f28..6346acd 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/mongo/MongoDatabaseInteraction.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/mongo/MongoDatabaseInteraction.java
@@ -103,9 +103,7 @@
throw new ResourceException("Invalid operation: " + operation);
}
} catch (Exception exception) {
- ResourceException resourceException = new ResourceException(exception.toString());
- resourceException.initCause(exception);
- throw resourceException;
+ throw new ResourceException(exception);
}
}
@@ -126,8 +124,7 @@
MongoOperation operation = mongoSpec.getOperation();
String collectionName = mongoSpec.getCollection();
if (operation == null) {
- ResourceException resourceException = new ResourceException("Mongo operation must be set");
- throw resourceException;
+ throw new ResourceException("Mongo operation must be set");
}
if (operation == MongoOperation.EVAL) {
Document commandDocument = new Document("$eval", mongoSpec.getCode())/*.append("args", asList(args))*/;
@@ -135,8 +132,7 @@
return buildRecordFromDBObject((Document)result.get("retval"));
}
if (collectionName == null) {
- ResourceException resourceException = new ResourceException("DB Collection name must be set");
- throw resourceException;
+ throw new ResourceException("DB Collection name must be set");
}
try {
MongoCollection<Document> collection = this.connection.getDB().getCollection(collectionName);
@@ -199,9 +195,7 @@
throw new ResourceException("Invalid operation: " + operation);
}
} catch (Exception exception) {
- ResourceException resourceException = new ResourceException(exception.toString());
- resourceException.initCause(exception);
- throw resourceException;
+ throw new ResourceException(exception.toString(), exception);
}
return null;
}
@@ -211,12 +205,12 @@
*/
public BasicDBObject buildDBObject(MongoRecord record) {
BasicDBObject object = new BasicDBObject();
- for (Iterator iterator = record.entrySet().iterator(); iterator.hasNext(); ) {
- Map.Entry entry = (Map.Entry)iterator.next();
+ for (Iterator<Map.Entry<String, ?>> iterator = record.entrySet().iterator(); iterator.hasNext(); ) {
+ Map.Entry<String, ?> entry = iterator.next();
if (entry.getValue() instanceof MongoRecord) {
- object.put((String)entry.getKey(), buildDBObject((MongoRecord)entry.getValue()));
+ object.put(entry.getKey(), buildDBObject((MongoRecord)entry.getValue()));
} else {
- object.put((String)entry.getKey(), entry.getValue());
+ object.put(entry.getKey(), entry.getValue());
}
}
return object;
@@ -227,12 +221,12 @@
*/
public Document buildDocument(MongoRecord record) {
Document object = new Document();
- for (Iterator iterator = record.entrySet().iterator(); iterator.hasNext(); ) {
- Map.Entry entry = (Map.Entry)iterator.next();
+ for (Iterator<Map.Entry<String, ?>> iterator = record.entrySet().iterator(); iterator.hasNext(); ) {
+ Map.Entry<String, ?> entry = iterator.next();
if (entry.getValue() instanceof MongoRecord) {
- object.put((String)entry.getKey(), buildDBObject((MongoRecord)entry.getValue()));
+ object.put(entry.getKey(), buildDBObject((MongoRecord)entry.getValue()));
} else {
- object.put((String)entry.getKey(), entry.getValue());
+ object.put(entry.getKey(), entry.getValue());
}
}
return object;
@@ -246,7 +240,7 @@
for (Iterator<Map.Entry<String, Object>> iterator = object.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry<String, Object> entry = iterator.next();
if (entry.getValue() instanceof BasicDBList) {
- List values = new ArrayList();
+ List<Object> values = new ArrayList<>();
for (Iterator<Object> valuesIterator = ((BasicDBList)entry.getValue()).iterator(); valuesIterator.hasNext(); ) {
Object value = valuesIterator.next();
if (value instanceof Document) {
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/mongo/MongoInteraction.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/mongo/MongoInteraction.java
index 8fa7e41..8d0027e 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/mongo/MongoInteraction.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/mongo/MongoInteraction.java
@@ -91,9 +91,7 @@
throw new ResourceException("Invalid operation: " + operation);
}
} catch (Exception exception) {
- ResourceException resourceException = new ResourceException(exception.toString());
- resourceException.initCause(exception);
- throw resourceException;
+ throw new ResourceException(exception.toString(), exception);
}
}
@@ -114,16 +112,14 @@
MongoOperation operation = mongoSpec.getOperation();
String collectionName = mongoSpec.getCollection();
if (operation == null) {
- ResourceException resourceException = new ResourceException("Mongo operation must be set");
- throw resourceException;
+ throw new ResourceException("Mongo operation must be set");
}
if (operation == MongoOperation.EVAL) {
Object result = this.connection.getDB().eval(mongoSpec.getCode());
return buildRecordFromDBObject((DBObject)result);
}
if (collectionName == null) {
- ResourceException resourceException = new ResourceException("DB Collection name must be set");
- throw resourceException;
+ throw new ResourceException("DB Collection name must be set");
}
try {
DBCollection collection = this.connection.getDB().getCollection(collectionName);
@@ -185,9 +181,7 @@
throw new ResourceException("Invalid operation: " + operation);
}
} catch (Exception exception) {
- ResourceException resourceException = new ResourceException(exception.toString());
- resourceException.initCause(exception);
- throw resourceException;
+ throw new ResourceException(exception);
}
return null;
}
@@ -197,12 +191,12 @@
*/
public DBObject buildDBObject(MongoRecord record) {
DBObject object = new BasicDBObject();
- for (Iterator iterator = record.entrySet().iterator(); iterator.hasNext(); ) {
- Map.Entry entry = (Map.Entry)iterator.next();
+ for (Iterator<Map.Entry<String, ?>> iterator = record.entrySet().iterator(); iterator.hasNext(); ) {
+ Map.Entry<String, ?> entry = iterator.next();
if (entry.getValue() instanceof MongoRecord) {
- object.put((String)entry.getKey(), buildDBObject((MongoRecord)entry.getValue()));
+ object.put(entry.getKey(), buildDBObject((MongoRecord)entry.getValue()));
} else {
- object.put((String)entry.getKey(), entry.getValue());
+ object.put(entry.getKey(), entry.getValue());
}
}
return object;
@@ -211,12 +205,13 @@
/**
* Build the Map record from the Mongo DBObject.
*/
+ @SuppressWarnings({"rawtypes"})
public MongoRecord buildRecordFromDBObject(DBObject object) {
MongoRecord record = new MongoRecord();
for (Iterator iterator = object.toMap().entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry entry = (Map.Entry)iterator.next();
if (entry.getValue() instanceof BasicDBList) {
- List values = new ArrayList();
+ List<Object> values = new ArrayList<>();
for (Iterator<Object> valuesIterator = ((BasicDBList)entry.getValue()).iterator(); valuesIterator.hasNext(); ) {
Object value = valuesIterator.next();
if (value instanceof DBObject) {
diff --git a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/nosql/adapters/mongo/MongoPlatform.java b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/nosql/adapters/mongo/MongoPlatform.java
index 022f7c8..2465085 100644
--- a/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/nosql/adapters/mongo/MongoPlatform.java
+++ b/foundation/org.eclipse.persistence.nosql/src/main/java/org/eclipse/persistence/nosql/adapters/mongo/MongoPlatform.java
@@ -378,7 +378,7 @@
DatabaseRecord second = new DatabaseRecord();
appendExpressionToQueryRow(logic.getFirstChild(), first, query);
appendExpressionToQueryRow(logic.getSecondChild(), second, query);
- List nested = new Vector();
+ List<DatabaseRecord> nested = new Vector<>();
nested.add(first);
nested.add(second);
if (logic.getOperator().getSelector() == ExpressionOperator.And) {
@@ -495,7 +495,8 @@
throw new EISException("Query too complex for Mongo translation, comparison of [" + expression + "] not supported in query: " + query);
}
if (value instanceof List) {
- List values = (List)value;
+ @SuppressWarnings({"unchecked"})
+ List<Object> values = (List<Object>)value;
for (int index = 0; index < values.size(); index++) {
Object element = values.get(index);
if (element instanceof Expression) {
diff --git a/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/aq/AQConnectionFactory.java b/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/aq/AQConnectionFactory.java
index 762bc64..970cae8 100644
--- a/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/aq/AQConnectionFactory.java
+++ b/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/internal/eis/adapters/aq/AQConnectionFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -58,7 +58,7 @@
connection.setAutoCommit(false);
}
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
- AccessController.doPrivileged(new PrivilegedClassForName("oracle.AQ.AQOracleDriver", true, this.getClass().getClassLoader()));
+ AccessController.doPrivileged(new PrivilegedClassForName<>("oracle.AQ.AQOracleDriver", true, this.getClass().getClassLoader()));
}else{
PrivilegedAccessHelper.getClassForName("oracle.AQ.AQOracleDriver", true, this.getClass().getClassLoader());
}
diff --git a/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/nosql/OracleNoSQLInteraction.java b/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/nosql/OracleNoSQLInteraction.java
index 3e97390..e2faa49 100644
--- a/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/nosql/OracleNoSQLInteraction.java
+++ b/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/internal/nosql/adapters/nosql/OracleNoSQLInteraction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -79,6 +79,7 @@
* The spec is either GET, PUT or DELETE interaction.
*/
@Override
+ @SuppressWarnings({"unchecked"})
public jakarta.resource.cci.Record execute(InteractionSpec spec, jakarta.resource.cci.Record record) throws ResourceException {
if (!(spec instanceof OracleNoSQLInteractionSpec)) {
throw EISException.invalidInteractionSpecType();
@@ -92,7 +93,7 @@
OracleNoSQLOperation operation = noSqlSpec.getOperation();
if (operation == OracleNoSQLOperation.GET) {
OracleNoSQLRecord output = new OracleNoSQLRecord();
- for (Map.Entry entry : (Set<Map.Entry>)input.entrySet()) {
+ for (Map.Entry<?, ?> entry : (Set<Map.Entry<?, ?>>)input.entrySet()) {
Key key = Key.createKey(createMajorKey(entry.getKey()));
Map<Key, ValueVersion> values = this.connection.getStore().multiGet(
key, null, null, noSqlSpec.getConsistency(), noSqlSpec.getTimeout(), TimeUnit.MILLISECONDS);
@@ -132,7 +133,7 @@
return output;
} else if (operation == OracleNoSQLOperation.ITERATOR) {
OracleNoSQLRecord output = new OracleNoSQLRecord();
- for (Map.Entry entry : (Set<Map.Entry>)input.entrySet()) {
+ for (Map.Entry<?, ?> entry : (Set<Map.Entry<?, ?>>)input.entrySet()) {
Key key = Key.createKey(createMajorKey(entry.getKey()));
Iterator<KeyValueVersion> values = this.connection.getStore().storeIterator(
Direction.UNORDERED, 0, key, null, null, noSqlSpec.getConsistency(), noSqlSpec.getTimeout(), TimeUnit.MILLISECONDS);
@@ -171,11 +172,11 @@
return output;
} else if ((operation == OracleNoSQLOperation.PUT) || (operation == OracleNoSQLOperation.PUT_IF_ABSENT)
|| (operation == OracleNoSQLOperation.PUT_IF_PRESENT) || (operation == OracleNoSQLOperation.PUT_IF_VERSION)) {
- List<Operation> operations = new ArrayList();
- for (Map.Entry entry : (Set<Map.Entry>)input.entrySet()) {
+ List<Operation> operations = new ArrayList<>();
+ for (Map.Entry<?, ?> entry : (Set<Map.Entry<?, ?>>)input.entrySet()) {
Object inputValue = entry.getValue();
- List majorKeys = createMajorKey(entry.getKey());
- List<String> minorKeys = new ArrayList<String>();
+ List<String> majorKeys = createMajorKey(entry.getKey());
+ List<String> minorKeys = new ArrayList<>();
putValues(inputValue, majorKeys, minorKeys, noSqlSpec, operations);
}
List<OperationResult> results = this.connection.getStore().execute(operations, noSqlSpec.getDurability(), noSqlSpec.getTimeout(), TimeUnit.MILLISECONDS);
@@ -185,12 +186,12 @@
}
}
} else if (operation == OracleNoSQLOperation.DELETE) {
- for (Map.Entry entry : (Set<Map.Entry>)input.entrySet()) {
+ for (Map.Entry<?, ?> entry : (Set<Map.Entry<?, ?>>)input.entrySet()) {
Key key = Key.createKey(createMajorKey(entry.getKey()));
this.connection.getStore().multiDelete(key, null, null, noSqlSpec.getDurability(), noSqlSpec.getTimeout(), TimeUnit.MILLISECONDS);
}
} else if (operation == OracleNoSQLOperation.DELETE_IF_VERSION) {
- for (Map.Entry entry : (Set<Map.Entry>)input.entrySet()) {
+ for (Map.Entry<?, ?> entry : (Set<Map.Entry<?, ?>>)input.entrySet()) {
Key key = Key.createKey(createMajorKey(entry.getKey()));
boolean success = this.connection.getStore().deleteIfVersion(key, noSqlSpec.getVersion(), null, noSqlSpec.getDurability(), noSqlSpec.getTimeout(), TimeUnit.MILLISECONDS);
if (!success) {
@@ -201,9 +202,7 @@
throw new ResourceException("Invalid NoSQL operation:" + operation);
}
} catch (Exception exception) {
- ResourceException resourceException = new ResourceException(exception.toString());
- resourceException.initCause(exception);
- throw resourceException;
+ throw new ResourceException(exception);
}
return null;
}
@@ -224,12 +223,13 @@
* this allows for a special key syntax to be used, or a list.
* "[<key1>,<key2>,..]"
*/
- protected List createMajorKey(Object key) {
- List majorKeys = null;
+ @SuppressWarnings({"unchecked"})
+ protected List<String> createMajorKey(Object key) {
+ List<String> majorKeys = null;
if (key instanceof List) {
- majorKeys = (List)key;
+ majorKeys = (List<String>)key;
} else {
- majorKeys = new ArrayList<String>();
+ majorKeys = new ArrayList<>();
String keyString = key.toString();
if ((keyString.length() > 2) && (keyString.charAt(0) == '[') && (keyString.charAt(keyString.length() - 1) == ']')) {
int startIndex = 1;
@@ -255,17 +255,10 @@
*/
protected void putValues(Object element, List<String> majorKeys, List<String> minorKeys, OracleNoSQLInteractionSpec spec, List<Operation> operations) {
if (element instanceof Collection) {
- element = ((List)element).get(0);
+ element = ((List<?>)element).get(0);
// Append nested record using minor keys.
- for (Map.Entry nestedEntry : (Set<Map.Entry>)((OracleNoSQLRecord)element).entrySet()) {
- List<String> nestedMinorKeys = new ArrayList<String>(minorKeys);
- nestedMinorKeys.add(nestedEntry.getKey().toString());
- putValues(nestedEntry.getValue(), majorKeys, nestedMinorKeys, spec, operations);
- }
- } else if (element instanceof OracleNoSQLRecord) {
- // Append nested record using minor keys.
- for (Map.Entry nestedEntry : (Set<Map.Entry>)((OracleNoSQLRecord)element).entrySet()) {
- List<String> nestedMinorKeys = new ArrayList<String>(minorKeys);
+ for (Map.Entry<?, ?> nestedEntry : ((Map<?, ?>)element).entrySet()) {
+ List<String> nestedMinorKeys = new ArrayList<>(minorKeys);
nestedMinorKeys.add(nestedEntry.getKey().toString());
putValues(nestedEntry.getValue(), majorKeys, nestedMinorKeys, spec, operations);
}
diff --git a/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/nosql/adapters/nosql/OracleNoSQLPlatform.java b/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/nosql/adapters/nosql/OracleNoSQLPlatform.java
index dc0e428..4fe94cb 100644
--- a/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/nosql/adapters/nosql/OracleNoSQLPlatform.java
+++ b/foundation/org.eclipse.persistence.oracle.nosql/src/main/java/org/eclipse/persistence/nosql/adapters/nosql/OracleNoSQLPlatform.java
@@ -208,22 +208,22 @@
* Allow the platform to handle record to row conversion.
*/
@Override
- public Vector buildRows(jakarta.resource.cci.Record record, EISInteraction interaction, EISAccessor accessor) {
+ public Vector<AbstractRecord> buildRows(jakarta.resource.cci.Record record, EISInteraction interaction, EISAccessor accessor) {
if (record == null) {
- return new Vector(0);
+ return new Vector<>(0);
}
OracleNoSQLRecord output = (OracleNoSQLRecord)record;
if ((output.size() == 1) && (interaction.getQuery().getDescriptor() != null)) {
// Check for a nested mapped record.
Object value = output.values().iterator().next();
if (value instanceof OracleNoSQLRecord) {
- Vector rows = new Vector(1);
+ Vector<AbstractRecord> rows = new Vector<>(1);
convertRecordBytesToString((OracleNoSQLRecord)value);
rows.add(interaction.buildRow((OracleNoSQLRecord)value, accessor));
return rows;
} else if (value instanceof Collection) {
- Vector rows = new Vector(((Collection)value).size());
- for (Object nestedValue : (Collection)value) {
+ Vector<AbstractRecord> rows = new Vector<>(((Collection<?>)value).size());
+ for (Object nestedValue : (Collection<?>)value) {
if (nestedValue instanceof OracleNoSQLRecord) {
rows.add(interaction.buildRow((OracleNoSQLRecord)nestedValue, accessor));
}
@@ -233,7 +233,7 @@
}
if (interaction.getQuery().getDescriptor() != null) {
// Check for a map of values.
- Vector rows = new Vector();
+ Vector<AbstractRecord> rows = new Vector<>();
for (Object value : output.values()) {
if (value instanceof OracleNoSQLRecord) {
convertRecordBytesToString((OracleNoSQLRecord)value);
@@ -255,8 +255,8 @@
*/
protected void convertRecordBytesToString(OracleNoSQLRecord record) {
// Convert byte[] to String.
- for (Iterator<Map.Entry> iterator = record.entrySet().iterator(); iterator.hasNext(); ) {
- Map.Entry entry = iterator.next();
+ for (Iterator<Map.Entry<?, Object>> iterator = record.entrySet().iterator(); iterator.hasNext(); ) {
+ Map.Entry<?, Object> entry = iterator.next();
if (entry.getValue() instanceof byte[]) {
entry.setValue(new String((byte[])entry.getValue()));
} else if (entry.getValue() instanceof OracleNoSQLRecord) {
@@ -321,7 +321,7 @@
*/
protected Object createMajorKey(ClassDescriptor descriptor, AbstractRecord record, EISInteraction interaction, EISAccessor accessor) {
Object id = descriptor.getObjectBuilder().extractPrimaryKeyFromRow(record, interaction.getQuery().getSession());
- List key = new ArrayList(descriptor.getPrimaryKeyFields().size() + 1);
+ List<String> key = new ArrayList<>(descriptor.getPrimaryKeyFields().size() + 1);
if (((EISDescriptor)descriptor).getDataTypeName().length() > 0) {
key.add(((EISDescriptor)descriptor).getDataTypeName());
}
@@ -367,7 +367,7 @@
}
} else {
domRecord = new EISDOMRecord();
- for (Map.Entry entry : (Set<Map.Entry>)noSqlRecord.entrySet()) {
+ for (Map.Entry<?, ?> entry : (Set<Map.Entry<?, ?>>)noSqlRecord.entrySet()) {
Object value = entry.getValue();
String xml = null;
if (value instanceof byte[]) {