aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Kraus2014-04-23 09:48:27 (EDT)
committerTomas Kraus2014-04-29 09:21:18 (EDT)
commit520c45010a3fdc5350ee781f0fa45dd7fc4a3705 (patch)
tree7c8e310ad686e148123432ecbf9d29e9fddcc9c7
parenta10e30f0c145ec6485f0cb3549e4eee687d30539 (diff)
downloadeclipselink.runtime-520c45010a3fdc5350ee781f0fa45dd7fc4a3705.zip
eclipselink.runtime-520c45010a3fdc5350ee781f0fa45dd7fc4a3705.tar.gz
eclipselink.runtime-520c45010a3fdc5350ee781f0fa45dd7fc4a3705.tar.bz2
Bug# 433302 - SPECjEnterprise performance regression in 2.5.2 and TRUNK
* inner classes changed to static where possible * String '+' operator replaced with StringBuilder Signed-off-by: Tomas Kraus <tomas.kraus@oracle.com>
-rw-r--r--dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/QueryOperation.java39
-rw-r--r--dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/Util.java110
-rw-r--r--dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRFieldInfo.java33
-rw-r--r--dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRServiceFactory.java15
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/CMPPolicy.java38
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/QueryException.java40
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/XMLMarshalException.java66
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/descriptors/DescriptorHelper.java101
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicEntityImpl.java40
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicPropertiesManager.java24
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/helper/StringHelper.java55
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/AbstractObjectLevelReadQueryVisitor.java4
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/ExpressionBuilderVisitor.java5
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLLexer.java63
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLParser.java678
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/ReferenceResolver.java15
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLBinaryDataHelper.java3
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/DOMReader.java30
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLEventReaderReader.java6
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLStreamReaderReader.java15
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/deferred/DeferredContentHandler.java15
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/SecurableObjectHolder.java15
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/ObjectPersistenceRuntimeXMLProject_11_1_1.java92
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/XMLDescriptor.java92
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/oracle/plsql/PLSQLStoredProcedureCall.java55
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ConstructorReportItem.java93
-rw-r--r--foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/tools/PackageRenamer.java25
-rw-r--r--foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/CopyBookParser.java44
-rw-r--r--foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/helper/ByteConverter.java102
-rw-r--r--jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractEclipseLinkSemanticValidator.java29
-rw-r--r--jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractGrammarValidator.java175
-rw-r--r--jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractSemanticValidator.java64
-rw-r--r--jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/EclipseLinkGrammarValidator.java26
-rw-r--r--jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/AndExpressionFactory.java25
-rw-r--r--jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/ArithmeticExpressionFactory.java25
-rw-r--r--jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/FullyQualifyPathExpressionVisitor.java25
-rw-r--r--jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/AbstractContentAssistVisitor.java917
-rw-r--r--jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/EclipseLinkContentAssistVisitor.java59
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/CMP3Policy.java328
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java10
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/deployment/JavaSECMPInitializer.java24
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/ORMetadata.java28
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/MetadataHelper.java94
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/classes/ConverterAccessor.java8
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAnnotatedElement.java37
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/IndexMetadata.java79
-rw-r--r--moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/AnnotationsProcessor.java25
-rw-r--r--moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java183
-rw-r--r--moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/SchemaGenerator.java25
-rw-r--r--utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/BaseDBWSBuilderHelper.java66
-rw-r--r--utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/DBWSBuilder.java51
-rw-r--r--utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/oracle/OracleHelper.java222
-rwxr-xr-xutils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/metadata/generation/JPAMetadataGenerator.java50
53 files changed, 2647 insertions, 1841 deletions
diff --git a/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/QueryOperation.java b/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/QueryOperation.java
index ab013d7..7f0a8c0 100644
--- a/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/QueryOperation.java
+++ b/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/QueryOperation.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2012 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -194,13 +194,13 @@ public class QueryOperation extends Operation {
if (queryHandler != null) {
queryHandler.validate(xrService, this);
}
- }
-
-
- public class DataHandlerInstantiationPolicy extends InstantiationPolicy {
- protected String mimeType;
- public DataHandlerInstantiationPolicy(String mimeType) {
- super();
+ }
+
+ // Made static final for performance reasons.
+ private static final class DataHandlerInstantiationPolicy extends InstantiationPolicy {
+ protected String mimeType;
+ public DataHandlerInstantiationPolicy(String mimeType) {
+ super();
this.mimeType = mimeType;
}
@Override
@@ -247,14 +247,13 @@ public class QueryOperation extends Operation {
XMLDescriptor descriptor =
(XMLDescriptor)oxSession.getProject().getClassDescriptor(DataHandler.class);
if (descriptor == null) {
- descriptor = new XMLDescriptor();
- descriptor.setAlias(DATAHANDLER_STR);
- descriptor.setJavaClass(DataHandler.class);
- descriptor.setInstantiationPolicy(
- this.new DataHandlerInstantiationPolicy(attachment.getMimeType()));
- XMLBinaryDataMapping mapping = new XMLBinaryDataMapping();
- mapping.setAttributeName(RESULTS_STR);
- mapping.setAttributeAccessor(new AttributeAccessor() {
+ descriptor = new XMLDescriptor();
+ descriptor.setAlias(DATAHANDLER_STR);
+ descriptor.setJavaClass(DataHandler.class);
+ descriptor.setInstantiationPolicy(new DataHandlerInstantiationPolicy(attachment.getMimeType()));
+ XMLBinaryDataMapping mapping = new XMLBinaryDataMapping();
+ mapping.setAttributeName(RESULTS_STR);
+ mapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public Object getAttributeValueFromObject(Object object)
throws DescriptorException {
diff --git a/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/Util.java b/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/Util.java
index 95156a9..4b441cc 100644
--- a/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/Util.java
+++ b/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/Util.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2012 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -124,61 +124,61 @@ public class Util {
int length = name.length();
if (length == 0) {
- return name;
- }
-
- String xmlName = new String();
- int beginAt = 1;
- char firstChar = name.charAt(0);
- // escape : to _x003A_
- if (firstChar == ':') {
- xmlName = xmlName + "_x003A_";
- }
- // escape _ of _x to _x005F_
- else if ((length >= 2) && name.substring(0, 2).equals("_x")) {
- xmlName = xmlName + "_x005F_";
- }
- // check to see if it is a valid first character
- else {
- if ((firstChar >= 0xd800) && (firstChar < 0xdc00)) {
- // surrogate
- if (length > 1) {
- xmlName += hexEscape((firstChar << 16) | (name.charAt(1) & 0xffff));
- beginAt = 2;
- } else {
- xmlName += hexEscape(firstChar);
- }
- } else if (isFirstNameChar(firstChar)) {
- xmlName = xmlName + firstChar;
- } else {
- xmlName = xmlName + hexEscape(firstChar);
- }
- }
-
+ return name;
+ }
+
+ StringBuilder xmlName = new StringBuilder();
+ int beginAt = 1;
+ char firstChar = name.charAt(0);
+ // escape : to _x003A_
+ if (firstChar == ':') {
+ xmlName.append("_x003A_");
+ }
+ // escape _ of _x to _x005F_
+ else if ((length >= 2) && name.substring(0, 2).equals("_x")) {
+ xmlName.append("_x005F_");
+ }
+ // check to see if it is a valid first character
+ else {
+ if ((firstChar >= 0xd800) && (firstChar < 0xdc00)) {
+ // surrogate
+ if (length > 1) {
+ xmlName.append(hexEscape((firstChar << 16) | (name.charAt(1) & 0xffff)));
+ beginAt = 2;
+ } else {
+ xmlName.append(hexEscape(firstChar));
+ }
+ } else if (isFirstNameChar(firstChar)) {
+ xmlName.append(firstChar);
+ } else {
+ xmlName.append(hexEscape(firstChar));
+ }
+ }
+
// check each following character to see if it is a valid NameChar
char c;
for (int x = beginAt; x < length; x++) {
c = name.charAt(x);
- if ((c >= 0xd800) && (c < 0xdc00)) {
- // surrogate
- if ((x + 1) < length) {
- xmlName += hexEscape((c << 16) | (name.charAt(x + 1) & 0xffff));
- x++;
- } else {
- xmlName += hexEscape(c);
- }
- } else if (!isNameChar(c)) {
- // escape
- xmlName = xmlName + hexEscape(c);
- } else {
- xmlName = xmlName + c;
- }
- }
- return xmlName;
- }
-
- /**
+ if ((c >= 0xd800) && (c < 0xdc00)) {
+ // surrogate
+ if ((x + 1) < length) {
+ xmlName.append(hexEscape((c << 16) | (name.charAt(x + 1) & 0xffff)));
+ x++;
+ } else {
+ xmlName.append(hexEscape(c));
+ }
+ } else if (!isNameChar(c)) {
+ // escape
+ xmlName.append(hexEscape(c));
+ } else {
+ xmlName.append(c);
+ }
+ }
+ return xmlName.toString();
+ }
+
+ /**
* Convert an escaped XML name back to the original SQL name
*
* @param name
diff --git a/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRFieldInfo.java b/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRFieldInfo.java
index 319b6e1..753207b 100644
--- a/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRFieldInfo.java
+++ b/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRFieldInfo.java
@@ -1,6 +1,18 @@
-package org.eclipse.persistence.internal.xr;
-
-import java.util.HashMap;
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation from Oracle TopLink
+ ******************************************************************************/
+package org.eclipse.persistence.internal.xr;
+
+import java.util.HashMap;
import java.util.Map;
import org.eclipse.persistence.exceptions.DynamicException;
@@ -37,13 +49,14 @@ public class XRFieldInfo {
break;
}
}
- return fieldName;
- }
-
- class Index {
- int idx;
- public Index(int idx) {
- this.idx = idx;
+ return fieldName;
+ }
+
+ // Made static final for performance reasons.
+ private static final class Index {
+ int idx;
+ public Index(int idx) {
+ this.idx = idx;
}
}
} \ No newline at end of file
diff --git a/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRServiceFactory.java b/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRServiceFactory.java
index 5d8c563..3ef3d9e 100644
--- a/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRServiceFactory.java
+++ b/dbws/org.eclipse.persistence.dbws/src/org/eclipse/persistence/internal/xr/XRServiceFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -604,7 +604,8 @@ public class XRServiceFactory {
}
}
}
-
+
+ // Made static final for performance reasons.
/**
* <p>INTERNAL:
*
@@ -612,7 +613,7 @@ public class XRServiceFactory {
* to the DynamicJAXBContextFactory
*
*/
- public class OXMMetadataSource implements MetadataSource {
+ public static final class OXMMetadataSource implements MetadataSource {
XmlBindings xmlbindings;
public OXMMetadataSource(XmlBindings bindings) {
@@ -624,7 +625,8 @@ public class XRServiceFactory {
return xmlbindings;
}
}
-
+
+ // Made static final for performance reasons.
/**
* <p>INTERNAL:
*
@@ -632,7 +634,7 @@ public class XRServiceFactory {
* MetadataProcessor.
*
*/
- public class JPAMetadataSource implements org.eclipse.persistence.jpa.metadata.MetadataSource {
+ public static final class JPAMetadataSource implements org.eclipse.persistence.jpa.metadata.MetadataSource {
XRDynamicClassLoader xrdecl;
Reader reader;
@@ -652,6 +654,7 @@ public class XRServiceFactory {
}
}
+ // Made static final for performance reasons.
/**
* <p>INTERNAL:
*
@@ -660,7 +663,7 @@ public class XRServiceFactory {
* null, empty lists, etc.
*
*/
- public class XRPersistenceUnitInfo implements PersistenceUnitInfo {
+ public static final class XRPersistenceUnitInfo implements PersistenceUnitInfo {
XRDynamicClassLoader xrdecl;
public XRPersistenceUnitInfo(XRDynamicClassLoader loader) {
xrdecl = loader;
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/CMPPolicy.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/CMPPolicy.java
index 5ebcd3f..7c127a3 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/CMPPolicy.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/descriptors/CMPPolicy.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -575,26 +575,26 @@ public class CMPPolicy implements java.io.Serializable, Cloneable {
}
/**
- * INTERNAL:
- * This is the interface used to encapsulate the the type of key class element
- */
- protected interface KeyElementAccessor {
- public String getAttributeName();
- public DatabaseField getDatabaseField();
- public DatabaseMapping getMapping();
+ * INTERNAL:
+ * This is the interface used to encapsulate the the type of key class element
+ */
+ protected static interface KeyElementAccessor {
+ public String getAttributeName();
+ public DatabaseField getDatabaseField();
+ public DatabaseMapping getMapping();
public Object getValue(Object object, AbstractSession session);
public void setValue(Object object, Object value);
public boolean isNestedAccessor();
}
/**
- * INTERNAL:
- * This class will be used when the keyClass is a primitive
- */
- protected class KeyIsElementAccessor implements KeyElementAccessor, Serializable {
- protected String attributeName;
- protected DatabaseField databaseField;
- protected DatabaseMapping mapping;
+ * INTERNAL:
+ * This class will be used when the keyClass is a primitive
+ */
+ protected static final class KeyIsElementAccessor implements KeyElementAccessor, Serializable {
+ protected String attributeName;
+ protected DatabaseField databaseField;
+ protected DatabaseMapping mapping;
public KeyIsElementAccessor(String attributeName, DatabaseField databaseField, DatabaseMapping mapping) {
this.attributeName = attributeName;
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/QueryException.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/QueryException.java
index a5bf735..ad31a04 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/QueryException.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/QueryException.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -712,18 +712,24 @@ public class QueryException extends ValidationException {
QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, MAPPING_FOR_EXPRESSION_DOES_NOT_SUPPORT_JOINING, args));
queryException.setErrorCode(MAPPING_FOR_EXPRESSION_DOES_NOT_SUPPORT_JOINING);
- return queryException;
- }
-
- public static QueryException mappingForFieldResultNotFound(String[] attributeNames, int currentString){
- String attributeName ="";
- for(int i=0; i<attributeNames.length;i++){
- attributeName=attributeName+attributeNames[i];
- }
- Object[] args = { attributeName, attributeNames[currentString] };
-
- QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, MAPPING_FOR_FIELDRESULT_NOT_FOUND, args));
- queryException.setErrorCode(MAPPING_FOR_FIELDRESULT_NOT_FOUND);
+ return queryException;
+ }
+
+ public static QueryException mappingForFieldResultNotFound(String[] attributeNames, int currentString) {
+ // Calculate name length
+ int length = 0;
+ for(int i=0; i<attributeNames.length;i++) {
+ length += attributeNames[i].length();
+ }
+ // Build name
+ StringBuilder attributeName = new StringBuilder(length);
+ for(int i=0; i<attributeNames.length;i++) {
+ attributeName.append(attributeNames[i]);
+ }
+ Object[] args = { attributeName.toString(), attributeNames[currentString] };
+
+ QueryException queryException = new QueryException(ExceptionMessageGenerator.buildMessage(QueryException.class, MAPPING_FOR_FIELDRESULT_NOT_FOUND, args));
+ queryException.setErrorCode(MAPPING_FOR_FIELDRESULT_NOT_FOUND);
return queryException;
}
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/XMLMarshalException.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/XMLMarshalException.java
index f52ba33..8fa44a4 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/XMLMarshalException.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/exceptions/XMLMarshalException.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -22,12 +22,17 @@ import org.eclipse.persistence.internal.oxm.mappings.Mapping;
/**
* <P><B>Purpose</B>: XMLMarshalExceptions are raised when issues are encountered
* during XMLMarshaller or XMLUnmarshaller operations.
- * </P>
- */
-public class XMLMarshalException extends ValidationException {
- public static final int INVALID_XPATH_STRING = 25001;
- public static final int INVALID_XPATH_INDEX_STRING = 25002;
- public static final int MARSHAL_EXCEPTION = 25003;
+ * </P>
+ */
+public class XMLMarshalException extends ValidationException {
+ /**
+ * Name parts separator. Used in {@link #missingIDForIDRef(String, Object[])} method to build output string.
+ */
+ private static final String FIELD_SEP = ", ";
+
+ public static final int INVALID_XPATH_STRING = 25001;
+ public static final int INVALID_XPATH_INDEX_STRING = 25002;
+ public static final int MARSHAL_EXCEPTION = 25003;
public static final int UNMARSHAL_EXCEPTION = 25004;
public static final int VALIDATE_EXCEPTION = 25005;
public static final int DEFAULT_ROOT_ELEMENT_NOT_SPECIFIED = 25006;
@@ -424,19 +429,32 @@ public class XMLMarshalException extends ValidationException {
XMLMarshalException exception = new XMLMarshalException(ExceptionMessageGenerator.buildMessage(XMLMarshalException.class, UNMARSHAL_FROM_STRING_FAILED, args));
exception.setInternalException(nestedException);
exception.setErrorCode(PLATFORM_NOT_SUPPORTED_WITH_JSON_MEDIA_TYPE);
- return exception;
- }
-
- public static XMLMarshalException missingIDForIDRef(String classname, Object[] primaryKey) {
- String id = "";
- for(int i=0;i<primaryKey.length; i++){
- id += primaryKey[i];
- if(i < primaryKey.length -1){
- id += ", ";
- }
- }
- Object[] args = {classname, id};
- XMLMarshalException exception = new XMLMarshalException(ExceptionMessageGenerator.buildMessage(XMLMarshalException.class, MISSING_ID_FOR_IDREF, args));
+ return exception;
+ }
+
+ public static XMLMarshalException missingIDForIDRef(String classname, Object[] primaryKey) {
+ String id;
+ if (primaryKey.length > 0) {
+ // Calculate id length
+ int length = 0;
+ length += (primaryKey.length - 1) * FIELD_SEP.length();
+ for (int i=0; i < primaryKey.length; i++) {
+ length += primaryKey[i].toString().length();
+ }
+ // Build id
+ StringBuilder idBuilder = new StringBuilder(length);
+ for (int i=0; i < primaryKey.length; i++) {
+ if (i > 0) {
+ idBuilder.append(FIELD_SEP);
+ }
+ idBuilder.append(primaryKey[i].toString());
+ }
+ id = idBuilder.toString();
+ } else {
+ id = "";
+ }
+ Object[] args = {classname, id};
+ XMLMarshalException exception = new XMLMarshalException(ExceptionMessageGenerator.buildMessage(XMLMarshalException.class, MISSING_ID_FOR_IDREF, args));
exception.setErrorCode(MISSING_ID_FOR_IDREF);
return exception;
}
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/descriptors/DescriptorHelper.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/descriptors/DescriptorHelper.java
new file mode 100644
index 0000000..01d2212
--- /dev/null
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/descriptors/DescriptorHelper.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Tomas Kraus - Initial API and implementation
+ ******************************************************************************/
+package org.eclipse.persistence.internal.descriptors;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.persistence.internal.helper.DatabaseField;
+import org.eclipse.persistence.internal.helper.StringHelper;
+import org.eclipse.persistence.mappings.DatabaseMapping;
+
+/**
+ * <p><b>Purpose</b>: Define any useful static methods to manipulate with descriptors content.</p>
+ */
+public class DescriptorHelper {
+
+ /**
+ * This class is just an envelope for static methods so no instances are allowed.
+ */
+ private DescriptorHelper() {
+ throw new UnsupportedOperationException("Instances of DescriptorHelper are not allowed");
+ }
+
+ /**
+ * Append list of columns from descriptor class to provided {@link StringBuilder}.
+ * Use to create content of columns brackets in <code>INSERT INTO table (col1, col1) VALUES ...</code>.
+ * @param target Target {@link StringBuilder}.
+ * @param mappings Object attributes mappings.
+ * @param separator String to separate values in list.
+ */
+ public static void buildColsFromMappings(final StringBuilder target,
+ final Collection<DatabaseMapping> mappings, final String separator) {
+ for (Iterator<DatabaseMapping> i = mappings.iterator(); i.hasNext(); ) {
+ target.append(i.next().getField().getName());
+ if (i.hasNext()) {
+ target.append(separator);
+ }
+ }
+ }
+
+ /**
+ * Append list of values as list of question marks from descriptor class to provided
+ * {@link StringBuilder}.
+ * Use to create content of <code>VALUES</code> brackets in <code>INSERT INTO table ... VALUES (?, ?) ...</code>.
+ * @param target Target {@link StringBuilder}.
+ * @param mappings Object attributes mappings.
+ * @param separator String to separate values in list.
+ */
+ public static void buildValuesAsQMarksFromMappings(final StringBuilder target,
+ final Collection<DatabaseMapping> mappings, final String separator) {
+ final int count = mappings.size();
+ if (count > 0) {
+ for (int i = 0; i < count; i++) {
+ if (i > 0) {
+ target.append(separator);
+ }
+ target.append(StringHelper.QUESTION_MARK);
+ }
+ }
+ }
+
+ /**
+ * Append list of column to value bindings from descriptor class to provided {@link StringBuilder}.
+ * Use to create value to column bindings of <code>SET</code> content in <code>UPDATE table SET col1 = ?2 WHERE ...</code>
+ * @param target Target {@link StringBuilder}.
+ * @param mappings Object attributes mappings.
+ * @param keys Entity primary key fields.
+ * @param valueIndex First value index in column to value bindings (e.g.
+ * <code>column = ?&gt;valueIndex&gt;</code>).
+ * @param binder String to bind value to column (e.g. <code>" = "</code>
+ * in <code>column = ?&gt;valueIndex&gt;</code>).
+ * @param separator String to separate values in list.
+ */
+ public static void buildColsAndValuesBindingsFromMappings(final StringBuilder target,
+ final Collection<DatabaseMapping> mappings, final Collection<DatabaseField> keys,
+ final int valueIndex, final String binder, final String separator) {
+ int idx = valueIndex;
+ for (Iterator<DatabaseMapping> i = mappings.iterator(); i.hasNext();) {
+ DatabaseMapping mapping = (DatabaseMapping) i.next();
+ DatabaseField field = mapping.getField();
+ if (!keys.contains(field)) {
+ target.append(field.getName()).append(binder).append(Integer.toString(++idx));
+ if (i.hasNext()) {
+ target.append(separator);
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicEntityImpl.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicEntityImpl.java
index 6abfff2..192ffd2 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicEntityImpl.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicEntityImpl.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -242,13 +242,14 @@ public abstract class DynamicEntityImpl implements DynamicEntity, PersistenceEnt
changeListener.propertyChange(new PropertyChangeEvent(this, propertyName,
oldValue, value));
}
- return this;
- }
-
- public class PropertyWrapper {
- private Object value = null;
- private boolean isSet = false;
-
+ return this;
+ }
+
+ // Made static final for performance reasons.
+ public static final class PropertyWrapper {
+ private Object value = null;
+ private boolean isSet = false;
+
/**
* Instantiates a new property wrapper.
*/
@@ -324,13 +325,14 @@ public abstract class DynamicEntityImpl implements DynamicEntity, PersistenceEnt
sb.append(value.toString());
}
return sb.toString();
- }
- }
-
- class UnknownMapping extends DatabaseMapping {
-
- /**
- * Instantiates a new unknown mapping.
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class UnknownMapping extends DatabaseMapping {
+
+ /**
+ * Instantiates a new unknown mapping.
*
* @param propertyName the property name
*/
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicPropertiesManager.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicPropertiesManager.java
index ef7cb43..e826333 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicPropertiesManager.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/dynamic/DynamicPropertiesManager.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -73,13 +73,13 @@ public class DynamicPropertiesManager {
protected void createSlots(DynamicEntityImpl entity) {
Map<String, PropertyWrapper> propertiesMap = entity.getPropertiesMap();
- List<String> propertyNames = getPropertyNames();
- if (propertyNames != null) {
- for (String propertyName : propertyNames) {
- propertiesMap.put(propertyName, entity.new PropertyWrapper());
- }
- }
- }
+ List<String> propertyNames = getPropertyNames();
+ if (propertyNames != null) {
+ for (String propertyName : propertyNames) {
+ propertiesMap.put(propertyName, new PropertyWrapper());
+ }
+ }
+ }
protected void initializeSlotValues(DynamicEntityImpl entity) {
getInitializatonPolicy().initializeProperties((DynamicTypeImpl)type, entity);
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/helper/StringHelper.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/helper/StringHelper.java
new file mode 100644
index 0000000..32c8056
--- /dev/null
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/helper/StringHelper.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Tomas Kraus - Initial API and implementation
+ ******************************************************************************/
+package org.eclipse.persistence.internal.helper;
+
+/**
+ * INTERNAL:
+ * <p><b>Purpose</b>: Define any useful {@link String} constants and methods that are missing from the base Java.</p>
+ */
+public class StringHelper {
+
+ /** Left brace. */
+ public static final char LEFT_BRACE = '{';
+
+ /** Right brace. */
+ public static final char RIGHT_BRACE = '}';
+
+ /** Left bracket. */
+ public static final char LEFT_BRACKET = '(';
+
+ /** Right bracket. */
+ public static final char RIGHT_BRACKET = ')';
+
+ /** Vertical bar. */
+ public static final char VERTICAL_BAR = '|';
+
+ /** Vertical bar. */
+ public static final char QUESTION_MARK = '?';
+
+ /** Empty {@link String}. */
+ public static final String EMPTY_STRING = "";
+
+ /** <code>"null"</code> {@link String}. */
+ public static final String NULL_STRING = "null";
+
+ /**
+ * Never return null but replace it with <code>"null"</code> {@link String}.
+ * @param str String to be checked for null and eventually replaced with
+ * <code>"null"</code> {@link String}.
+ * @return Provided string when not null or <code>"null"</code> {@link String}.
+ */
+ public static final String nonNullString(String str) {
+ return str != null ? str : NULL_STRING;
+ }
+
+}
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/AbstractObjectLevelReadQueryVisitor.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/AbstractObjectLevelReadQueryVisitor.java
index 8387633..4a93f90 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/AbstractObjectLevelReadQueryVisitor.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/AbstractObjectLevelReadQueryVisitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -370,7 +370,7 @@ abstract class AbstractObjectLevelReadQueryVisitor extends AbstractEclipseLinkEx
}
}
- private class CountFunctionVisitor extends EclipseLinkAnonymousExpressionVisitor {
+ private static class CountFunctionVisitor extends EclipseLinkAnonymousExpressionVisitor {
/**
* Determines whether the single {@link org.eclipse.persistence.jpa.jpql.parser.Expression
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/ExpressionBuilderVisitor.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/ExpressionBuilderVisitor.java
index b77271f..4427252 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/ExpressionBuilderVisitor.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/jpql/ExpressionBuilderVisitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -2131,11 +2131,12 @@ final class ExpressionBuilderVisitor implements EclipseLinkExpressionVisitor {
return whenClauseExpressionVisitor;
}
+ // Made static for performance reasons.
/**
* This visitor creates a list by retrieving either the single child or the children of the
* {@link CollectionExpression}, which would be the child.
*/
- private class ChildrenExpressionVisitor extends AnonymousExpressionVisitor {
+ private static class ChildrenExpressionVisitor extends AnonymousExpressionVisitor {
/**
* The list of {@link org.eclipse.persistence.jpa.jpql.parser.Expression Expression} that are
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLLexer.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLLexer.java
index b157636..4fc819e 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLLexer.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLLexer.java
@@ -1,6 +1,18 @@
-// $ANTLR 3.0 JPQL.g 2010-05-03 16:14:54
-
- package org.eclipse.persistence.internal.jpa.parsing.jpql.antlr;
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation from Oracle TopLink
+ ******************************************************************************/
+// $ANTLR 3.0 JPQL.g 2010-05-03 16:14:54
+
+ package org.eclipse.persistence.internal.jpa.parsing.jpql.antlr;
import org.eclipse.persistence.internal.jpa.parsing.jpql.InvalidIdentifierStartException;
@@ -4625,13 +4637,14 @@ public class JPQLLexer extends Lexer {
DFA17_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA17_transition[i] = DFA.unpackEncodedString(DFA17_transitionS[i]);
- }
- }
-
- class DFA17 extends DFA {
-
- public DFA17(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static for performance reasons.
+ static class DFA17 extends DFA {
+
+ public DFA17(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 17;
this.eot = DFA17_eot;
this.eof = DFA17_eof;
@@ -4682,13 +4695,14 @@ public class JPQLLexer extends Lexer {
DFA20_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA20_transition[i] = DFA.unpackEncodedString(DFA20_transitionS[i]);
- }
- }
-
- class DFA20 extends DFA {
-
- public DFA20(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static for performance reasons.
+ static class DFA20 extends DFA {
+
+ public DFA20(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 20;
this.eot = DFA20_eot;
this.eof = DFA20_eof;
@@ -5335,13 +5349,14 @@ public class JPQLLexer extends Lexer {
DFA35_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA35_transition[i] = DFA.unpackEncodedString(DFA35_transitionS[i]);
- }
- }
-
- class DFA35 extends DFA {
-
- public DFA35(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static for performance reasons.
+ static class DFA35 extends DFA {
+
+ public DFA35(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 35;
this.eot = DFA35_eot;
this.eof = DFA35_eof;
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLParser.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLParser.java
index 3a5cc72..e755e38 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLParser.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/jpa/parsing/jpql/antlr/JPQLParser.java
@@ -10,13 +10,13 @@
import org.eclipse.persistence.internal.libraries.antlr.runtime.*;
-
-import java.util.Stack;
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+
+import java.util.Stack;
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -176,12 +176,17 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
/** */
protected boolean aggregatesAllowed() {
- return aggregatesAllowed;
- }
-
- /** */
- protected void validateAbstractSchemaName(Token token)
- throws RecognitionException {
+ return aggregatesAllowed;
+ }
+
+ // State access from DFA classes
+ private final RecognizerSharedState getSharedState() {
+ return state;
+ }
+
+ /** */
+ protected void validateAbstractSchemaName(Token token)
+ throws RecognitionException {
String text = token.getText();
if (!isValidJavaIdentifier(token.getText())) {
throw new InvalidIdentifierException(token);
@@ -8777,21 +8782,40 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
static final char[] DFA10_min = DFA.unpackEncodedStringToUnsignedChars(DFA10_minS);
static final char[] DFA10_max = DFA.unpackEncodedStringToUnsignedChars(DFA10_maxS);
static final short[] DFA10_accept = DFA.unpackEncodedString(DFA10_acceptS);
- static final short[] DFA10_special = DFA.unpackEncodedString(DFA10_specialS);
- static final short[][] DFA10_transition;
-
- static {
- int numStates = DFA10_transitionS.length;
- DFA10_transition = new short[numStates][];
+ static final short[] DFA10_special = DFA.unpackEncodedString(DFA10_specialS);
+ static final short[][] DFA10_transition;
+
+ // Made static for performance reasons.
+ static class DFAParser extends DFA {
+
+ boolean aggregatesAllowed;
+ public DFAParser(JPQLParser recognizer) {
+ this.recognizer = recognizer;
+ }
+ protected final boolean aggregatesAllowed() {
+ return ((JPQLParser)recognizer).aggregatesAllowed();
+ }
+ protected final boolean synpred1_JPQL() {
+ return ((JPQLParser)recognizer).synpred1_JPQL();
+ }
+ protected final RecognizerSharedState getSharedState() {
+ return ((JPQLParser)recognizer).getSharedState();
+ }
+ }
+
+ static {
+ int numStates = DFA10_transitionS.length;
+ DFA10_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA10_transition[i] = DFA.unpackEncodedString(DFA10_transitionS[i]);
- }
- }
-
- class DFA10 extends DFA {
-
- public DFA10(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA10 extends DFA {
+
+ public DFA10(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 10;
this.eot = DFA10_eot;
this.eof = DFA10_eof;
@@ -8882,13 +8906,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA11_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA11_transition[i] = DFA.unpackEncodedString(DFA11_transitionS[i]);
- }
- }
-
- class DFA11 extends DFA {
-
- public DFA11(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA11 extends DFA {
+
+ public DFA11(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 11;
this.eot = DFA11_eot;
this.eof = DFA11_eof;
@@ -8983,13 +9008,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA15_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA15_transition[i] = DFA.unpackEncodedString(DFA15_transitionS[i]);
- }
- }
-
- class DFA15 extends DFA {
-
- public DFA15(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA15 extends DFA {
+
+ public DFA15(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 15;
this.eot = DFA15_eot;
this.eof = DFA15_eof;
@@ -9374,16 +9400,17 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA19_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA19_transition[i] = DFA.unpackEncodedString(DFA19_transitionS[i]);
- }
- }
-
- class DFA19 extends DFA {
-
- public DFA19(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
- this.decisionNumber = 19;
- this.eot = DFA19_eot;
- this.eof = DFA19_eof;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA19 extends DFAParser {
+
+ public DFA19(JPQLParser recognizer) {
+ super(recognizer);
+ this.decisionNumber = 19;
+ this.eot = DFA19_eot;
+ this.eof = DFA19_eof;
this.min = DFA19_min;
this.max = DFA19_max;
this.accept = DFA19_accept;
@@ -12770,13 +12797,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
input.seek(index19_277);
- if ( s>=0 ) return s;
- break;
- }
- if (state.backtracking>0) {state.failed=true; return -1;}
- NoViableAltException nvae =
- new NoViableAltException(getDescription(), 19, _s, input);
- error(nvae);
+ if ( s>=0 ) return s;
+ break;
+ }
+ RecognizerSharedState sharedState = getSharedState();
+ if (sharedState.backtracking>0) {sharedState.failed=true; return -1;}
+ NoViableAltException nvae =
+ new NoViableAltException(getDescription(), 19, _s, input);
+ error(nvae);
throw nvae;
}
}
@@ -12848,13 +12876,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA20_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA20_transition[i] = DFA.unpackEncodedString(DFA20_transitionS[i]);
- }
- }
-
- class DFA20 extends DFA {
-
- public DFA20(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA20 extends DFA {
+
+ public DFA20(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 20;
this.eot = DFA20_eot;
this.eof = DFA20_eof;
@@ -12945,13 +12974,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA22_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA22_transition[i] = DFA.unpackEncodedString(DFA22_transitionS[i]);
- }
- }
-
- class DFA22 extends DFA {
-
- public DFA22(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA22 extends DFA {
+
+ public DFA22(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 22;
this.eot = DFA22_eot;
this.eof = DFA22_eof;
@@ -13042,13 +13072,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA23_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA23_transition[i] = DFA.unpackEncodedString(DFA23_transitionS[i]);
- }
- }
-
- class DFA23 extends DFA {
-
- public DFA23(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA23 extends DFA {
+
+ public DFA23(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 23;
this.eot = DFA23_eot;
this.eof = DFA23_eof;
@@ -13139,13 +13170,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA24_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA24_transition[i] = DFA.unpackEncodedString(DFA24_transitionS[i]);
- }
- }
-
- class DFA24 extends DFA {
-
- public DFA24(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA24 extends DFA {
+
+ public DFA24(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 24;
this.eot = DFA24_eot;
this.eof = DFA24_eof;
@@ -13236,13 +13268,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA25_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA25_transition[i] = DFA.unpackEncodedString(DFA25_transitionS[i]);
- }
- }
-
- class DFA25 extends DFA {
-
- public DFA25(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA25 extends DFA {
+
+ public DFA25(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 25;
this.eot = DFA25_eot;
this.eof = DFA25_eof;
@@ -13333,13 +13366,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA26_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA26_transition[i] = DFA.unpackEncodedString(DFA26_transitionS[i]);
- }
- }
-
- class DFA26 extends DFA {
-
- public DFA26(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA26 extends DFA {
+
+ public DFA26(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 26;
this.eot = DFA26_eot;
this.eof = DFA26_eof;
@@ -13721,16 +13755,17 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA30_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA30_transition[i] = DFA.unpackEncodedString(DFA30_transitionS[i]);
- }
- }
-
- class DFA30 extends DFA {
-
- public DFA30(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
- this.decisionNumber = 30;
- this.eot = DFA30_eot;
- this.eof = DFA30_eof;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA30 extends DFAParser {
+
+ public DFA30(JPQLParser recognizer) {
+ super(recognizer);
+ this.decisionNumber = 30;
+ this.eot = DFA30_eot;
+ this.eof = DFA30_eof;
this.min = DFA30_min;
this.max = DFA30_max;
this.accept = DFA30_accept;
@@ -13748,13 +13783,13 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
int LA30_50 = input.LA(1);
- int index30_50 = input.index();
- input.rewind();
- s = -1;
- if ( (( aggregatesAllowed() )) ) {s = 1;}
-
- else if ( (true) ) {s = 275;}
-
+ int index30_50 = input.index();
+ input.rewind();
+ s = -1;
+ if ( (( this.aggregatesAllowed() )) ) {s = 1;}
+
+ else if ( (true) ) {s = 275;}
+
input.seek(index30_50);
if ( s>=0 ) return s;
@@ -17117,13 +17152,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
input.seek(index30_274);
- if ( s>=0 ) return s;
- break;
- }
- if (state.backtracking>0) {state.failed=true; return -1;}
- NoViableAltException nvae =
- new NoViableAltException(getDescription(), 30, _s, input);
- error(nvae);
+ if ( s>=0 ) return s;
+ break;
+ }
+ RecognizerSharedState sharedState = getSharedState();
+ if (sharedState.backtracking>0) {sharedState.failed=true; return -1;}
+ NoViableAltException nvae =
+ new NoViableAltException(getDescription(), 30, _s, input);
+ error(nvae);
throw nvae;
}
}
@@ -17168,13 +17204,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA33_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA33_transition[i] = DFA.unpackEncodedString(DFA33_transitionS[i]);
- }
- }
-
- class DFA33 extends DFA {
-
- public DFA33(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA33 extends DFA {
+
+ public DFA33(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 33;
this.eot = DFA33_eot;
this.eof = DFA33_eof;
@@ -17232,13 +17269,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA41_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA41_transition[i] = DFA.unpackEncodedString(DFA41_transitionS[i]);
- }
- }
-
- class DFA41 extends DFA {
-
- public DFA41(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA41 extends DFA {
+
+ public DFA41(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 41;
this.eot = DFA41_eot;
this.eof = DFA41_eof;
@@ -17296,13 +17334,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA42_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA42_transition[i] = DFA.unpackEncodedString(DFA42_transitionS[i]);
- }
- }
-
- class DFA42 extends DFA {
-
- public DFA42(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA42 extends DFA {
+
+ public DFA42(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 42;
this.eot = DFA42_eot;
this.eof = DFA42_eof;
@@ -17394,13 +17433,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA45_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA45_transition[i] = DFA.unpackEncodedString(DFA45_transitionS[i]);
- }
- }
-
- class DFA45 extends DFA {
-
- public DFA45(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA45 extends DFA {
+
+ public DFA45(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 45;
this.eot = DFA45_eot;
this.eof = DFA45_eof;
@@ -17491,13 +17531,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA46_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA46_transition[i] = DFA.unpackEncodedString(DFA46_transitionS[i]);
- }
- }
-
- class DFA46 extends DFA {
-
- public DFA46(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA46 extends DFA {
+
+ public DFA46(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 46;
this.eot = DFA46_eot;
this.eof = DFA46_eof;
@@ -17941,16 +17982,17 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA47_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA47_transition[i] = DFA.unpackEncodedString(DFA47_transitionS[i]);
- }
- }
-
- class DFA47 extends DFA {
-
- public DFA47(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
- this.decisionNumber = 47;
- this.eot = DFA47_eot;
- this.eof = DFA47_eof;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA47 extends DFAParser {
+
+ public DFA47(JPQLParser recognizer) {
+ super(recognizer);
+ this.decisionNumber = 47;
+ this.eot = DFA47_eot;
+ this.eof = DFA47_eof;
this.min = DFA47_min;
this.max = DFA47_max;
this.accept = DFA47_accept;
@@ -20454,13 +20496,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
input.seek(index47_319);
- if ( s>=0 ) return s;
- break;
- }
- if (state.backtracking>0) {state.failed=true; return -1;}
- NoViableAltException nvae =
- new NoViableAltException(getDescription(), 47, _s, input);
- error(nvae);
+ if ( s>=0 ) return s;
+ break;
+ }
+ RecognizerSharedState sharedState = getSharedState();
+ if (sharedState.backtracking>0) {sharedState.failed=true; return -1;}
+ NoViableAltException nvae =
+ new NoViableAltException(getDescription(), 47, _s, input);
+ error(nvae);
throw nvae;
}
}
@@ -20541,13 +20584,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA48_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA48_transition[i] = DFA.unpackEncodedString(DFA48_transitionS[i]);
- }
- }
-
- class DFA48 extends DFA {
-
- public DFA48(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA48 extends DFA {
+
+ public DFA48(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 48;
this.eot = DFA48_eot;
this.eof = DFA48_eof;
@@ -20603,13 +20647,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA51_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA51_transition[i] = DFA.unpackEncodedString(DFA51_transitionS[i]);
- }
- }
-
- class DFA51 extends DFA {
-
- public DFA51(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA51 extends DFA {
+
+ public DFA51(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 51;
this.eot = DFA51_eot;
this.eof = DFA51_eof;
@@ -20700,13 +20745,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA55_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA55_transition[i] = DFA.unpackEncodedString(DFA55_transitionS[i]);
- }
- }
-
- class DFA55 extends DFA {
-
- public DFA55(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA55 extends DFA {
+
+ public DFA55(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 55;
this.eot = DFA55_eot;
this.eof = DFA55_eof;
@@ -20759,13 +20805,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA57_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA57_transition[i] = DFA.unpackEncodedString(DFA57_transitionS[i]);
- }
- }
-
- class DFA57 extends DFA {
-
- public DFA57(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA57 extends DFA {
+
+ public DFA57(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 57;
this.eot = DFA57_eot;
this.eof = DFA57_eof;
@@ -20859,13 +20906,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA60_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA60_transition[i] = DFA.unpackEncodedString(DFA60_transitionS[i]);
- }
- }
-
- class DFA60 extends DFA {
-
- public DFA60(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA60 extends DFA {
+
+ public DFA60(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 60;
this.eot = DFA60_eot;
this.eof = DFA60_eof;
@@ -20972,13 +21020,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA61_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA61_transition[i] = DFA.unpackEncodedString(DFA61_transitionS[i]);
- }
- }
-
- class DFA61 extends DFA {
-
- public DFA61(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA61 extends DFA {
+
+ public DFA61(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 61;
this.eot = DFA61_eot;
this.eof = DFA61_eof;
@@ -21057,13 +21106,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA62_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA62_transition[i] = DFA.unpackEncodedString(DFA62_transitionS[i]);
- }
- }
-
- class DFA62 extends DFA {
-
- public DFA62(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA62 extends DFA {
+
+ public DFA62(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 62;
this.eot = DFA62_eot;
this.eof = DFA62_eof;
@@ -21144,13 +21194,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA63_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA63_transition[i] = DFA.unpackEncodedString(DFA63_transitionS[i]);
- }
- }
-
- class DFA63 extends DFA {
-
- public DFA63(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA63 extends DFA {
+
+ public DFA63(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 63;
this.eot = DFA63_eot;
this.eof = DFA63_eof;
@@ -21224,13 +21275,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA64_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA64_transition[i] = DFA.unpackEncodedString(DFA64_transitionS[i]);
- }
- }
-
- class DFA64 extends DFA {
-
- public DFA64(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA64 extends DFA {
+
+ public DFA64(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 64;
this.eot = DFA64_eot;
this.eof = DFA64_eof;
@@ -21304,13 +21356,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA65_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA65_transition[i] = DFA.unpackEncodedString(DFA65_transitionS[i]);
- }
- }
-
- class DFA65 extends DFA {
-
- public DFA65(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA65 extends DFA {
+
+ public DFA65(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 65;
this.eot = DFA65_eot;
this.eof = DFA65_eof;
@@ -21401,13 +21454,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA66_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA66_transition[i] = DFA.unpackEncodedString(DFA66_transitionS[i]);
- }
- }
-
- class DFA66 extends DFA {
-
- public DFA66(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA66 extends DFA {
+
+ public DFA66(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 66;
this.eot = DFA66_eot;
this.eof = DFA66_eof;
@@ -21498,13 +21552,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA67_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA67_transition[i] = DFA.unpackEncodedString(DFA67_transitionS[i]);
- }
- }
-
- class DFA67 extends DFA {
-
- public DFA67(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA67 extends DFA {
+
+ public DFA67(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 67;
this.eot = DFA67_eot;
this.eof = DFA67_eof;
@@ -21565,13 +21620,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA68_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA68_transition[i] = DFA.unpackEncodedString(DFA68_transitionS[i]);
- }
- }
-
- class DFA68 extends DFA {
-
- public DFA68(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA68 extends DFA {
+
+ public DFA68(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 68;
this.eot = DFA68_eot;
this.eof = DFA68_eof;
@@ -21627,13 +21683,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA77_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA77_transition[i] = DFA.unpackEncodedString(DFA77_transitionS[i]);
- }
- }
-
- class DFA77 extends DFA {
-
- public DFA77(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA77 extends DFA {
+
+ public DFA77(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 77;
this.eot = DFA77_eot;
this.eof = DFA77_eof;
@@ -21702,13 +21759,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA89_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA89_transition[i] = DFA.unpackEncodedString(DFA89_transitionS[i]);
- }
- }
-
- class DFA89 extends DFA {
-
- public DFA89(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA89 extends DFA {
+
+ public DFA89(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 89;
this.eot = DFA89_eot;
this.eof = DFA89_eof;
@@ -21761,13 +21819,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA97_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA97_transition[i] = DFA.unpackEncodedString(DFA97_transitionS[i]);
- }
- }
-
- class DFA97 extends DFA {
-
- public DFA97(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA97 extends DFA {
+
+ public DFA97(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 97;
this.eot = DFA97_eot;
this.eof = DFA97_eof;
@@ -21821,13 +21880,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA98_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA98_transition[i] = DFA.unpackEncodedString(DFA98_transitionS[i]);
- }
- }
-
- class DFA98 extends DFA {
-
- public DFA98(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA98 extends DFA {
+
+ public DFA98(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 98;
this.eot = DFA98_eot;
this.eof = DFA98_eof;
@@ -21887,13 +21947,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA102_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA102_transition[i] = DFA.unpackEncodedString(DFA102_transitionS[i]);
- }
- }
-
- class DFA102 extends DFA {
-
- public DFA102(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA102 extends DFA {
+
+ public DFA102(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 102;
this.eot = DFA102_eot;
this.eof = DFA102_eof;
@@ -21946,13 +22007,14 @@ public class JPQLParser extends org.eclipse.persistence.internal.jpa.parsing.jpq
DFA101_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA101_transition[i] = DFA.unpackEncodedString(DFA101_transitionS[i]);
- }
- }
-
- class DFA101 extends DFA {
-
- public DFA101(BaseRecognizer recognizer) {
- this.recognizer = recognizer;
+ }
+ }
+
+ // Made static final for performance reasons.
+ static final class DFA101 extends DFA {
+
+ public DFA101(BaseRecognizer recognizer) {
+ this.recognizer = recognizer;
this.decisionNumber = 101;
this.eot = DFA101_eot;
this.eof = DFA101_eof;
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/ReferenceResolver.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/ReferenceResolver.java
index a20e06b..e96cbb0 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/ReferenceResolver.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/ReferenceResolver.java
@@ -383,13 +383,14 @@ public class ReferenceResolver {
if(null != keyToObject) {
return keyToObject.get(primaryKey);
}
- return null;
- }
-
- private class ReferenceKey {
- private Object sourceObject;
- private Mapping mapping;
-
+ return null;
+ }
+
+ // Made static final for performance reasons.
+ private static final class ReferenceKey {
+ private Object sourceObject;
+ private Mapping mapping;
+
public ReferenceKey(Object sourceObject, Mapping mapping) {
this.sourceObject = sourceObject;
this.mapping = mapping;
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLBinaryDataHelper.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLBinaryDataHelper.java
index 7eec8a5..db33d6f 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLBinaryDataHelper.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLBinaryDataHelper.java
@@ -415,12 +415,13 @@ public class XMLBinaryDataHelper {
return null;
}
+ // Made static final for performance reasons.
/**
* INTERNAL
* @author mmacivor
*
*/
- public class EncodedData {
+ public static final class EncodedData {
private byte[] data;
private String mimeType;
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/DOMReader.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/DOMReader.java
index 75792a3..7df3f86 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/DOMReader.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/DOMReader.java
@@ -371,14 +371,15 @@ public class DOMReader extends XMLReaderAdapter {
this.contentHandler.setDocumentLocator(locator);
}
+ // Made static final for performance reasons.
/**
- * Implementation of Attributes - used to pass along a given node's attributes
- * to the startElement method of the reader's content handler.
- */
- protected class IndexedAttributeList implements org.xml.sax.Attributes {
-
- private List<Attr> attrs;
-
+ * Implementation of Attributes - used to pass along a given node's attributes
+ * to the startElement method of the reader's content handler.
+ */
+ protected static final class IndexedAttributeList implements org.xml.sax.Attributes {
+
+ private List<Attr> attrs;
+
public IndexedAttributeList() {
attrs = new ArrayList();
}
@@ -490,13 +491,14 @@ public class DOMReader extends XMLReaderAdapter {
}
}
return null;
- }
- }
-
- protected class LocatorImpl implements Locator2 {
-
- private String encoding;
- private String version;
+ }
+ }
+
+ // Made static final for performance reasons.
+ protected static final class LocatorImpl implements Locator2 {
+
+ private String encoding;
+ private String version;
public LocatorImpl() {
encoding = "UTF-8";
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLEventReaderReader.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLEventReaderReader.java
index 1f0f3fc..a19ae0d 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLEventReaderReader.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLEventReaderReader.java
@@ -202,7 +202,8 @@ public class XMLEventReaderReader extends XMLReaderAdapter {
}
}
- private static class XMLEventReaderAttributes extends IndexedAttributeList {
+ // Made static final for performance reasons.
+ private static final class XMLEventReaderAttributes extends IndexedAttributeList {
private Iterator namespaces;
private Iterator attrs;
@@ -261,13 +262,14 @@ public class XMLEventReaderReader extends XMLReaderAdapter {
}
+ // Made static final for performance reasons.
/**
* <p>An implementation of Locator, with location data provided by an existing XMLEvent.</p>
*
* @see org.xml.sax.Locator
* @see javax.xml.stream.events.XMLEvent
*/
- private class EventReaderLocator implements Locator2 {
+ private static final class EventReaderLocator implements Locator2 {
private XMLEvent event;
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLStreamReaderReader.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLStreamReaderReader.java
index 97abd9d..358ffa6 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLStreamReaderReader.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/XMLStreamReaderReader.java
@@ -279,16 +279,17 @@ public class XMLStreamReaderReader extends XMLReaderAdapter {
}
+ // Made static for performance reasons.
/**
* <p>An implementation of Locator, created from an existing XMLStreamReader.</p>
*
- * @see org.xml.sax.Locator
- * @see javax.xml.stream.XMLStreamReader
- */
- private class StreamReaderLocator implements Locator2 {
-
- private XMLStreamReader reader;
-
+ * @see org.xml.sax.Locator
+ * @see javax.xml.stream.XMLStreamReader
+ */
+ private static class StreamReaderLocator implements Locator2 {
+
+ private XMLStreamReader reader;
+
/**
* Instantiates a new StreamReaderLocator.
*
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/deferred/DeferredContentHandler.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/deferred/DeferredContentHandler.java
index 84f6d32..9301f79 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/deferred/DeferredContentHandler.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/record/deferred/DeferredContentHandler.java
@@ -221,14 +221,15 @@ public abstract class DeferredContentHandler implements ExtendedContentHandler,
return events;
}
+ // Made static final for performance reasons.
/**
- * Implementation of Attributes - used to pass along a given node's attributes
- * to the startElement method of the reader's content handler.
- */
- public class AttributeList implements org.xml.sax.Attributes {
-
- private String[] localNames;
- private String[] uris;
+ * Implementation of Attributes - used to pass along a given node's attributes
+ * to the startElement method of the reader's content handler.
+ */
+ private static final class AttributeList implements org.xml.sax.Attributes {
+
+ private String[] localNames;
+ private String[] uris;
private String[] values;
private String[] types;
private ArrayList<String> qNames;
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/SecurableObjectHolder.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/SecurableObjectHolder.java
index 59e6384..aecfa48 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/SecurableObjectHolder.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/security/SecurableObjectHolder.java
@@ -105,16 +105,17 @@ public class SecurableObjectHolder {
}
}
+ // Made static final for performance reasons.
/*
* If we default to JCE and the initialization fails, our fall back is to do
* no encryption. This covers the case where the user is running against JDK 1.3
- * At runtime, no encryption will be made and the passwords will be assummed to
- * be clear text.
- */
- private class PassThroughEncryptor implements Securable {
- public String encryptPassword(String pswd) {
- return pswd;
- }
+ * At runtime, no encryption will be made and the passwords will be assummed to
+ * be clear text.
+ */
+ private static final class PassThroughEncryptor implements Securable {
+ public String encryptPassword(String pswd) {
+ return pswd;
+ }
public String decryptPassword(String encryptedPswd) {
return encryptedPswd;
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/ObjectPersistenceRuntimeXMLProject_11_1_1.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/ObjectPersistenceRuntimeXMLProject_11_1_1.java
index a491f97..ab73a48 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/ObjectPersistenceRuntimeXMLProject_11_1_1.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/ObjectPersistenceRuntimeXMLProject_11_1_1.java
@@ -845,13 +845,15 @@ public class ObjectPersistenceRuntimeXMLProject_11_1_1 extends ObjectPersistence
enum StoredProcedureArgumentType {
STORED_PROCEDURE_ARG,
STORED_PROCEDURE_INOUT_ARG,
- STORED_PROCEDURE_OUT_ARG,
- STORED_PROCEDURE_OUTCURSOR_ARG
- }
- class StoredProcedureArgumentInstantiationPolicy extends InstantiationPolicy {
- ObjectPersistenceRuntimeXMLProject_11_1_1 outer;
- StoredProcedureArgumentType argType;
- StoredProcedureArgumentInstantiationPolicy(
+ STORED_PROCEDURE_OUT_ARG,
+ STORED_PROCEDURE_OUTCURSOR_ARG
+ }
+
+ // Made static for performance reasons.
+ static class StoredProcedureArgumentInstantiationPolicy extends InstantiationPolicy {
+ ObjectPersistenceRuntimeXMLProject_11_1_1 outer;
+ StoredProcedureArgumentType argType;
+ StoredProcedureArgumentInstantiationPolicy(
ObjectPersistenceRuntimeXMLProject_11_1_1 outer, StoredProcedureArgumentType argType) {
this.outer = outer;
this.argType = argType;
@@ -1386,15 +1388,16 @@ public class ObjectPersistenceRuntimeXMLProject_11_1_1 extends ObjectPersistence
return aDescriptor;
}
+ // Made static for performance reasons.
/**
* INTERNAL:
- * Wrap the isset parameter object array as a Collection.
- * Prerequisite: parameterTypes must be set.
- */
- public class IsSetNullPolicyIsSetParametersAttributeAccessor extends AttributeAccessor {
- public IsSetNullPolicyIsSetParametersAttributeAccessor() {
- super();
- }
+ * Wrap the isset parameter object array as a Collection.
+ * Prerequisite: parameterTypes must be set.
+ */
+ public static class IsSetNullPolicyIsSetParametersAttributeAccessor extends AttributeAccessor {
+ public IsSetNullPolicyIsSetParametersAttributeAccessor() {
+ super();
+ }
@Override
public Object getAttributeValueFromObject(Object object) throws DescriptorException {
@@ -1425,14 +1428,15 @@ public class ObjectPersistenceRuntimeXMLProject_11_1_1 extends ObjectPersistence
}
}
+ // Made static for performance reasons.
/**
- * INTERNAL:
- * Wrap the isset parameterType class array as a Collection
- */
- public class IsSetNullPolicyIsSetParameterTypesAttributeAccessor extends AttributeAccessor {
- public IsSetNullPolicyIsSetParameterTypesAttributeAccessor() {
- super();
- }
+ * INTERNAL:
+ * Wrap the isset parameterType class array as a Collection
+ */
+ public static class IsSetNullPolicyIsSetParameterTypesAttributeAccessor extends AttributeAccessor {
+ public IsSetNullPolicyIsSetParameterTypesAttributeAccessor() {
+ super();
+ }
@Override
public Object getAttributeValueFromObject(Object object) throws DescriptorException {
@@ -1482,14 +1486,15 @@ public class ObjectPersistenceRuntimeXMLProject_11_1_1 extends ObjectPersistence
return descriptor;
}
+ // Made static for performance reasons.
/**
- * INTERNAL:
- * If the policy is the default NullPolicy with defaults set - then represent this default policy by null.
- */
- public class NullPolicyAttributeAccessor extends AttributeAccessor {
-
- public NullPolicyAttributeAccessor() {
- super();
+ * INTERNAL:
+ * If the policy is the default NullPolicy with defaults set - then represent this default policy by null.
+ */
+ public static class NullPolicyAttributeAccessor extends AttributeAccessor {
+
+ public NullPolicyAttributeAccessor() {
+ super();
}
@Override
@@ -1776,14 +1781,16 @@ public class ObjectPersistenceRuntimeXMLProject_11_1_1 extends ObjectPersistence
return descriptor;
}
+
+ // Made static for performance reasons.
/**
- * Instantiation policy for ObjectTypeFieldAssociation class. This policy
- * enables the default constructor of the inner class to be accessed.
- */
- class ObjectTypeFieldAssociationInstantiationPolicy extends InstantiationPolicy {
- ObjectPersistenceRuntimeXMLProject_11_1_1 outer;
- ObjectTypeFieldAssociationInstantiationPolicy(
- ObjectPersistenceRuntimeXMLProject_11_1_1 outer) {
+ * Instantiation policy for ObjectTypeFieldAssociation class. This policy
+ * enables the default constructor of the inner class to be accessed.
+ */
+ static class ObjectTypeFieldAssociationInstantiationPolicy extends InstantiationPolicy {
+ ObjectPersistenceRuntimeXMLProject_11_1_1 outer;
+ ObjectTypeFieldAssociationInstantiationPolicy(
+ ObjectPersistenceRuntimeXMLProject_11_1_1 outer) {
this.outer = outer;
}
@Override
@@ -2027,13 +2034,14 @@ public class ObjectPersistenceRuntimeXMLProject_11_1_1 extends ObjectPersistence
descriptor.getInheritancePolicy().addClassIndicator(ObjectRelationalDatabaseField.class,
getPrimaryNamespaceXPath() + "object-relational-field");
- return descriptor;
- }
-
- class ObjectRelationalDatabaseFieldInstantiationPolicy extends InstantiationPolicy {
-
- ObjectRelationalDatabaseFieldInstantiationPolicy() {
- }
+ return descriptor;
+ }
+
+ // Made static for performance reasons.
+ static class ObjectRelationalDatabaseFieldInstantiationPolicy extends InstantiationPolicy {
+
+ ObjectRelationalDatabaseFieldInstantiationPolicy() {
+ }
@Override
public Object buildNewInstance() throws DescriptorException {
return new ObjectRelationalDatabaseField("");
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/XMLDescriptor.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/XMLDescriptor.java
index 004033e..0f25184 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/XMLDescriptor.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/XMLDescriptor.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -69,12 +69,18 @@ import org.eclipse.persistence.queries.DoesExistQuery;
* by an XML schema document (XSD). Using XML descriptors in an EclipseLink XML project, you can configure XML mappings.
*
* @see org.eclipse.persistence.oxm.mappings
- */
-public class XMLDescriptor extends ClassDescriptor implements Descriptor<AttributeAccessor, DatabaseMapping, DatabaseField, InheritancePolicy, InstantiationPolicy, NamespaceResolver, ObjectBuilder, DatabaseTable, UnmarshalRecord, XMLUnmarshaller>{
-
- private static final Vector EMPTY_VECTOR = NonSynchronizedVector.newInstance(1);
-
- private NamespaceResolver namespaceResolver;
+ */
+public class XMLDescriptor extends ClassDescriptor implements Descriptor<AttributeAccessor, DatabaseMapping, DatabaseField, InheritancePolicy, InstantiationPolicy, NamespaceResolver, ObjectBuilder, DatabaseTable, UnmarshalRecord, XMLUnmarshaller>{
+
+ /*
+ * Character used to separate individual xPath elements.
+ * TODO: Use some global value reference.
+ */
+ private static final char XPATH_FRAGMENT_SEPARATOR = '/';
+
+ private static final Vector EMPTY_VECTOR = NonSynchronizedVector.newInstance(1);
+
+ private NamespaceResolver namespaceResolver;
private XMLSchemaReference schemaReference;
private boolean shouldPreserveDocument = false;
private XMLField defaultRootElementField;
@@ -1022,36 +1028,36 @@ public class XMLDescriptor extends ClassDescriptor implements Descriptor<Attribu
@Override
public DatabaseField getTypedField(DatabaseField field) {
XMLField foundField = (XMLField) super.getTypedField(field);
- if(null != foundField) {
- return foundField;
- }
- StringTokenizer stringTokenizer = new StringTokenizer(field.getName(), "/");
- DatabaseField typedField = getTypedField(stringTokenizer);
- if(null == typedField) {
- DatabaseMapping selfMapping = objectBuilder.getMappingForField(new XMLField("."));
+ if(null != foundField) {
+ return foundField;
+ }
+ StringTokenizer stringTokenizer = new StringTokenizer(field.getName(), String.valueOf(XPATH_FRAGMENT_SEPARATOR));
+ DatabaseField typedField = getTypedField(stringTokenizer);
+ if(null == typedField) {
+ DatabaseMapping selfMapping = objectBuilder.getMappingForField(new XMLField("."));
if(null != selfMapping) {
return selfMapping.getReferenceDescriptor().getTypedField(field);
}
}
return typedField;
- }
-
- protected DatabaseField getTypedField(StringTokenizer stringTokenizer) {
- String xPath = "";
- XMLField xmlField = new XMLField();
- xmlField.setNamespaceResolver(namespaceResolver);
- while(stringTokenizer.hasMoreElements()) {
- String nextToken = stringTokenizer.nextToken();
- xmlField.setXPath(xPath + nextToken);
- xmlField.initialize();
- DatabaseMapping mapping = objectBuilder.getMappingForField(xmlField);
- if(null == mapping) {
- XPathFragment xPathFragment = new XPathFragment(nextToken);
- if(xPathFragment.getIndexValue() > 0) {
- xmlField.setXPath(xPath + nextToken.substring(0, nextToken.indexOf('[')));
- xmlField.initialize();
- mapping = objectBuilder.getMappingForField(xmlField);
- if(null != mapping) {
+ }
+
+ protected DatabaseField getTypedField(StringTokenizer stringTokenizer) {
+ StringBuilder xPath = new StringBuilder();
+ XMLField xmlField = new XMLField();
+ xmlField.setNamespaceResolver(namespaceResolver);
+ while(stringTokenizer.hasMoreElements()) {
+ String nextToken = stringTokenizer.nextToken();
+ xmlField.setXPath(xPath.toString() + nextToken);
+ xmlField.initialize();
+ DatabaseMapping mapping = objectBuilder.getMappingForField(xmlField);
+ if(null == mapping) {
+ XPathFragment xPathFragment = new XPathFragment(nextToken);
+ if(xPathFragment.getIndexValue() > 0) {
+ xmlField.setXPath(xPath.toString() + nextToken.substring(0, nextToken.indexOf('[')));
+ xmlField.initialize();
+ mapping = objectBuilder.getMappingForField(xmlField);
+ if(null != mapping) {
if(mapping.isCollectionMapping()) {
if(mapping.getContainerPolicy().isListPolicy()) {
if(stringTokenizer.hasMoreElements()) {
@@ -1067,13 +1073,13 @@ public class XMLDescriptor extends ClassDescriptor implements Descriptor<Attribu
if(stringTokenizer.hasMoreElements()) {
return ((XMLDescriptor) mapping.getReferenceDescriptor()).getTypedField(stringTokenizer);
} else {
- return mapping.getField();
- }
- }
- xPath = xPath + nextToken + "/";
- }
- return null;
- }
+ return mapping.getField();
+ }
+ }
+ xPath = xPath.append(nextToken).append(XPATH_FRAGMENT_SEPARATOR);
+ }
+ return null;
+ }
/**
* INTERNAL:
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/oracle/plsql/PLSQLStoredProcedureCall.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/oracle/plsql/PLSQLStoredProcedureCall.java
index 7460ed7..6b078a2 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/oracle/plsql/PLSQLStoredProcedureCall.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/oracle/plsql/PLSQLStoredProcedureCall.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -1193,14 +1193,15 @@ public class PLSQLStoredProcedureCall extends StoredProcedureCall {
return inArgs;
}
+ // Made static for performance reasons.
/**
- * INTERNAL:
- * Helper structure used to store the PLSQL type conversion routines.
- */
- class TypeInfo {
- String sql2PlName;
- String sql2PlConv;
- String pl2SqlName;
+ * INTERNAL:
+ * Helper structure used to store the PLSQL type conversion routines.
+ */
+ static final class TypeInfo {
+ String sql2PlName;
+ String sql2PlConv;
+ String pl2SqlName;
String pl2SqlConv;
@Override
public String toString() {
@@ -1258,15 +1259,16 @@ public class PLSQLStoredProcedureCall extends StoredProcedureCall {
this.arguments = arguments;
}
+ // Made static final for performance reasons.
/**
* Class responsible for comparing PLSQLargument instances based on
- * the inIndex property.
- *
- */
- static class InArgComparer implements Comparator<PLSQLargument> {
- @Override
- public int compare(PLSQLargument arg0, PLSQLargument arg1) {
- if (arg0.inIndex < arg1.inIndex) {
+ * the inIndex property.
+ *
+ */
+ static final class InArgComparer implements Comparator<PLSQLargument> {
+ @Override
+ public int compare(PLSQLargument arg0, PLSQLargument arg1) {
+ if (arg0.inIndex < arg1.inIndex) {
return -1;
}
if (arg0.inIndex > arg1.inIndex) {
@@ -1276,15 +1278,16 @@ public class PLSQLStoredProcedureCall extends StoredProcedureCall {
}
}
+ // Made static final for performance reasons.
/**
* Class responsible for comparing PLSQLargument instances based on
- * the outIndex property.
- *
- */
- static class OutArgComparer implements Comparator<PLSQLargument> {
- @Override
- public int compare(PLSQLargument arg0, PLSQLargument arg1) {
- if (arg0.inIndex < arg1.outIndex) {
+ * the outIndex property.
+ *
+ */
+ static final class OutArgComparer implements Comparator<PLSQLargument> {
+ @Override
+ public int compare(PLSQLargument arg0, PLSQLargument arg1) {
+ if (arg0.inIndex < arg1.outIndex) {
return -1;
}
if (arg0.inIndex > arg1.outIndex) {
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ConstructorReportItem.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ConstructorReportItem.java
index cd2d923..4c57571 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ConstructorReportItem.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ConstructorReportItem.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -21,12 +21,13 @@ import java.security.PrivilegedActionException;
import org.eclipse.persistence.exceptions.QueryException;
import org.eclipse.persistence.expressions.Expression;
-import org.eclipse.persistence.internal.expressions.ConstantExpression;
-import org.eclipse.persistence.internal.expressions.MapEntryExpression;
-import org.eclipse.persistence.internal.helper.ClassConstants;
-import org.eclipse.persistence.internal.queries.ReportItem;
-import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
-import org.eclipse.persistence.internal.security.PrivilegedGetConstructorFor;
+import org.eclipse.persistence.internal.expressions.ConstantExpression;
+import org.eclipse.persistence.internal.expressions.MapEntryExpression;
+import org.eclipse.persistence.internal.helper.ClassConstants;
+import org.eclipse.persistence.internal.helper.StringHelper;
+import org.eclipse.persistence.internal.queries.ReportItem;
+import org.eclipse.persistence.internal.security.PrivilegedAccessHelper;
+import org.eclipse.persistence.internal.security.PrivilegedGetConstructorFor;
import org.eclipse.persistence.mappings.CollectionMapping;
import org.eclipse.persistence.mappings.DatabaseMapping;
@@ -46,12 +47,27 @@ import org.eclipse.persistence.mappings.DatabaseMapping;
*
* @author Chris Delahunt
* @since TopLink Essentials 1.0
- */
-public class ConstructorReportItem extends ReportItem {
-
- protected Class[] constructorArgTypes;
- protected List constructorMappings;
- protected List reportItems;
+ */
+public class ConstructorReportItem extends ReportItem {
+
+ /**
+ * String prefix of {@link #toString()} output.
+ */
+ private static final String TO_STR_PREFIX = "ConstructorReportItem(";
+
+ /**
+ * String to separate name and items array of {@link #toString()} output.
+ */
+ private static final String TO_STR_ARRAY = " -> [";
+
+ /**
+ * String suffix of {@link #toString()} output.
+ */
+ private static final String TO_STR_SUFFIX = "])";
+
+ protected Class[] constructorArgTypes;
+ protected List constructorMappings;
+ protected List reportItems;
protected Constructor constructor;
/**
@@ -206,20 +222,29 @@ public class ConstructorReportItem extends ReportItem {
this.constructorMappings = constructorMappings;
}
- public void setReportItems(List reportItems){
- this.reportItems = reportItems;
- }
-
- public String toString() {
- String string = "ConstructorReportItem(" + getName() + " -> [";
- //don't use getReportItems to avoid creating collection.
- if (reportItems!=null){
- int size=reportItems.size();
- for(int i=0;i<size;i++){
- string =string + reportItems.get(i).toString();
- }
- }
- return string +"])";
- }
-
-}
+ public void setReportItems(List reportItems){
+ this.reportItems = reportItems;
+ }
+
+ public String toString() {
+ String name = StringHelper.nonNullString(getName());
+ // Calculate string length
+ int length = TO_STR_PREFIX.length() + name.length()
+ + TO_STR_ARRAY.length() + TO_STR_SUFFIX.length();
+ int size = reportItems != null ? reportItems.size() : 0;
+ String[] items = new String[size];
+ for (int i=0; i < size; i++) {
+ items[i] = StringHelper.nonNullString(reportItems.get(i).toString());
+ length += items[i].length();
+ }
+ // Build string
+ StringBuilder str = new StringBuilder(length);
+ str.append(TO_STR_PREFIX).append(name).append(TO_STR_ARRAY);
+ for (int i=0; i < size; i++) {
+ str.append(items[i]);
+ }
+ str.append(TO_STR_SUFFIX);
+ return str.toString();
+ }
+
+}
diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/tools/PackageRenamer.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/tools/PackageRenamer.java
index 49b4e88..33e4f99 100644
--- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/tools/PackageRenamer.java
+++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/tools/PackageRenamer.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -627,12 +627,13 @@ public class PackageRenamer {
System.out.println("\t<log-file> - The logging of the renaming process will be written");
System.out.println("\tto the <log-file>. If no <log-file> is specified then logging");
System.out.println("\twill be written to standard output.");
- System.out.println("");
- }
-
- public class PackageRenamerException extends RuntimeException {
- public PackageRenamerException(String aMessage) {
- super(aMessage);
- }
+ System.out.println("");
+ }
+
+ // Made static final for performance reasons.
+ public static final class PackageRenamerException extends RuntimeException {
+ public PackageRenamerException(String aMessage) {
+ super(aMessage);
+ }
}
}
diff --git a/foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/CopyBookParser.java b/foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/CopyBookParser.java
index d202a20..f974709 100644
--- a/foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/CopyBookParser.java
+++ b/foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/CopyBookParser.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2012 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -374,23 +374,23 @@ public class CopyBookParser {
int size = 0;
while (index < length) {
- char currentChar = picChars[index];
- switch (currentChar) {
- case '(':
- String number = new String();
- index++;
- size--;
- currentChar = picChars[index];
- while ((index < length) && (currentChar != ')')) {
- number += currentChar;
- index++;
- currentChar = picChars[index];
- }
- try {
- Integer value = Integer.valueOf(number);
- size += value.intValue();
- } catch (NumberFormatException exception) {
- throw invalidCopyBookException("In pic statement a valid integer must be enclosed by the parenthesis.", exception);
+ char currentChar = picChars[index];
+ switch (currentChar) {
+ case '(':
+ StringBuilder number = new StringBuilder();
+ index++;
+ size--;
+ currentChar = picChars[index];
+ while ((index < length) && (currentChar != ')')) {
+ number.append(currentChar);
+ index++;
+ currentChar = picChars[index];
+ }
+ try {
+ Integer value = Integer.valueOf(number.toString());
+ size += value.intValue();
+ } catch (NumberFormatException exception) {
+ throw invalidCopyBookException("In pic statement a valid integer must be enclosed by the parenthesis.", exception);
}
if (currentChar == ')') {
index++;
diff --git a/foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/helper/ByteConverter.java b/foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/helper/ByteConverter.java
index 6dc6c25..41076bc 100644
--- a/foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/helper/ByteConverter.java
+++ b/foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/internal/eis/cobol/helper/ByteConverter.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2012 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -221,53 +221,51 @@ public class ByteConverter {
/**
* this method builds a string value from a byte array containing packed-decimal data
*/
- protected String getStringValueFromPackedDecimal() {
- int mask = 0xf0;
- boolean signed = this.getFieldMetaData().isSigned();
- String sign = new String();
- int offset = this.getFieldMetaData().getOffset();
- int size = this.getFieldMetaData().getSize();
- String value = new String();
- int position = 0;
-
- //determine the sign if there is one
- if (signed) {
- byte signBits = (byte)(myRecordData[(offset + size) - 1] | mask);
- if (signBits == 0x0d) {
- sign = "-";
- } else if (signBits == 0x0c) {
- sign = "+";
- }
- }
-
- String stringValue;
-
- //build hex string
- for (int i = offset; i < (offset + size); i++) {
- stringValue = Integer.toHexString(Helper.intFromByte(myRecordData[i]));
- //added to handle strange behavior of toHexString method with negative numbers
- if (stringValue.length() > 2) {
- stringValue = stringValue.substring(stringValue.length() - 2);
- }
- value += stringValue;
- }
-
- //count leading zeros
- while (value.charAt(position) == '0') {
- position++;
- }
-
- //remove sign bits and leading zeros
- value = value.substring(position, value.length() - 1);
-
- if (signed) {
- return sign + value;
- } else {
- return value;
- }
- }
-
- /**
+ protected String getStringValueFromPackedDecimal() {
+ int mask = 0xf0;
+ boolean signed = this.getFieldMetaData().isSigned();
+ String sign = "";
+ int offset = this.getFieldMetaData().getOffset();
+ int size = this.getFieldMetaData().getSize();
+ StringBuilder value = new StringBuilder();
+ int position = 0;
+
+ // Determine the sign if there is one
+ if (signed) {
+ byte signBits = (byte)(myRecordData[(offset + size) - 1] | mask);
+ if (signBits == 0x0d) {
+ sign = String.valueOf('-');
+ } else if (signBits == 0x0c) {
+ sign = String.valueOf('+');
+ }
+ }
+
+ String stringValue;
+
+ // Build hex string
+ for (int i = offset; i < (offset + size); i++) {
+ stringValue = Integer.toHexString(Helper.intFromByte(myRecordData[i]));
+ // Added to handle strange behavior of toHexString method with negative numbers
+ if (stringValue.length() > 2) {
+ stringValue = stringValue.substring(stringValue.length() - 2);
+ }
+ value.append(stringValue);
+ }
+
+ // Count leading zeros
+ while (value.charAt(position) == '0') {
+ position++;
+ }
+ // Prepend sign and remove leading zeros
+ if (signed) {
+ value.replace(0, position, sign);
+ } else {
+ value.delete(0, position);
+ }
+ return value.toString();
+ }
+
+ /**
* this method sets byte array data to a packed-decimal value held in the value argument
*/
protected void setByteArrayToPackedDecimalValue(String value) {
diff --git a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractEclipseLinkSemanticValidator.java b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractEclipseLinkSemanticValidator.java
index ab8fa0c..d26d567 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractEclipseLinkSemanticValidator.java
+++ b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractEclipseLinkSemanticValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -39,6 +39,7 @@ import org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression;
import org.eclipse.persistence.jpa.jpql.parser.TableExpression;
import org.eclipse.persistence.jpa.jpql.parser.TableVariableDeclaration;
import org.eclipse.persistence.jpa.jpql.parser.UnionClause;
+
import static org.eclipse.persistence.jpa.jpql.JPQLQueryProblemMessages.*;
/**
@@ -130,7 +131,7 @@ public class AbstractEclipseLinkSemanticValidator extends AbstractSemanticValida
*/
@Override
protected TopLevelFirstDeclarationVisitor buildTopLevelFirstDeclarationVisitor() {
- return new TopLevelFirstDeclarationVisitor();
+ return new TopLevelFirstDeclarationVisitor(this);
}
protected JPQLQueryDeclaration getDeclaration(String variableName) {
@@ -527,10 +528,11 @@ public class AbstractEclipseLinkSemanticValidator extends AbstractSemanticValida
// Nothing to validate semantically
}
+ // Made static final for performance reasons.
/**
* This visitor retrieves the clause owning the visited {@link Expression}.
*/
- public static class EclipseLinkOwningClauseVisitor extends OwningClauseVisitor {
+ public static final class EclipseLinkOwningClauseVisitor extends OwningClauseVisitor {
public UnionClause unionClause;
@@ -555,7 +557,8 @@ public class AbstractEclipseLinkSemanticValidator extends AbstractSemanticValida
}
}
- protected static class SubquerySelectItemCalculator extends AnonymousExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class SubquerySelectItemCalculator extends AnonymousExpressionVisitor {
public int count;
@@ -608,7 +611,8 @@ public class AbstractEclipseLinkSemanticValidator extends AbstractSemanticValida
}
}
- protected static class TableExpressionVisitor extends AbstractEclipseLinkExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class TableExpressionVisitor extends AbstractEclipseLinkExpressionVisitor {
/**
* The {@link Expression} being visited.
@@ -629,7 +633,14 @@ public class AbstractEclipseLinkSemanticValidator extends AbstractSemanticValida
}
}
- protected class TopLevelFirstDeclarationVisitor extends AbstractSemanticValidator.TopLevelFirstDeclarationVisitor {
+ // Made static final for performance reasons.
+ protected static final class TopLevelFirstDeclarationVisitor extends AbstractSemanticValidator.TopLevelFirstDeclarationVisitor {
+
+ private final AbstractEclipseLinkSemanticValidator validator;
+
+ private TopLevelFirstDeclarationVisitor(AbstractEclipseLinkSemanticValidator validator) {
+ this.validator = validator;
+ }
/**
* {@inheritDoc}
@@ -639,12 +650,12 @@ public class AbstractEclipseLinkSemanticValidator extends AbstractSemanticValida
// Derived path is not allowed, this could although be a fully
// qualified class name, which was added to EclipseLink 2.4
- EclipseLinkVersion version = EclipseLinkVersion.value(getProviderVersion());
+ EclipseLinkVersion version = EclipseLinkVersion.value(validator.getProviderVersion());
valid = version.isNewerThanOrEqual(EclipseLinkVersion.VERSION_2_4);
if (valid) {
- Object type = helper.getType(expression.toActualText());
- valid = helper.isTypeResolvable(type);
+ Object type = validator.helper.getType(expression.toActualText());
+ valid = validator.helper.isTypeResolvable(type);
}
}
}
diff --git a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractGrammarValidator.java b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractGrammarValidator.java
index 0b43e45..3d5b4e3 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractGrammarValidator.java
+++ b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractGrammarValidator.java
@@ -230,7 +230,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<AbsExpression> buildAbsExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<AbsExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<AbsExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(AbsExpression expression) {
return AbsExpression_InvalidExpression;
@@ -249,7 +249,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<AllOrAnyExpression> buildAllOrAnyExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<AllOrAnyExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<AllOrAnyExpression>(this) {
@Override
public String[] arguments(AllOrAnyExpression expression) {
return new String[] { expression.getIdentifier() };
@@ -272,7 +272,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<AvgFunction> buildAvgFunctionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<AvgFunction>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<AvgFunction>(this) {
@Override
public String encapsulatedExpressionInvalidKey(AvgFunction expression) {
return AvgFunction_InvalidExpression;
@@ -296,7 +296,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<CoalesceExpression> buildCoalesceExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<CoalesceExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<CoalesceExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(CoalesceExpression expression) {
return CoalesceExpression_InvalidExpression;
@@ -328,7 +328,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<ConcatExpression> buildConcatExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<ConcatExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<ConcatExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(ConcatExpression expression) {
return ConcatExpression_InvalidExpression;
@@ -352,7 +352,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<CountFunction> buildCountFunctionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<CountFunction>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<CountFunction>(this) {
@Override
public String encapsulatedExpressionInvalidKey(CountFunction expression) {
return CountFunction_InvalidExpression;
@@ -380,7 +380,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<EntryExpression> buildEntryExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<EntryExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<EntryExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(EntryExpression expression) {
return EntryExpression_InvalidExpression;
@@ -403,7 +403,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<ExistsExpression> buildExistsExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<ExistsExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<ExistsExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(ExistsExpression expression) {
return ExistsExpression_InvalidExpression;
@@ -422,7 +422,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<FunctionExpression> buildFunctionExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<FunctionExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<FunctionExpression>(this) {
@Override
public String[] arguments(FunctionExpression expression) {
return new String[] { expression.getIdentifier() };
@@ -510,7 +510,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<IndexExpression> buildIndexExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<IndexExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<IndexExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(IndexExpression expression) {
return IndexExpression_InvalidExpression;
@@ -533,7 +533,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<KeyExpression> buildKeyExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<KeyExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<KeyExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(KeyExpression expression) {
return KeyExpression_InvalidExpression;
@@ -556,7 +556,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<LengthExpression> buildLengthExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<LengthExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<LengthExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(LengthExpression expression) {
return LengthExpression_InvalidExpression;
@@ -575,7 +575,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractTripleEncapsulatedExpressionHelper<LocateExpression> buildLocateExpressionHelper() {
- return new AbstractTripleEncapsulatedExpressionHelper<LocateExpression>() {
+ return new AbstractTripleEncapsulatedExpressionHelper<LocateExpression>(this) {
@Override
protected String firstCommaMissingKey() {
return LocateExpression_MissingFirstComma;
@@ -621,7 +621,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<LowerExpression> buildLowerExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<LowerExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<LowerExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(LowerExpression expression) {
return LowerExpression_InvalidExpression;
@@ -640,7 +640,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<MaxFunction> buildMaxFunctionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<MaxFunction>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<MaxFunction>(this) {
@Override
public String encapsulatedExpressionInvalidKey(MaxFunction expression) {
return MaxFunction_InvalidExpression;
@@ -664,7 +664,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<MinFunction> buildMinFunctionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<MinFunction>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<MinFunction>(this) {
@Override
public String encapsulatedExpressionInvalidKey(MinFunction expression) {
return MinFunction_InvalidExpression;
@@ -688,7 +688,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractDoubleEncapsulatedExpressionHelper<ModExpression> buildModExpressionHelper() {
- return new AbstractDoubleEncapsulatedExpressionHelper<ModExpression>() {
+ return new AbstractDoubleEncapsulatedExpressionHelper<ModExpression>(this) {
@Override
protected String firstExpressionInvalidKey() {
return ModExpression_InvalidFirstExpression;
@@ -728,7 +728,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractDoubleEncapsulatedExpressionHelper<NullIfExpression> buildNullIfExpressionHelper() {
- return new AbstractDoubleEncapsulatedExpressionHelper<NullIfExpression>() {
+ return new AbstractDoubleEncapsulatedExpressionHelper<NullIfExpression>(this) {
@Override
public String firstExpressionInvalidKey() {
return NullIfExpression_InvalidFirstExpression;
@@ -759,7 +759,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<ObjectExpression> buildObjectExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<ObjectExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<ObjectExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(ObjectExpression expression) {
return ObjectExpression_InvalidExpression;
@@ -782,7 +782,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<SizeExpression> buildSizeExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<SizeExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<SizeExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(SizeExpression expression) {
return SizeExpression_InvalidExpression;
@@ -801,7 +801,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<SqrtExpression> buildSqrtExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<SqrtExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<SqrtExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(SqrtExpression expression) {
return SqrtExpression_InvalidExpression;
@@ -820,7 +820,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractTripleEncapsulatedExpressionHelper<SubstringExpression> buildSubstringExpressionHelper() {
- return new AbstractTripleEncapsulatedExpressionHelper<SubstringExpression>() {
+ return new AbstractTripleEncapsulatedExpressionHelper<SubstringExpression>(this) {
@Override
protected String firstCommaMissingKey() {
return SubstringExpression_MissingFirstComma;
@@ -866,7 +866,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<SumFunction> buildSumFunctionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<SumFunction>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<SumFunction>(this) {
@Override
public String encapsulatedExpressionInvalidKey(SumFunction expression) {
return SumFunction_InvalidExpression;
@@ -890,7 +890,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<TrimExpression> buildTrimExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<TrimExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<TrimExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(TrimExpression expression) {
return TrimExpression_InvalidExpression;
@@ -919,7 +919,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<TypeExpression> buildTypeExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<TypeExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<TypeExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(TypeExpression expression) {
return TypeExpression_InvalidExpression;
@@ -938,7 +938,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<UpperExpression> buildUpperExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<UpperExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<UpperExpression>(this) {
@Override
public String encapsulatedExpressionInvalidKey(UpperExpression expression) {
return UpperExpression_InvalidExpression;
@@ -957,7 +957,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected AbstractSingleEncapsulatedExpressionHelper<ValueExpression> buildValueExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<ValueExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<ValueExpression>(this) {
@Override
protected String encapsulatedExpressionInvalidKey(ValueExpression expression) {
return ValueExpression_InvalidExpression;
@@ -990,14 +990,14 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
protected CollectionSeparatedByCommaValidator collectionSeparatedByCommaValidator() {
if (collectionSeparatedByCommaValidator == null) {
- collectionSeparatedByCommaValidator = new CollectionSeparatedByCommaValidator();
+ collectionSeparatedByCommaValidator = new CollectionSeparatedByCommaValidator(this);
}
return collectionSeparatedByCommaValidator;
}
protected CollectionSeparatedBySpaceValidator collectionSeparatedBySpaceValidator() {
if (collectionSeparatedBySpaceValidator == null) {
- collectionSeparatedBySpaceValidator = new CollectionSeparatedBySpaceValidator();
+ collectionSeparatedBySpaceValidator = new CollectionSeparatedBySpaceValidator(this);
}
return collectionSeparatedBySpaceValidator;
}
@@ -4539,6 +4539,17 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
);
}
+ // Made static for performance reasons.
+ private abstract static class AbstractValidator {
+
+ protected final AbstractGrammarValidator validator;
+
+ protected AbstractValidator(AbstractGrammarValidator validator) {
+ this.validator = validator;
+ }
+ }
+
+ // Made static for performance reasons.
/**
* This validate is responsible to validate the collection of {@link Expression Expressions}:
* <ul>
@@ -4548,18 +4559,23 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
* <li>There is no empty expression between two commas.</li>
* </ul>
*/
- protected abstract class AbstractCollectionValidator extends AbstractExpressionVisitor {
+ protected abstract static class AbstractCollectionValidator extends AbstractExpressionVisitor {
String endsWithCommaProblemKey;
boolean validateOnly;
String wrongSeparatorProblemKey;
+ private final AbstractGrammarValidator validator;
+
+ protected AbstractCollectionValidator(AbstractGrammarValidator validator) {
+ this.validator = validator;
+ }
protected void validateEndsWithComma(CollectionExpression expression) {
if (expression.endsWithComma()) {
int lastIndex = expression.childrenSize() - 1;
int length = expression.toParsedText(lastIndex).length();
- int startPosition = position(expression) + length - 1;
+ int startPosition = validator.position(expression) + length - 1;
if (expression.endsWithSpace()) {
startPosition--;
@@ -4568,7 +4584,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
int endPosition = startPosition + 1;
if (!validateOnly) {
- addProblem(expression, startPosition, endPosition, endsWithCommaProblemKey);
+ validator.addProblem(expression, startPosition, endPosition, endsWithCommaProblemKey);
}
}
}
@@ -4579,11 +4595,11 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
Expression expression1 = expression.getChild(index);
- if (length(expression1) == 0) {
- int startPosition = position(expression1);
+ if (validator.length(expression1) == 0) {
+ int startPosition = validator.position(expression1);
int endPosition = startPosition;
- addProblem(
+ validator.addProblem(
expression,
startPosition,
endPosition,
@@ -4595,8 +4611,8 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
if (!validateSeparator(expression, index)) {
Expression expression2 = expression.getChild(index + 1);
- int startPosition = position(expression1) + length(expression1);
- int endPosition = position(expression2);
+ int startPosition = validator.position(expression1) + validator.length(expression1);
+ int endPosition = validator.position(expression2);
// The space is part of the child expression, move backward
if (!expression.hasSpace(index)) {
@@ -4604,7 +4620,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
if (!validateOnly) {
- addProblem(
+ validator.addProblem(
expression,
startPosition,
endPosition,
@@ -4636,7 +4652,13 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
}
- protected abstract class AbstractDoubleEncapsulatedExpressionHelper<T extends AbstractDoubleEncapsulatedExpression> implements AbstractEncapsulatedExpressionHelper<T> {
+ // Made static for performance reasons.
+ protected static abstract class AbstractDoubleEncapsulatedExpressionHelper<T extends AbstractDoubleEncapsulatedExpression>
+ extends AbstractValidator implements AbstractEncapsulatedExpressionHelper<T> {
+
+ protected AbstractDoubleEncapsulatedExpressionHelper(AbstractGrammarValidator validator) {
+ super(validator);
+ }
/**
* {@inheritDoc}
@@ -4648,7 +4670,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
protected abstract String firstExpressionInvalidKey();
protected int firstExpressionLength(T expression) {
- return length(expression.getFirstExpression());
+ return validator.length(expression.getFirstExpression());
}
protected abstract String firstExpressionMissingKey();
@@ -4693,11 +4715,11 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected final boolean isFirstExpressionValid(T expression) {
- return isValid(expression.getFirstExpression(), expression.parameterExpressionBNF(0));
+ return validator.isValid(expression.getFirstExpression(), expression.parameterExpressionBNF(0));
}
protected final boolean isSecondExpressionValid(T expression) {
- return isValid(expression.getSecondExpression(), expression.parameterExpressionBNF(1));
+ return validator.isValid(expression.getSecondExpression(), expression.parameterExpressionBNF(1));
}
protected abstract String missingCommaKey();
@@ -4705,12 +4727,13 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
protected abstract String secondExpressionInvalidKey();
protected int secondExpressionLength(T expression) {
- return length(expression.getSecondExpression());
+ return validator.length(expression.getSecondExpression());
}
protected abstract String secondExpressionMissingKey();
}
+ // Made static for performance reasons.
/**
* The root helper that validates any {@link AbstractEncapsulatedExpression}.
*
@@ -4718,7 +4741,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
* @see AbstractSingleEncapsulatedExpressionHelper
* @see AbstractTripleEncapsulatedExpressionHelper
*/
- protected interface AbstractEncapsulatedExpressionHelper<T extends AbstractEncapsulatedExpression> {
+ protected static interface AbstractEncapsulatedExpressionHelper<T extends AbstractEncapsulatedExpression> {
/**
* Returns the arguments that can help to format the localized problem.
@@ -4769,14 +4792,20 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
String rightParenthesisMissingKey(T expression);
}
+ // Made static for performance reasons.
/**
* The abstract implementation of {@link AbstractSingleEncapsulatedExpressionHelper} which
* implements some of the methods since the behavior is the same for all subclasses of
* {@link AbstractSingleEncapsulatedExpression}.
*/
- protected abstract class AbstractSingleEncapsulatedExpressionHelper<T extends AbstractSingleEncapsulatedExpression> implements AbstractEncapsulatedExpressionHelper<T> {
+ protected static abstract class AbstractSingleEncapsulatedExpressionHelper<T extends AbstractSingleEncapsulatedExpression>
+ extends AbstractValidator implements AbstractEncapsulatedExpressionHelper<T> {
- /**
+ protected AbstractSingleEncapsulatedExpressionHelper(AbstractGrammarValidator validator) {
+ super(validator);
+ }
+
+ /**
* {@inheritDoc}
*/
public String[] arguments(T expression) {
@@ -4798,7 +4827,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
* @return The length of the encapsulated expression
*/
protected int encapsulatedExpressionLength(T expression) {
- return length(expression.getExpression());
+ return validator.length(expression.getExpression());
}
/**
@@ -4853,7 +4882,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
* otherwise
*/
protected boolean isEncapsulatedExpressionValid(T expression) {
- return isValid(expression.getExpression(), expression.getEncapsulatedExpressionQueryBNFId());
+ return validator.isValid(expression.getExpression(), expression.getEncapsulatedExpressionQueryBNFId());
}
/**
@@ -4870,9 +4899,15 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
}
- protected abstract class AbstractTripleEncapsulatedExpressionHelper<T extends AbstractTripleEncapsulatedExpression> implements AbstractEncapsulatedExpressionHelper<T> {
+ // Made static for performance reasons.
+ protected abstract static class AbstractTripleEncapsulatedExpressionHelper<T extends AbstractTripleEncapsulatedExpression>
+ extends AbstractValidator implements AbstractEncapsulatedExpressionHelper<T> {
- /**
+ protected AbstractTripleEncapsulatedExpressionHelper(AbstractGrammarValidator validator) {
+ super(validator);
+ }
+
+ /**
* {@inheritDoc}
*/
public String[] arguments(T expression) {
@@ -4884,7 +4919,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
protected abstract String firstExpressionInvalidKey();
protected int firstExpressionLength(T expression) {
- return length(expression.getFirstExpression());
+ return validator.length(expression.getFirstExpression());
}
protected abstract String firstExpressionMissingKey();
@@ -4916,7 +4951,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected boolean isFirstExpressionValid(T expression) {
- return isValid(expression.getFirstExpression(), expression.getParameterQueryBNFId(0));
+ return validator.isValid(expression.getFirstExpression(), expression.getParameterQueryBNFId(0));
}
/**
@@ -4964,11 +4999,11 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
protected boolean isSecondExpressionValid(T expression) {
- return isValid(expression.getSecondExpression(), expression.getParameterQueryBNFId(1));
+ return validator.isValid(expression.getSecondExpression(), expression.getParameterQueryBNFId(1));
}
protected boolean isThirdExpressionValid(T expression) {
- return isValid(expression.getThirdExpression(), expression.getParameterQueryBNFId(2));
+ return validator.isValid(expression.getThirdExpression(), expression.getParameterQueryBNFId(2));
}
protected abstract String secondCommaMissingKey();
@@ -4976,7 +5011,7 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
protected abstract String secondExpressionInvalidKey();
protected int secondExpressionLength(T expression) {
- return length(expression.getSecondExpression());
+ return validator.length(expression.getSecondExpression());
}
protected abstract String secondExpressionMissingKey();
@@ -4984,16 +5019,17 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
protected abstract String thirdExpressionInvalidKey();
protected int thirdExpressionLength(T expression) {
- return length(expression.getThirdExpression());
+ return validator.length(expression.getThirdExpression());
}
protected abstract String thirdExpressionMissingKey();
}
+ // Made static final for performance reasons.
/**
* This visitor retrieves the {@link CollectionExpression} if it is visited.
*/
- protected static class CollectionExpressionVisitor extends AbstractExpressionVisitor {
+ protected static final class CollectionExpressionVisitor extends AbstractExpressionVisitor {
/**
* The {@link CollectionExpression} if it is the {@link Expression} that was visited.
@@ -5016,13 +5052,18 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
}
+ // Made static final for performance reasons.
/**
* This validator validates a {@link CollectionExpression} by making sure each item is separated
* by a comma.
*/
- protected class CollectionSeparatedByCommaValidator extends AbstractCollectionValidator {
+ protected static final class CollectionSeparatedByCommaValidator extends AbstractCollectionValidator {
- /**
+ protected CollectionSeparatedByCommaValidator(AbstractGrammarValidator validator) {
+ super(validator);
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -5031,11 +5072,16 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
}
+ // Made static final for performance reasons.
/**
* This validator validates a {@link CollectionExpression} by making sure each item is not
* separated by a comma.
*/
- protected class CollectionSeparatedBySpaceValidator extends AbstractCollectionValidator {
+ protected static final class CollectionSeparatedBySpaceValidator extends AbstractCollectionValidator {
+
+ protected CollectionSeparatedBySpaceValidator(AbstractGrammarValidator validator) {
+ super(validator);
+ }
/**
* {@inheritDoc}
@@ -5046,7 +5092,8 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
}
- protected static class ComparisonExpressionVisitor extends AbstractExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class ComparisonExpressionVisitor extends AbstractExpressionVisitor {
/**
* The {@link ComparisonExpression} if it is the {@link Expression} that was visited.
@@ -5062,7 +5109,8 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
}
- protected class DateTimeVisitor extends AbstractExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class DateTimeVisitor extends AbstractExpressionVisitor {
/**
* Determines whether the visited {@link Expression} is {@link DateTime} or not.
@@ -5078,10 +5126,11 @@ public abstract class AbstractGrammarValidator extends AbstractValidator {
}
}
+ // Made static final for performance reasons.
/**
* This visitor checks to see if the visited expression is {@link NullExpression}.
*/
- protected static class NullExpressionVisitor extends AbstractExpressionVisitor {
+ protected static final class NullExpressionVisitor extends AbstractExpressionVisitor {
/**
* The {@link NullExpression} if it is the {@link Expression} that was visited.
diff --git a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractSemanticValidator.java b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractSemanticValidator.java
index 02b4127..62c75b7 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractSemanticValidator.java
+++ b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/AbstractSemanticValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -213,7 +213,7 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
}
protected InItemsVisitor buildInItemsVisitor() {
- return new InItemsVisitor();
+ return new InItemsVisitor(this);
}
protected SubqueryFirstDeclarationVisitor buildSubqueryFirstDeclarationVisitor() {
@@ -281,7 +281,7 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
protected ComparisonExpressionVisitor getComparisonExpressionVisitor() {
if (comparisonExpressionVisitor == null) {
- comparisonExpressionVisitor = new ComparisonExpressionVisitor();
+ comparisonExpressionVisitor = new ComparisonExpressionVisitor(this);
}
return comparisonExpressionVisitor;
}
@@ -3264,11 +3264,12 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
validateWhereClause(expression);
}
+ // Made static final for performance reasons.
/**
* This visitor is meant to retrieve an {@link CollectionValuedPathExpression} if the visited
* {@link Expression} is that object.
*/
- protected static class CollectionValuedPathExpressionVisitor extends AbstractExpressionVisitor {
+ protected static final class CollectionValuedPathExpressionVisitor extends AbstractExpressionVisitor {
/**
* The {@link CollectionValuedPathExpression} that was visited; <code>null</code> if he was not.
@@ -3284,7 +3285,8 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
}
}
- protected class ComparingEntityTypeLiteralVisitor extends AbstractExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class ComparingEntityTypeLiteralVisitor extends AbstractExpressionVisitor {
protected IdentificationVariable expression;
public boolean result;
@@ -3317,12 +3319,14 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
}
}
+ // Made static final for performance reasons.
/**
* This visitor compares the left and right expressions of a comparison expression and gathers
* information about those expressions if they are an identification variable or a path expression.
*/
- protected class ComparisonExpressionVisitor extends AnonymousExpressionVisitor {
+ protected static final class ComparisonExpressionVisitor extends AnonymousExpressionVisitor {
+ private final AbstractSemanticValidator validator;
public boolean leftIdentificationVariable;
public boolean leftIdentificationVariableValid;
public boolean leftStateFieldPathExpression;
@@ -3333,10 +3337,14 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
public boolean rightStateFieldPathExpressionValid;
public boolean validatingLeftExpression;
+ private ComparisonExpressionVisitor(AbstractSemanticValidator validator) {
+ this.validator = validator;
+ }
+
/**
* Resets the flags.
*/
- protected void dispose() {
+ private void dispose() {
leftIdentificationVariable = false;
leftIdentificationVariableValid = false;
leftStateFieldPathExpression = false;
@@ -3353,7 +3361,7 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
@Override
protected void visit(Expression expression) {
// Redirect to the validator, nothing special is required
- expression.accept(AbstractSemanticValidator.this);
+ expression.accept(validator);
}
/**
@@ -3363,19 +3371,19 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
public void visit(IdentificationVariable expression) {
// Make sure the identification variable is not a result variable
- if (!helper.isResultVariable(expression.getVariableName())) {
+ if (!validator.helper.isResultVariable(expression.getVariableName())) {
if (validatingLeftExpression) {
leftIdentificationVariable = !expression.isVirtual();
// Make sure what was parsed is a valid identification variable
- leftIdentificationVariableValid = validateIdentificationVariable(expression);
+ leftIdentificationVariableValid = validator.validateIdentificationVariable(expression);
}
else {
rightIdentificationVariable = !expression.isVirtual();
// Make sure what was parsed is a valid identification variable
- rightIdentificationVariableValid = validateIdentificationVariable(expression);
+ rightIdentificationVariableValid = validator.validateIdentificationVariable(expression);
}
}
}
@@ -3390,7 +3398,7 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
leftStateFieldPathExpression = true;
// Make sure what was parsed is a valid path expression
- leftStateFieldPathExpressionValid = validateStateFieldPathExpression(
+ leftStateFieldPathExpressionValid = validator.validateStateFieldPathExpression(
expression,
PathType.ANY_FIELD_INCLUDING_COLLECTION
);
@@ -3399,7 +3407,7 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
rightStateFieldPathExpression = true;
// Make sure what was parsed is a valid path expression
- rightStateFieldPathExpressionValid = validateStateFieldPathExpression(
+ rightStateFieldPathExpressionValid = validator.validateStateFieldPathExpression(
expression,
PathType.ANY_FIELD_INCLUDING_COLLECTION
);
@@ -3407,7 +3415,8 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
}
}
- protected class FirstDeclarationVisitor extends AnonymousExpressionVisitor {
+ // Made static for performance reasons.
+ protected static class FirstDeclarationVisitor extends AnonymousExpressionVisitor {
protected boolean valid;
@@ -3462,14 +3471,21 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
}
}
- protected class InItemsVisitor extends AnonymousExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class InItemsVisitor extends AnonymousExpressionVisitor {
- /**
+ private final AbstractSemanticValidator validator;
+
+ protected InItemsVisitor(AbstractSemanticValidator validator) {
+ this.validator = validator;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
protected void visit(Expression expression) {
- expression.accept(AbstractSemanticValidator.this);
+ expression.accept(validator);
}
/**
@@ -3477,16 +3493,17 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
*/
@Override
public void visit(StateFieldPathExpression expression) {
- validateStateFieldPathExpression(expression, validPathExpressionTypeForInItem());
+ validator.validateStateFieldPathExpression(expression, validator.validPathExpressionTypeForInItem());
}
}
+ // Made static for performance reasons.
/**
* This enumeration allows {@link AbstractSemanticValidator#validateStateFieldPathExpression(
* StateFieldPathExpression, PathType)} to validate the type of the mapping and to make sure it
* is allowed based on its location.
*/
- protected enum PathType {
+ protected static enum PathType {
/**
* This will allow basic, and association fields to be specified.
@@ -3509,11 +3526,12 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
BASIC_FIELD_ONLY
}
+ // Made static final for performance reasons.
/**
* This visitor is meant to retrieve an {@link StateFieldPathExpressionVisitor} if the visited
* {@link Expression} is that object.
*/
- protected static class StateFieldPathExpressionVisitor extends AbstractExpressionVisitor {
+ protected static final class StateFieldPathExpressionVisitor extends AbstractExpressionVisitor {
/**
* The {@link StateFieldPathExpression} that was visited; <code>null</code> if it was not.
@@ -3529,7 +3547,8 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
}
}
- protected class SubqueryFirstDeclarationVisitor extends FirstDeclarationVisitor {
+ // Made static final for performance reasons.
+ protected static final class SubqueryFirstDeclarationVisitor extends FirstDeclarationVisitor {
/**
* {@inheritDoc}
@@ -3540,7 +3559,8 @@ public abstract class AbstractSemanticValidator extends AbstractValidator {
}
}
- protected class TopLevelFirstDeclarationVisitor extends FirstDeclarationVisitor {
+ // Made static for performance reasons.
+ protected static class TopLevelFirstDeclarationVisitor extends FirstDeclarationVisitor {
/**
* {@inheritDoc}
diff --git a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/EclipseLinkGrammarValidator.java b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/EclipseLinkGrammarValidator.java
index c7b3f57..7eb8291 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/EclipseLinkGrammarValidator.java
+++ b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/EclipseLinkGrammarValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -70,7 +70,7 @@ public class EclipseLinkGrammarValidator extends AbstractGrammarValidator
}
protected AbstractSingleEncapsulatedExpressionHelper<CastExpression> buildCastExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<CastExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<CastExpression>(this) {
@Override
protected String encapsulatedExpressionInvalidKey(CastExpression expression) {
return CastExpression_InvalidExpression;
@@ -89,7 +89,7 @@ public class EclipseLinkGrammarValidator extends AbstractGrammarValidator
}
protected AbstractDoubleEncapsulatedExpressionHelper<DatabaseType> buildDatabaseTypeHelper() {
- return new AbstractDoubleEncapsulatedExpressionHelper<DatabaseType>() {
+ return new AbstractDoubleEncapsulatedExpressionHelper<DatabaseType>(this) {
@Override
protected String firstExpressionInvalidKey() {
return DatabaseType_InvalidFirstExpression;
@@ -160,7 +160,7 @@ public class EclipseLinkGrammarValidator extends AbstractGrammarValidator
}
protected AbstractSingleEncapsulatedExpressionHelper<ExtractExpression> buildExtractExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<ExtractExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<ExtractExpression>(this) {
@Override
protected String encapsulatedExpressionInvalidKey(ExtractExpression expression) {
return ExtractExpression_InvalidExpression;
@@ -190,7 +190,7 @@ public class EclipseLinkGrammarValidator extends AbstractGrammarValidator
}
protected InExpressionWithNestedArrayVisitor buildInExpressionWithNestedArrayVisitor() {
- return new InExpressionWithNestedArrayVisitor();
+ return new InExpressionWithNestedArrayVisitor(this);
}
/**
@@ -210,7 +210,7 @@ public class EclipseLinkGrammarValidator extends AbstractGrammarValidator
}
protected AbstractSingleEncapsulatedExpressionHelper<TableExpression> buildTableExpressionHelper() {
- return new AbstractSingleEncapsulatedExpressionHelper<TableExpression>() {
+ return new AbstractSingleEncapsulatedExpressionHelper<TableExpression>(this) {
@Override
protected String encapsulatedExpressionInvalidKey(TableExpression expression) {
return TableExpression_InvalidExpression;
@@ -652,6 +652,7 @@ public class EclipseLinkGrammarValidator extends AbstractGrammarValidator
}
}
+ // Made static for performance reasons.
protected static class InExpressionVisitor extends AbstractEclipseLinkExpressionVisitor {
protected InExpression expression;
@@ -662,9 +663,16 @@ public class EclipseLinkGrammarValidator extends AbstractGrammarValidator
}
}
- protected class InExpressionWithNestedArrayVisitor extends AbstractEclipseLinkExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class InExpressionWithNestedArrayVisitor extends AbstractEclipseLinkExpressionVisitor {
- /**
+ private final EclipseLinkGrammarValidator visitor;
+
+ protected InExpressionWithNestedArrayVisitor(EclipseLinkGrammarValidator visitor) {
+ this.visitor = visitor;
+ }
+
+ /**
* Determines whether the left expression of an <code><b>IN</b></code> expression is a nested
* array when the <code><b>IN</b></code> item is a subquery.
*/
@@ -675,7 +683,7 @@ public class EclipseLinkGrammarValidator extends AbstractGrammarValidator
*/
@Override
public void visit(InExpression expression) {
- valid = isNestedArray(expression.getExpression());
+ valid = visitor.isNestedArray(expression.getExpression());
}
/**
diff --git a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/AndExpressionFactory.java b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/AndExpressionFactory.java
index dae5cdc..65df346 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/AndExpressionFactory.java
+++ b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/AndExpressionFactory.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -91,14 +91,15 @@ public final class AndExpressionFactory extends ExpressionFactory {
return visitor;
}
+ // Made static final for performance reasons.
/**
- * This {@link ExpressionVisitor} is used to check if the {@link Expression} passed to this
- * factory is an {@link OrExpression}.
- */
- private class OrExpressionVisitor extends AbstractExpressionVisitor {
-
- /**
- * This flag is turned on if the {@link Expression} visited is {@link OrExpression}.
+ * This {@link ExpressionVisitor} is used to check if the {@link Expression} passed to this
+ * factory is an {@link OrExpression}.
+ */
+ private static final class OrExpressionVisitor extends AbstractExpressionVisitor {
+
+ /**
+ * This flag is turned on if the {@link Expression} visited is {@link OrExpression}.
*/
boolean found;
diff --git a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/ArithmeticExpressionFactory.java b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/ArithmeticExpressionFactory.java
index c5c385e..6304228 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/ArithmeticExpressionFactory.java
+++ b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/ArithmeticExpressionFactory.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -148,14 +148,15 @@ public final class ArithmeticExpressionFactory extends ExpressionFactory {
return visitor;
}
+ // Made static final for performance reasons.
/**
- * This {@link ExpressionVisitor} is used to check if the {@link Expression} passed to this
- * factory is an {@link AdditionExpression} or {@link SubtractionExpression}.
- */
- private class ArithmeticExpressionVisitor extends AbstractExpressionVisitor {
-
- /**
- * This flag is turned on if the {@link Expression} visited is {@link OrExpression}.
+ * This {@link ExpressionVisitor} is used to check if the {@link Expression} passed to this
+ * factory is an {@link AdditionExpression} or {@link SubtractionExpression}.
+ */
+ private static final class ArithmeticExpressionVisitor extends AbstractExpressionVisitor {
+
+ /**
+ * This flag is turned on if the {@link Expression} visited is {@link OrExpression}.
*/
boolean found;
diff --git a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/FullyQualifyPathExpressionVisitor.java b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/FullyQualifyPathExpressionVisitor.java
index b897cfd..52775cb 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/FullyQualifyPathExpressionVisitor.java
+++ b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/parser/FullyQualifyPathExpressionVisitor.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -187,13 +187,14 @@ public final class FullyQualifyPathExpressionVisitor extends AbstractTraverseChi
if (visitor.expression == null) {
expression.setVirtualIdentificationVariable(variableName);
}
- }
- }
-
- private class GeneralIdentificationVariableVisitor extends AbstractExpressionVisitor {
-
- /**
- * The {@link Expression} that was visited, which is a general identification variable but is
+ }
+ }
+
+ // Made static final for performance reasons.
+ private static final class GeneralIdentificationVariableVisitor extends AbstractExpressionVisitor {
+
+ /**
+ * The {@link Expression} that was visited, which is a general identification variable but is
* not a identification variable, it's either a map value, map key or map value expression.
*/
private Expression expression;
diff --git a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/AbstractContentAssistVisitor.java b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/AbstractContentAssistVisitor.java
index 03cf882..9aa3d3e 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/AbstractContentAssistVisitor.java
+++ b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/AbstractContentAssistVisitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -836,7 +836,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
protected abstract AcceptableTypeVisitor buildAcceptableTypeVisitor();
protected AppendableExpressionVisitor buildAppendableExpressionVisitor() {
- return new AppendableExpressionVisitor();
+ return new AppendableExpressionVisitor(this);
}
protected Filter<Expression> buildCollectionCompoundTypeFilter() {
@@ -859,15 +859,15 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected ConcatExpressionCollectionHelper buildConcatExpressionCollectionHelper() {
- return new ConcatExpressionCollectionHelper();
+ return new ConcatExpressionCollectionHelper(this);
}
protected ConditionalClauseCollectionHelper buildConditionalClauseCollectionHelper() {
- return new ConditionalClauseCollectionHelper();
+ return new ConditionalClauseCollectionHelper(this);
}
protected ConstrutorCollectionHelper buildConstrutorCollectionHelper() {
- return new ConstrutorCollectionHelper();
+ return new ConstrutorCollectionHelper(this);
}
protected DeclarationVisitor buildDeclarationVisitor() {
@@ -879,11 +879,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected DeleteClauseCollectionHelper buildDeleteClauseCollectionHelper() {
- return new DeleteClauseCollectionHelper();
+ return new DeleteClauseCollectionHelper(this);
}
protected DeleteClauseStatementHelper buildDeleteClauseStatementHelper() {
- return new DeleteClauseStatementHelper();
+ return new DeleteClauseStatementHelper(this);
}
protected Filter<Expression> buildDifferentComparisonFilter() {
@@ -891,7 +891,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected DoubleEncapsulatedCollectionHelper buildDoubleEncapsulatedCollectionHelper() {
- return new DoubleEncapsulatedCollectionHelper();
+ return new DoubleEncapsulatedCollectionHelper(this);
}
protected EncapsulatedExpressionVisitor buildEncapsulatedExpressionVisitor() {
@@ -930,7 +930,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected EndingQueryPositionBuilder buildEndingQueryPositionBuilder() {
- return new EndingQueryPositionBuilder();
+ return new EndingQueryPositionBuilder(this);
}
protected EnumVisitor buildEnumVisitor() {
@@ -954,27 +954,27 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected FollowingInvalidExpressionVisitor buildFollowingInvalidExpressionVisitor() {
- return new FollowingInvalidExpressionVisitor();
+ return new FollowingInvalidExpressionVisitor(this);
}
protected FromClauseCollectionHelper buildFromClauseCollectionHelper() {
- return new FromClauseCollectionHelper();
+ return new FromClauseCollectionHelper(this);
}
protected FromClauseStatementHelper buildFromClauseStatementHelper() {
- return new FromClauseStatementHelper();
+ return new FromClauseStatementHelper(this);
}
protected GroupByClauseCollectionHelper buildGroupByClauseCollectionHelper() {
- return new GroupByClauseCollectionHelper();
+ return new GroupByClauseCollectionHelper(this);
}
protected GroupByClauseStatementHelper buildGroupByClauseStatementHelper() {
- return new GroupByClauseStatementHelper();
+ return new GroupByClauseStatementHelper(this);
}
protected HavingClauseStatementHelper buildHavingClauseStatementHelper() {
- return new HavingClauseStatementHelper();
+ return new HavingClauseStatementHelper(this);
}
protected IncompleteCollectionExpressionVisitor buildIncompleteCollectionExpressionVisitor() {
@@ -986,7 +986,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected JoinCollectionHelper buildJoinCollectionHelper() {
- return new JoinCollectionHelper();
+ return new JoinCollectionHelper(this);
}
/**
@@ -1027,7 +1027,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
// This will filter the property mappings
- return new AndFilter<IMapping>(new MappingTypeFilter(type), filter);
+ return new AndFilter<IMapping>(new MappingTypeFilter(type, this), filter);
}
protected Filter<IMapping> buildMappingFilter(Expression expression) {
@@ -1042,7 +1042,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected MappingFilterBuilder buildMappingFilterBuilder() {
- return new MappingFilterBuilder();
+ return new MappingFilterBuilder(this);
}
protected Filter<Expression> buildNonCollectionCompoundTypeFilter() {
@@ -1061,11 +1061,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected OrderByClauseCollectionHelper buildOrderByClauseCollectionHelper() {
- return new OrderByClauseCollectionHelper();
+ return new OrderByClauseCollectionHelper(this);
}
protected OrderByClauseStatementHelper buildOrderByClauseStatementHelper() {
- return new OrderByClauseStatementHelper();
+ return new OrderByClauseStatementHelper(this);
}
protected PropertyMappingFilter buildPropertyMappingFilter() {
@@ -1128,35 +1128,35 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected SelectClauseCollectionHelper buildSelectClauseCollectionHelper() {
- return new SelectClauseCollectionHelper();
+ return new SelectClauseCollectionHelper(this);
}
protected SelectClauseStatementHelper buildSelectClauseStatementHelper() {
- return new SelectClauseStatementHelper();
+ return new SelectClauseStatementHelper(this);
}
protected SimpleFromClauseStatementHelper buildSimpleFromClauseStatementHelper() {
- return new SimpleFromClauseStatementHelper();
+ return new SimpleFromClauseStatementHelper(this);
}
protected SimpleGroupByClauseStatementHelper buildSimpleGroupByClauseStatementHelper() {
- return new SimpleGroupByClauseStatementHelper();
+ return new SimpleGroupByClauseStatementHelper(this);
}
protected SimpleHavingClauseStatementHelper buildSimpleHavingClauseStatementHelper() {
- return new SimpleHavingClauseStatementHelper();
+ return new SimpleHavingClauseStatementHelper(this);
}
protected SimpleSelectClauseCollectionHelper buildSimpleSelectClauseCollectionHelper() {
- return new SimpleSelectClauseCollectionHelper();
+ return new SimpleSelectClauseCollectionHelper(this);
}
protected SimpleSelectClauseStatementHelper buildSimpleSelectClauseStatementHelper() {
- return new SimpleSelectClauseStatementHelper();
+ return new SimpleSelectClauseStatementHelper(this);
}
protected SimpleWhereClauseSelectStatementHelper buildSimpleWhereClauseSelectStatementHelper() {
- return new SimpleWhereClauseSelectStatementHelper();
+ return new SimpleWhereClauseSelectStatementHelper(this);
}
protected SubqueryAppendableExpressionVisitor buildSubqueryAppendableExpressionVisitor() {
@@ -1168,35 +1168,35 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
protected TripleEncapsulatedCollectionHelper buildTripleEncapsulatedCollectionHelper() {
- return new TripleEncapsulatedCollectionHelper();
+ return new TripleEncapsulatedCollectionHelper(this);
}
protected UpdateClauseStatementHelper buildUpdateClauseStatementHelper() {
- return new UpdateClauseStatementHelper();
+ return new UpdateClauseStatementHelper(this);
}
protected UpdateItemCollectionHelper buildUpdateItemCollectionHelper() {
- return new UpdateItemCollectionHelper();
+ return new UpdateItemCollectionHelper(this);
}
protected VisitParentVisitor buildVisitParentVisitor() {
- return new VisitParentVisitor();
+ return new VisitParentVisitor(this);
}
protected WhenClauseConditionalClauseCollectionHelper buildWhenClauseConditionalClauseCollectionHelper() {
- return new WhenClauseConditionalClauseCollectionHelper();
+ return new WhenClauseConditionalClauseCollectionHelper(this);
}
protected WhereClauseDeleteStatementHelper buildWhereClauseDeleteStatementHelper() {
- return new WhereClauseDeleteStatementHelper();
+ return new WhereClauseDeleteStatementHelper(this);
}
protected WhereClauseSelectStatementHelper buildWhereClauseSelectStatementHelper() {
- return new WhereClauseSelectStatementHelper();
+ return new WhereClauseSelectStatementHelper(this);
}
protected WhereClauseUpdateStatementHelper buildWhereClauseUpdateStatementHelper() {
- return new WhereClauseUpdateStatementHelper();
+ return new WhereClauseUpdateStatementHelper(this);
}
protected WithinInvalidExpressionVisitor buildWithinInvalidExpressionVisitor() {
@@ -4887,7 +4887,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
String variableName) {
}
- protected class AbstractAppendableExpressionVisitor extends AnonymousExpressionVisitor {
+ // Made static for performance reasons.
+ protected static class AbstractAppendableExpressionVisitor extends AnonymousExpressionVisitor {
/**
* Flag used to determine if JPQL identifiers can be appended to the expression.
@@ -4911,14 +4912,37 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static for performance reasons.
+ /**
+ * Common helper with visitor reference.
+ */
+ private static abstract class AbstractVisitorHelper {
+
+ /**
+ * Enclosing visitor instance.
+ */
+ protected final AbstractContentAssistVisitor visitor;
+
+ AbstractVisitorHelper(AbstractContentAssistVisitor visitor) {
+ this.visitor = visitor;
+ }
+
+ }
+
+ // Made static for performance reasons.
/**
* This helper handles adding proposals within a conditional expression that might be parsed as
* a single expression or has a collection of expression, which means the fragment is either
* incomplete or invalid.
*/
- protected abstract class AbstractConditionalClauseCollectionHelper<T extends Expression> implements CollectionExpressionHelper<T> {
+ protected static abstract class AbstractConditionalClauseCollectionHelper<T extends Expression>
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<T> {
- /**
+ protected AbstractConditionalClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public void addAtTheEndOfChild(Expression expression,
@@ -4939,8 +4963,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
Expression child = collectionExpression.getChild(0);
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
}
else {
@@ -4958,21 +4982,21 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
// If 'IS' or 'IS NOT' is present, then none of the following are valid proposals
if (!hasIs && !hasNot) {
- if (areLogicalSymbolsAppendable(child)) {
- addLogicalIdentifiers();
+ if (visitor.areLogicalSymbolsAppendable(child)) {
+ visitor.addLogicalIdentifiers();
}
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
- if (areComparisonSymbolsAppendable(child)) {
- addComparisonIdentifiers(child);
+ if (visitor.areComparisonSymbolsAppendable(child)) {
+ visitor.addComparisonIdentifiers(child);
}
}
- if (isCompoundable(child)) {
- addCompoundIdentifiers(ConditionalExpressionBNF.ID, child, hasIs, hasNot);
+ if (visitor.isCompoundable(child)) {
+ visitor.addCompoundIdentifiers(ConditionalExpressionBNF.ID, child, hasIs, hasNot);
}
}
}
@@ -4981,7 +5005,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(Expression expression, String identifier) {
- proposals.addIdentifier(identifier);
+ visitor.proposals.addIdentifier(identifier);
}
/**
@@ -4994,13 +5018,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
if (index == 0) {
- addIdentificationVariables();
- addFunctionIdentifiers(ConditionalExpressionBNF.ID);
+ visitor.addIdentificationVariables();
+ visitor.addFunctionIdentifiers(ConditionalExpressionBNF.ID);
if ((collectionExpression != null) &&
- isSubqueryAppendable(collectionExpression.getChild(index))) {
+ visitor.isSubqueryAppendable(collectionExpression.getChild(index))) {
- AbstractContentAssistVisitor.this.addIdentifier(SELECT);
+ visitor.addIdentifier(SELECT);
}
}
else {
@@ -5017,7 +5041,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
Expression child = collectionExpression.getChild(index);
- if (isNotExpression(child)) {
+ if (visitor.isNotExpression(child)) {
return true;
}
@@ -5052,7 +5076,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
String text = child.toParsedText();
// Handle 'NOT'
- if (text.equalsIgnoreCase(NOT) || isNotExpression(child)) {
+ if (text.equalsIgnoreCase(NOT) || visitor.isNotExpression(child)) {
// Two consecutive 'NOT' or 'IS' is invalid or 'NOT IS' is not valid
if (isFound || notFound) {
@@ -5119,17 +5143,23 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(Expression expression, int index) {
- return getQueryBNF(ConditionalExpressionBNF.ID);
+ return visitor.getQueryBNF(ConditionalExpressionBNF.ID);
}
}
- protected abstract class AbstractFromClauseStatementHelper<T extends AbstractSelectStatement> implements StatementHelper<T> {
+ // Made static for performance reasons.
+ protected static abstract class AbstractFromClauseStatementHelper<T extends AbstractSelectStatement>
+ extends AbstractVisitorHelper implements StatementHelper<T> {
+
+ protected AbstractFromClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addIdentifier(FROM);
+ visitor.addIdentifier(FROM);
}
/**
@@ -5164,7 +5194,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(T expression) {
- return isComplete(expression.getFromClause());
+ return visitor.isComplete(expression.getFromClause());
}
/**
@@ -5175,13 +5205,19 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected abstract class AbstractGroupByClauseStatementHelper<T extends AbstractSelectStatement> implements StatementHelper<T> {
+ // Made static for performance reasons.
+ protected static abstract class AbstractGroupByClauseStatementHelper<T extends AbstractSelectStatement>
+ extends AbstractVisitorHelper implements StatementHelper<T> {
+
+ protected AbstractGroupByClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addCompositeIdentifier(GROUP_BY, -1);
+ visitor.addCompositeIdentifier(GROUP_BY, -1);
}
/**
@@ -5216,7 +5252,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(T expression) {
- return isComplete(expression.getGroupByClause());
+ return visitor.isComplete(expression.getGroupByClause());
}
/**
@@ -5227,13 +5263,19 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected abstract class AbstractHavingClauseStatementHelper<T extends AbstractSelectStatement> implements StatementHelper<T> {
+ // Made static for performance reasons.
+ protected static abstract class AbstractHavingClauseStatementHelper<T extends AbstractSelectStatement>
+ extends AbstractVisitorHelper implements StatementHelper<T> {
+
+ protected AbstractHavingClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addIdentifier(HAVING);
+ visitor.addIdentifier(HAVING);
}
/**
@@ -5261,7 +5303,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(T expression) {
- return isComplete(expression.getHavingClause());
+ return visitor.isComplete(expression.getHavingClause());
}
/**
@@ -5272,7 +5314,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected abstract class AbstractSelectClauseCollectionHelper<T extends AbstractSelectClause> implements CollectionExpressionHelper<T> {
+ // Made static for performance reasons.
+ protected static abstract class AbstractSelectClauseCollectionHelper<T extends AbstractSelectClause>
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<T> {
+
+ protected AbstractSelectClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
@@ -5290,8 +5338,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
Expression child = collectionExpression.getChild(index);
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
}
}
@@ -5300,7 +5348,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(T expression, String identifier) {
- proposals.addIdentifier(identifier);
+ visitor.proposals.addIdentifier(identifier);
}
/**
@@ -5312,8 +5360,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
boolean hasComma) {
if ((index == 0) || hasComma) {
- addIdentificationVariables();
- addFunctionIdentifiers(expression.getSelectItemQueryBNFId());
+ visitor.addIdentificationVariables();
+ visitor.addFunctionIdentifiers(expression.getSelectItemQueryBNFId());
}
}
@@ -5321,7 +5369,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(T expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getSelectExpression());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getSelectExpression());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -5360,17 +5408,23 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(T expression, int index) {
- return getQueryBNF(expression.getSelectItemQueryBNFId());
+ return visitor.getQueryBNF(expression.getSelectItemQueryBNFId());
}
}
- protected abstract class AbstractSelectClauseStatementHelper implements StatementHelper<AbstractSelectStatement> {
+ // Made static for performance reasons.
+ protected static abstract class AbstractSelectClauseStatementHelper
+ extends AbstractVisitorHelper implements StatementHelper<AbstractSelectStatement> {
+
+ protected AbstractSelectClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addIdentifier(SELECT);
+ visitor.addIdentifier(SELECT);
}
/**
@@ -5405,7 +5459,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(AbstractSelectStatement expression) {
- return isComplete(expression.getSelectClause());
+ return visitor.isComplete(expression.getSelectClause());
}
/**
@@ -5417,13 +5471,19 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
- protected abstract class AbstractWhereClauseSelectStatementHelper<T extends AbstractSelectStatement> implements StatementHelper<T> {
+ // Made static for performance reasons.
+ protected static abstract class AbstractWhereClauseSelectStatementHelper<T extends AbstractSelectStatement>
+ extends AbstractVisitorHelper implements StatementHelper<T> {
+
+ protected AbstractWhereClauseSelectStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addIdentifier(WHERE);
+ visitor.addIdentifier(WHERE);
}
/**
@@ -5458,7 +5518,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(T expression) {
- return isComplete(expression.getWhereClause());
+ return visitor.isComplete(expression.getWhereClause());
}
/**
@@ -5469,11 +5529,12 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static for performance reasons.
/**
* This visitor retrieves the permitted type from the path expression's parent. For instance,
* <b>SUM<b></b> or <b>AVG</b> only accepts state fields that have a numeric type.
*/
- protected abstract class AcceptableTypeVisitor extends AbstractExpressionVisitor {
+ protected static abstract class AcceptableTypeVisitor extends AbstractExpressionVisitor {
/**
* The type that is retrieved based on the expression, it determines what is acceptable.
@@ -5504,6 +5565,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static for performance reasons.
/**
* This visitor scans the visited {@link Expression} and determines if a JPQL identifier can be
* added ("appended") when the position of the cursor is at the end of the expression.
@@ -5521,9 +5583,14 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* identifiers are allowed, but the logical and compound identifiers.</li>
* </ul>
*/
- protected class AppendableExpressionVisitor extends AbstractAppendableExpressionVisitor {
+ protected static class AppendableExpressionVisitor extends AbstractAppendableExpressionVisitor {
- /**
+ /**
+ * Enclosing visitor instance.
+ */
+ protected final AbstractContentAssistVisitor visitor;
+
+ /**
* The type of the JPQL identifiers can can be possible proposals.
*/
protected AppendableType appendableType;
@@ -5563,10 +5630,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
/**
* Creates a new <code>AppendableExpressionVisitor</code>.
*/
- protected AppendableExpressionVisitor() {
- super();
- this.positionInCollection = -1;
- }
+ AppendableExpressionVisitor(AbstractContentAssistVisitor visitor) {
+ super();
+ this.visitor = visitor;
+ this.positionInCollection = -1;
+ }
/**
* {@inheritDoc}
@@ -5651,7 +5719,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
// Example 1: "x between y SQRT(e.age)" is seen as complete
if (!expression.hasAnd()) {
- String variable = queryContext.literal(
+ String variable = visitor.queryContext.literal(
expression.getUpperBoundExpression(),
LiteralType.IDENTIFICATION_VARIABLE
);
@@ -5999,7 +6067,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
else if (clauseOfItems || (!clauseOfItems && (appendableType == AppendableType.CLAUSE))) {
appendable = !hasComma &&
(positionInCollection > -1) &&
- !isFollowingInvalidExpression(expression);
+ !visitor.isFollowingInvalidExpression(expression);
}
else {
@@ -6231,7 +6299,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
// Example: "NOT B" can only have compound identifiers like 'NOT BETWEEN'
if (expression.hasExpression()) {
- String variable = queryContext.literal(
+ String variable = visitor.queryContext.literal(
expression.getExpression(),
LiteralType.IDENTIFICATION_VARIABLE
);
@@ -6509,7 +6577,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
else {
// Resolve the mapping so we can determine what is valid based on its type
- IMapping mapping = queryContext.getMapping(expression);
+ IMapping mapping = visitor.queryContext.getMapping(expression);
if (mapping == null) {
appendable = false;
@@ -6521,11 +6589,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
case ARITHMETIC: {
// e.name (String) cannot be followed by +,-,/,*
// e.age (int) can be followed by an arithmetic operator
- appendable = queryContext.getTypeHelper().isNumericType(type);
+ appendable = visitor.queryContext.getTypeHelper().isNumericType(type);
break;
}
case COMPARISON: {
- TypeHelper typeHelper = queryContext.getTypeHelper();
+ TypeHelper typeHelper = visitor.queryContext.getTypeHelper();
appendable = !typeHelper.isCollectionType(type) &&
!typeHelper.isMapType(type);
break;
@@ -6536,7 +6604,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
break;
}
case LOGICAL: {
- appendable = queryContext.getTypeHelper().isBooleanType(type);
+ appendable = visitor.queryContext.getTypeHelper().isBooleanType(type);
break;
}
}
@@ -6710,10 +6778,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static for performance reasons.
/**
* This is used to determine how {@link AppendableExpressionVisitor} should perform the check.
*/
- protected enum AppendableType {
+ protected static enum AppendableType {
/**
* Determines whether the arithmetic operators (+, -, *, /) can be appended as valid proposals.
@@ -6756,11 +6825,12 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
SUBQUERY
}
+ // Made static for performance reasons.
/**
* This helper is used to determine how to add proposals within a collection of expressions. Each
* expression is usually separated by either a whitespace or by a comma.
*/
- protected interface CollectionExpressionHelper<T extends Expression> {
+ protected static interface CollectionExpressionHelper<T extends Expression> {
/**
* Adds the proposals because the cursor is at the end of the child at the given position.
@@ -6865,10 +6935,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
JPQLQueryBNF queryBNF(T expression, int index);
}
+ // Made static final for performance reasons.
/**
* This visitor retrieves the {@link CollectionExpression} if it is visited.
*/
- protected static class CollectionExpressionVisitor extends AbstractExpressionVisitor {
+ protected static final class CollectionExpressionVisitor extends AbstractExpressionVisitor {
/**
* The {@link CollectionExpression} if it is the {@link Expression} that was visited.
@@ -6891,7 +6962,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class CollectionMappingFilter implements Filter<IMapping> {
+ // Made static final for performance reasons.
+ protected static final class CollectionMappingFilter implements Filter<IMapping> {
/**
* {@inheritDoc}
@@ -6904,9 +6976,15 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class ConcatExpressionCollectionHelper implements CollectionExpressionHelper<ConcatExpression> {
+ // Made static final for performance reasons.
+ protected static final class ConcatExpressionCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<ConcatExpression> {
- /**
+ protected ConcatExpressionCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public void addAtTheEndOfChild(ConcatExpression expression,
@@ -6924,18 +7002,18 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
if ((index == 0) && !virtualSpace) {
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
}
else {
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
- if (areComparisonSymbolsAppendable(child)) {
- addComparisonIdentifiers(child);
+ if (visitor.areComparisonSymbolsAppendable(child)) {
+ visitor.addComparisonIdentifiers(child);
}
}
}
@@ -6945,9 +7023,9 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(ConcatExpression expression, String identifier) {
- proposals.addIdentifier(identifier);
- addIdentificationVariables();
- addFunctionIdentifiers(expression.getParent().findQueryBNF(expression));
+ visitor.proposals.addIdentifier(identifier);
+ visitor.addIdentificationVariables();
+ visitor.addFunctionIdentifiers(expression.getParent().findQueryBNF(expression));
}
/**
@@ -6958,15 +7036,15 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
int index,
boolean hasComma) {
- addIdentificationVariables();
- addFunctionIdentifiers(queryBNF(expression, index));
+ visitor.addIdentificationVariables();
+ visitor.addFunctionIdentifiers(queryBNF(expression, index));
}
/**
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(ConcatExpression expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getExpression());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getExpression());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -7009,20 +7087,26 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(ConcatExpression expression, int index) {
- return getQueryBNF(expression.getEncapsulatedExpressionQueryBNFId());
+ return visitor.getQueryBNF(expression.getEncapsulatedExpressionQueryBNFId());
}
+
}
+ // Made static final for performance reasons.
/**
* This helpers handles adding proposals for {@link AbstractConditionalClause}.
*/
- protected class ConditionalClauseCollectionHelper extends AbstractConditionalClauseCollectionHelper<AbstractConditionalClause> {
+ protected static final class ConditionalClauseCollectionHelper extends AbstractConditionalClauseCollectionHelper<AbstractConditionalClause> {
- /**
+ protected ConditionalClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(AbstractConditionalClause expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getConditionalExpression());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getConditionalExpression());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -7037,7 +7121,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class ConstrutorCollectionHelper implements CollectionExpressionHelper<ConstructorExpression> {
+ // Made static final for performance reasons.
+ protected static final class ConstrutorCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<ConstructorExpression> {
+
+ protected ConstrutorCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
@@ -7057,18 +7147,18 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
if ((index == 0) && !virtualSpace) {
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
}
else {
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
- if (areComparisonSymbolsAppendable(child)) {
- addComparisonIdentifiers(child);
+ if (visitor.areComparisonSymbolsAppendable(child)) {
+ visitor.addComparisonIdentifiers(child);
}
}
}
@@ -7078,7 +7168,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(ConstructorExpression expression, String identifier) {
- proposals.addIdentifier(identifier);
+ visitor.proposals.addIdentifier(identifier);
}
/**
@@ -7089,15 +7179,15 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
int index,
boolean hasComma) {
- addIdentificationVariables(expression, IdentificationVariableType.ALL);
- addFunctionIdentifiers(ConstructorItemBNF.ID);
+ visitor.addIdentificationVariables(expression, IdentificationVariableType.ALL);
+ visitor.addFunctionIdentifiers(ConstructorItemBNF.ID);
}
/**
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(ConstructorExpression expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getConstructorItems());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getConstructorItems());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -7142,11 +7232,12 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(ConstructorExpression expression, int index) {
- return AbstractContentAssistVisitor.this.getQueryBNF(ConstructorItemBNF.ID);
+ return visitor.getQueryBNF(ConstructorItemBNF.ID);
}
}
- protected class DeclarationVisitor extends AnonymousExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class DeclarationVisitor extends AnonymousExpressionVisitor {
/**
* Indicates if the visited {@link CollectionValuedPathExpression} is found within a
@@ -7189,10 +7280,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static final for performance reasons.
/**
* The default implementation of {@link MappingCollector}, which simply returns an empty collection.
*/
- protected class DefaultMappingCollector implements MappingCollector {
+ protected static final class DefaultMappingCollector implements MappingCollector {
/**
* {@inheritDoc}
@@ -7202,9 +7294,15 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class DeleteClauseCollectionHelper implements CollectionExpressionHelper<DeleteClause> {
+ // Made static final for performance reasons.
+ protected static final class DeleteClauseCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<DeleteClause> {
- /**
+ protected DeleteClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public void addAtTheEndOfChild(DeleteClause expression,
@@ -7218,7 +7316,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(DeleteClause expression, String identifier) {
- proposals.addIdentifier(identifier);
+ visitor.proposals.addIdentifier(identifier);
}
/**
@@ -7230,7 +7328,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
boolean hasComma) {
if (index == 0) {
- addEntities();
+ visitor.addEntities();
}
}
@@ -7238,7 +7336,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(DeleteClause expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getRangeVariableDeclaration());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getRangeVariableDeclaration());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -7280,17 +7378,23 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(DeleteClause expression, int index) {
- return getQueryBNF(RangeVariableDeclarationBNF.ID);
+ return visitor.getQueryBNF(RangeVariableDeclarationBNF.ID);
}
}
- protected class DeleteClauseStatementHelper implements StatementHelper<DeleteStatement> {
+ // Made static final for performance reasons.
+ protected static final class DeleteClauseStatementHelper
+ extends AbstractVisitorHelper implements StatementHelper<DeleteStatement> {
+
+ protected DeleteClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addIdentifier(DELETE_FROM);
+ visitor.addIdentifier(DELETE_FROM);
}
/**
@@ -7311,7 +7415,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public WhereClauseDeleteStatementHelper getNextHelper() {
- return getWhereClauseDeleteStatementHelper();
+ return visitor.getWhereClauseDeleteStatementHelper();
}
/**
@@ -7332,7 +7436,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(DeleteStatement expression) {
- return isComplete(expression.getDeleteClause());
+ return visitor.isComplete(expression.getDeleteClause());
}
/**
@@ -7343,8 +7447,9 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class DifferentComparisonFilter extends AnonymousExpressionVisitor
- implements Filter<Expression> {
+ // Made static final for performance reasons.
+ protected static final class DifferentComparisonFilter
+ extends AnonymousExpressionVisitor implements Filter<Expression> {
/**
* Determines whether '<', '<=', '>=', '>' are valid comparison operators.
@@ -7381,7 +7486,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class DoubleEncapsulatedCollectionHelper implements CollectionExpressionHelper<AbstractDoubleEncapsulatedExpression> {
+ // Made static final for performance reasons.
+ protected static final class DoubleEncapsulatedCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<AbstractDoubleEncapsulatedExpression> {
+
+ protected DoubleEncapsulatedCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
@@ -7401,18 +7512,18 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
if ((index == 0) && !virtualSpace) {
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
}
else {
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
- if (areComparisonSymbolsAppendable(child)) {
- addComparisonIdentifiers(child);
+ if (visitor.areComparisonSymbolsAppendable(child)) {
+ visitor.addComparisonIdentifiers(child);
}
}
}
@@ -7422,9 +7533,9 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(AbstractDoubleEncapsulatedExpression expression, String identifier) {
- proposals.addIdentifier(identifier);
- addIdentificationVariables();
- addFunctionIdentifiers(expression.getParent().findQueryBNF(expression));
+ visitor.proposals.addIdentifier(identifier);
+ visitor.addIdentificationVariables();
+ visitor.addFunctionIdentifiers(expression.getParent().findQueryBNF(expression));
}
/**
@@ -7435,8 +7546,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
int index,
boolean hasComma) {
- addIdentificationVariables();
- addFunctionIdentifiers(queryBNF(expression, index));
+ visitor.addIdentificationVariables();
+ visitor.addFunctionIdentifiers(queryBNF(expression, index));
}
/**
@@ -7483,11 +7594,12 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(AbstractDoubleEncapsulatedExpression expression, int index) {
- return getQueryBNF(expression.parameterExpressionBNF(index));
+ return visitor.getQueryBNF(expression.parameterExpressionBNF(index));
}
}
- protected class EncapsulatedExpressionVisitor extends AnonymousExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class EncapsulatedExpressionVisitor extends AnonymousExpressionVisitor {
/**
* Determines whether the visited {@link Expression} is being encapsulated or not.
@@ -7537,6 +7649,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static for performance reasons.
/**
* This builder populates a {@link QueryPosition} by traversing the valid portion of the JPQL
* query. The position is the end of each {@link Expression}.
@@ -7552,7 +7665,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* <li>IdentificationVariable = 1</li>
* </ul>
*/
- protected class EndingQueryPositionBuilder implements ExpressionVisitor {
+ protected static class EndingQueryPositionBuilder
+ extends AbstractVisitorHelper implements ExpressionVisitor {
/**
* This internal flag helps to determine if the {@link Expression} where the cursor is located
@@ -7592,6 +7706,10 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
public boolean virtualSpace;
+ protected EndingQueryPositionBuilder(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
/**
* Disposes the internal data.
*/
@@ -7629,7 +7747,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
public void prepare(Expression invalidExpression) {
- QueryPosition oldQueryPosition = AbstractContentAssistVisitor.this.queryPosition;
+ QueryPosition oldQueryPosition = visitor.queryPosition;
this.invalidExpression = invalidExpression;
this.positionWithinInvalidExpression = oldQueryPosition.getPosition(invalidExpression);
@@ -7827,7 +7945,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
if (index > 0) {
Expression previousChild = expression.getChild(index - 1);
- if (!isComplete(previousChild)) {
+ if (!visitor.isComplete(previousChild)) {
queryPosition.setExpression(previousChild);
queryPosition.addPosition(previousChild, previousChild.getLength());
}
@@ -9173,6 +9291,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static final for performance reasons.
/**
* This visitor determines whether a path expression can be resolved as a fully qualified enum
* type and an enum constant.
@@ -9192,7 +9311,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* <li>{@link NullIfExpression} : The second expression;</li>
* </ul>
*/
- protected class EnumVisitor extends AbstractExpressionVisitor {
+ protected static final class EnumVisitor extends AbstractExpressionVisitor {
/**
* The {@link AbstractPathExpression} being scanned for its location within the JPQL query.
@@ -9326,11 +9445,12 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static final for performance reasons.
/**
* This {@link MappingCollector} returns the possible mappings (non-collection type or
* collection type) from a managed type.
*/
- protected class FilteringMappingCollector implements MappingCollector {
+ protected static final class FilteringMappingCollector implements MappingCollector {
/**
* The {@link Filter} used to filter out either the collection type properties or the non-
@@ -9408,7 +9528,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class FollowingClausesVisitor extends AbstractTraverseParentVisitor {
+ // Made static for performance reasons.
+ protected static class FollowingClausesVisitor extends AbstractTraverseParentVisitor {
/**
* The JPQL identifier of the clause used to determine if there is any clause defined after it.
@@ -9612,7 +9733,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class FollowingInvalidExpressionVisitor extends AbstractTraverseParentVisitor {
+ // Made static final for performance reasons.
+ protected static final class FollowingInvalidExpressionVisitor extends AbstractTraverseParentVisitor {
+
+ /**
+ * Enclosing visitor instance.
+ */
+ protected final AbstractContentAssistVisitor visitor;
/**
* The {@link Expression} used to determine if it follows an invalid fragment or not.
@@ -9624,6 +9751,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
protected boolean followingInvalidExpression;
+ protected FollowingInvalidExpressionVisitor(AbstractContentAssistVisitor visitor) {
+ super();
+ this.visitor = visitor;
+ }
+
/**
* Disposes of the internal data.
*/
@@ -9662,7 +9794,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
// Check to see if an expression before the index is invalid
while (--index >= 0) {
Expression child = expression.getChild(index);
- followingInvalidExpression = isInvalidExpression(child);
+ followingInvalidExpression = visitor.isInvalidExpression(child);
if (followingInvalidExpression) {
index = -1;
@@ -9680,7 +9812,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class FromClauseCollectionHelper implements CollectionExpressionHelper<AbstractFromClause> {
+ // Made static for performance reasons.
+ protected static class FromClauseCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<AbstractFromClause> {
+
+ protected FromClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
@@ -9697,9 +9835,9 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
if (((index == 0) || hasComma) && virtualSpace) {
// "... JOIN e.mananager m |" <- Valid to add JOIN identifiers
// "... JOIN e.mananager m ON e.name |" <- Invalid to add JOIN identifiers
- if (isComplete(collectionExpression.getChild(0))) {
- addJoinIdentifiers();
- AbstractContentAssistVisitor.this.addIdentifier(ON);
+ if (visitor.isComplete(collectionExpression.getChild(0))) {
+ visitor.addJoinIdentifiers();
+ visitor.addIdentifier(ON);
}
}
// Special case to handle a range variable declaration that can also
@@ -9709,14 +9847,14 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
if ((index > 0) && end && !hasComma) {
- int position = queryPosition.getPosition();
+ int position = visitor.queryPosition.getPosition();
- if (!hasClausesDefinedBetween(expression, FROM, HAVING)) {
- addCompositeIdentifier(GROUP_BY, 4 /* GROUP - 1 */);
+ if (!visitor.hasClausesDefinedBetween(expression, FROM, HAVING)) {
+ visitor.addCompositeIdentifier(GROUP_BY, 4 /* GROUP - 1 */);
}
- if (!hasClausesDefinedBetween(expression, FROM, ORDER_BY)) {
- addCompositeIdentifier(ORDER_BY, 4 /* ORDER - 1 */);
+ if (!visitor.hasClausesDefinedBetween(expression, FROM, ORDER_BY)) {
+ visitor.addCompositeIdentifier(ORDER_BY, 4 /* ORDER - 1 */);
}
}
}
@@ -9726,7 +9864,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(AbstractFromClause expression, String identifier) {
- proposals.addIdentifier(identifier);
+ visitor.proposals.addIdentifier(identifier);
}
/**
@@ -9741,12 +9879,12 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
// 2. To be valid elsewhere, the declarations have to be separated by a comma
// "SELECT e FROM Employee e W|" <- entity names are not valid proposals, only 'WHERE' is
if ((index == 0) || hasComma) {
- addEntities();
+ visitor.addEntities();
}
// In any other case, the JOIN identifiers are the only valid choices
// "SELECT e FROM Employee e J|" <- only 'JOIN' and 'JOIN FETCH' are valid proposals
else if ((index > 0) && !hasComma) {
- addJoinIdentifiers();
+ visitor.addJoinIdentifiers();
}
// The identifier for a collection member declaration can only be added
@@ -9755,7 +9893,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
// "SELECT e FROM Employee e, I|" <- 'IN' is a valid proposal
// "SELECT e FROM Employee e I|" <- 'IN' is NOT a valid proposal
if ((index > 0) && hasComma) {
- AbstractContentAssistVisitor.this.addIdentifier(IN);
+ visitor.addIdentifier(IN);
}
}
@@ -9763,7 +9901,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(AbstractFromClause expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getDeclaration());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getDeclaration());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -9805,23 +9943,34 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(AbstractFromClause expression, int index) {
- return getQueryBNF(expression.getDeclarationQueryBNFId());
+ return visitor.getQueryBNF(expression.getDeclarationQueryBNFId());
}
}
- protected class FromClauseStatementHelper extends AbstractFromClauseStatementHelper<SelectStatement> {
+ // Made static for performance reasons.
+ protected static class FromClauseStatementHelper extends AbstractFromClauseStatementHelper<SelectStatement> {
+
+ protected FromClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public WhereClauseSelectStatementHelper getNextHelper() {
- return getWhereClauseSelectStatementHelper();
+ return visitor.getWhereClauseSelectStatementHelper();
}
}
- protected class GroupByClauseCollectionHelper implements CollectionExpressionHelper<GroupByClause> {
+ // Made static final for performance reasons.
+ protected static final class GroupByClauseCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<GroupByClause> {
- /**
+ protected GroupByClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public void addAtTheEndOfChild(GroupByClause expression,
@@ -9835,7 +9984,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(GroupByClause expression, String identifier) {
- proposals.addIdentifier(identifier);
+ visitor.proposals.addIdentifier(identifier);
}
/**
@@ -9847,8 +9996,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
boolean hasComma) {
if ((index == 0) || hasComma) {
- addFunctionIdentifiers(GroupByItemBNF.ID);
- addIdentificationVariables();
+ visitor.addFunctionIdentifiers(GroupByItemBNF.ID);
+ visitor.addIdentificationVariables();
}
}
@@ -9856,7 +10005,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(GroupByClause expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getGroupByItems());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getGroupByItems());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -9898,27 +10047,37 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(GroupByClause expression, int index) {
- return AbstractContentAssistVisitor.this.getQueryBNF(GroupByItemBNF.ID);
+ return visitor.getQueryBNF(GroupByItemBNF.ID);
}
}
- protected class GroupByClauseStatementHelper extends AbstractGroupByClauseStatementHelper<SelectStatement> {
+ // Made static final for performance reasons.
+ protected static final class GroupByClauseStatementHelper extends AbstractGroupByClauseStatementHelper<SelectStatement> {
+
+ protected GroupByClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public HavingClauseStatementHelper getNextHelper() {
- return getHavingClauseStatementHelper();
+ return visitor.getHavingClauseStatementHelper();
}
}
- protected class HavingClauseStatementHelper extends AbstractHavingClauseStatementHelper<SelectStatement> {
+ // Made static final for performance reasons.
+ protected static final class HavingClauseStatementHelper extends AbstractHavingClauseStatementHelper<SelectStatement> {
+
+ protected HavingClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public OrderByClauseStatementHelper getNextHelper() {
- return getOrderByClauseStatementHelper();
+ return visitor.getOrderByClauseStatementHelper();
}
/**
@@ -9929,10 +10088,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static for performance reasons.
/**
* The various ways of retrieving identification variables from the declaration expression.
*/
- protected enum IdentificationVariableType {
+ protected static enum IdentificationVariableType {
/**
* Retrieves all the identification variables declared in the declaration portion of the
@@ -10121,6 +10281,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
Expression expression);
}
+ // Made static for performance reasons.
/**
* This visitor is used when a clause or a compound expression was parsed with a collection of
* expressions representing an invalid fragment.
@@ -10132,7 +10293,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* this one just means it's incomplete and "GROUP B" is the beginning of the <code><b>GROUP BY</b></code>
* clause.
*/
- protected class IncompleteCollectionExpressionVisitor extends AbstractExpressionVisitor {
+ protected static class IncompleteCollectionExpressionVisitor extends AbstractExpressionVisitor {
/**
* The clause being visited, which is marked by its JPQL identifier.
@@ -10317,11 +10478,12 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static final for performance reasons.
/**
* This visitor determines if the visited {@link Expression} is one of the two that represents
* an invalid expression.
*/
- protected static class InvalidExpressionVisitor extends AbstractExpressionVisitor {
+ protected static final class InvalidExpressionVisitor extends AbstractExpressionVisitor {
/**
* The invalid {@link Expression}, which is either {@link UnknownExpression} or {@link BadExpression}.
@@ -10362,7 +10524,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class JoinCollectionHelper implements CollectionExpressionHelper<IdentificationVariableDeclaration> {
+ // Made static final for performance reasons.
+ protected static final class JoinCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<IdentificationVariableDeclaration> {
+
+ protected JoinCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
@@ -10378,7 +10546,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(IdentificationVariableDeclaration expression, String identifier) {
- proposals.addIdentifier(identifier);
+ visitor.proposals.addIdentifier(identifier);
}
/**
@@ -10389,14 +10557,14 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
int index,
boolean hasComma) {
- addJoinIdentifiers();
+ visitor.addJoinIdentifiers();
}
/**
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(IdentificationVariableDeclaration expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getJoins());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getJoins());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -10438,15 +10606,16 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(IdentificationVariableDeclaration expression, int index) {
- return AbstractContentAssistVisitor.this.getQueryBNF(InternalJoinBNF.ID);
+ return visitor.getQueryBNF(InternalJoinBNF.ID);
}
}
+ // Made static for performance reasons.
/**
* A collector is responsible to retrieve the possible proposals by using the mappings that can
* complete a path expression.
*/
- protected interface MappingCollector {
+ protected static interface MappingCollector {
/**
* Retrieves the possible proposals that can be used to complete a path expression based on
@@ -10457,17 +10626,28 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
Collection<IMapping> buildProposals();
}
+ // Made static final for performance reasons.
/**
* This visitor is responsible to create the right {@link Filter} based on the type of the {@link Expression}.
*/
- protected class MappingFilterBuilder extends AbstractTraverseParentVisitor {
+ protected static final class MappingFilterBuilder extends AbstractTraverseParentVisitor {
- /**
+ /**
+ * Enclosing visitor instance.
+ */
+ protected final AbstractContentAssistVisitor visitor;
+
+ /**
* The {@link Filter} that will filter the various type of {@link IMapping IMappings} based
* on the location of the of the path expression within the JPQL query.
*/
protected Filter<IMapping> filter;
+ protected MappingFilterBuilder(AbstractContentAssistVisitor visitor) {
+ super();
+ this.visitor = visitor;
+ }
+
/**
* Disposes of the internal data.
*/
@@ -10480,7 +10660,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(AbsExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10488,7 +10668,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(AvgFunction expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10496,7 +10676,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(BetweenExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10504,7 +10684,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(CoalesceExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10512,7 +10692,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(CollectionMemberDeclaration expression) {
- filter = getMappingCollectionFilter();
+ filter = visitor.getMappingCollectionFilter();
}
/**
@@ -10520,7 +10700,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(CollectionValuedPathExpression expression) {
- filter = getMappingCollectionFilter();
+ filter = visitor.getMappingCollectionFilter();
}
/**
@@ -10528,7 +10708,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(ConcatExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10536,7 +10716,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(CountFunction expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10544,7 +10724,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(EmptyCollectionComparisonExpression expression) {
- filter = getMappingCollectionFilter();
+ filter = visitor.getMappingCollectionFilter();
}
/**
@@ -10552,7 +10732,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(FunctionExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10573,7 +10753,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(Join expression) {
- filter = getMappingCollectionFilter();
+ filter = visitor.getMappingCollectionFilter();
}
/**
@@ -10581,7 +10761,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(JPQLExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10589,7 +10769,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(LengthExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10597,7 +10777,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(LocateExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10605,7 +10785,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(LowerExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10613,7 +10793,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(MaxFunction expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10621,7 +10801,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(MinFunction expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10629,7 +10809,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(ModExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10637,7 +10817,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(NullComparisonExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10658,7 +10838,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(SizeExpression expression) {
- filter = getMappingCollectionFilter();
+ filter = visitor.getMappingCollectionFilter();
}
/**
@@ -10666,7 +10846,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(SqrtExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10674,7 +10854,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(SubstringExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10682,7 +10862,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(SumFunction expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10690,7 +10870,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(TreatExpression expression) {
- filter = getMappingCollectionFilter();
+ filter = visitor.getMappingCollectionFilter();
}
/**
@@ -10698,7 +10878,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(TrimExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10706,7 +10886,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*/
@Override
public void visit(UpperExpression expression) {
- filter = getMappingPropertyFilter();
+ filter = visitor.getMappingPropertyFilter();
}
/**
@@ -10736,11 +10916,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static final for performance reasons.
/**
* This {@link Filter} is responsible to filter out the mappings that can't have their type
* assignable to the one passed in.
*/
- protected class MappingTypeFilter implements Filter<IMapping> {
+ protected static final class MappingTypeFilter
+ extends AbstractVisitorHelper implements Filter<IMapping> {
/**
* The type used to determine if the mapping's type is a valid type.
@@ -10752,8 +10934,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
*
* @param type The type used to determine if the mapping's type is a valid type
*/
- MappingTypeFilter(IType type) {
- super();
+ MappingTypeFilter(IType type, AbstractContentAssistVisitor visitor) {
+ super(visitor);
this.type = type;
}
@@ -10771,12 +10953,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
// Determine if it's assignable to the desired type
IType mappingType = value.getType();
- mappingType = queryContext.getTypeHelper().convertPrimitive(mappingType);
+ mappingType = visitor.queryContext.getTypeHelper().convertPrimitive(mappingType);
return mappingType.isAssignableTo(type);
}
}
- protected class NotExpressionVisitor extends AbstractExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class NotExpressionVisitor extends AbstractExpressionVisitor {
/**
* The {@link NotExpression} if it is the {@link Expression} being visited otherwise <code>null</code>.
@@ -10809,7 +10992,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class OrderByClauseCollectionHelper implements CollectionExpressionHelper<AbstractOrderByClause> {
+ // Made static final for performance reasons.
+ protected static final class OrderByClauseCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<AbstractOrderByClause> {
+
+ protected OrderByClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
@@ -10823,8 +11012,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
OrderByItem item = (OrderByItem) collectionExpression.getChild(index);
if (item.getOrdering() == Ordering.DEFAULT) {
- AbstractContentAssistVisitor.this.addIdentifier(ASC);
- AbstractContentAssistVisitor.this.addIdentifier(DESC);
+ visitor.addIdentifier(ASC);
+ visitor.addIdentifier(DESC);
}
}
@@ -10832,7 +11021,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(AbstractOrderByClause expression, String identifier) {
- proposals.addIdentifier(identifier);
+ visitor.proposals.addIdentifier(identifier);
}
/**
@@ -10844,8 +11033,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
boolean hasComma) {
if ((index == 0) || hasComma) {
- addIdentificationVariables();
- addResultVariables();
+ visitor.addIdentificationVariables();
+ visitor.addResultVariables();
}
}
@@ -10853,7 +11042,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(AbstractOrderByClause expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getOrderByItems());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getOrderByItems());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -10895,17 +11084,23 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(AbstractOrderByClause expression, int index) {
- return AbstractContentAssistVisitor.this.getQueryBNF(OrderByItemBNF.ID);
+ return visitor.getQueryBNF(OrderByItemBNF.ID);
}
}
- protected class OrderByClauseStatementHelper implements StatementHelper<SelectStatement> {
+ // Made static for performance reasons.
+ protected static class OrderByClauseStatementHelper
+ extends AbstractVisitorHelper implements StatementHelper<SelectStatement> {
+
+ protected OrderByClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addCompositeIdentifier(ORDER_BY, -1);
+ visitor.addCompositeIdentifier(ORDER_BY, -1);
}
/**
@@ -10947,7 +11142,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(SelectStatement expression) {
- return isComplete(expression.getOrderByClause());
+ return visitor.isComplete(expression.getOrderByClause());
}
/**
@@ -10958,7 +11153,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class PropertyMappingFilter implements Filter<IMapping> {
+ // Made static final for performance reasons.
+ protected static final class PropertyMappingFilter implements Filter<IMapping> {
/**
* {@inheritDoc}
@@ -10969,7 +11165,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class RangeVariableDeclarationVisitor extends AbstractExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class RangeVariableDeclarationVisitor extends AbstractExpressionVisitor {
/**
* The {@link RangeVariableDeclaration} if it was visited otherwise <code>null</code>.
@@ -10992,7 +11189,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class ResultVariableVisitor extends AbstractExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class ResultVariableVisitor extends AbstractExpressionVisitor {
/**
* The {@link ResultVariable} if it was visited otherwise <code>null</code>.
@@ -11015,9 +11213,14 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class SelectClauseCollectionHelper extends AbstractSelectClauseCollectionHelper<SelectClause> {
+ // Made static final for performance reasons.
+ protected static final class SelectClauseCollectionHelper extends AbstractSelectClauseCollectionHelper<SelectClause> {
- /**
+ protected SelectClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -11033,8 +11236,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
// "SELECT e |" <- Valid to add AS
// "SELECT AVG(e |" <- Invalid to add AS
- if (virtualSpace && isComplete(child)) {
- AbstractContentAssistVisitor.this.addIdentifier(AS);
+ if (virtualSpace && visitor.isComplete(child)) {
+ visitor.addIdentifier(AS);
}
}
@@ -11050,7 +11253,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
super.addTheBeginningOfChild(expression, collectionExpression, index, hasComma);
if (index == 0) {
- AbstractContentAssistVisitor.this.addIdentifier(DISTINCT);
+ visitor.addIdentifier(DISTINCT);
}
}
@@ -11074,37 +11277,57 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class SelectClauseStatementHelper extends AbstractSelectClauseStatementHelper {
+ // Made static final for performance reasons.
+ protected static final class SelectClauseStatementHelper extends AbstractSelectClauseStatementHelper {
+
+ protected SelectClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public FromClauseStatementHelper getNextHelper() {
- return getFromClauseStatementHelper();
+ return visitor.getFromClauseStatementHelper();
}
}
- protected class SimpleFromClauseStatementHelper extends AbstractFromClauseStatementHelper<SimpleSelectStatement> {
+ // Made static for performance reasons.
+ protected static class SimpleFromClauseStatementHelper extends AbstractFromClauseStatementHelper<SimpleSelectStatement> {
+
+ protected SimpleFromClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public SimpleWhereClauseSelectStatementHelper getNextHelper() {
- return getSimpleWhereClauseSelectStatementHelper();
+ return visitor.getSimpleWhereClauseSelectStatementHelper();
}
}
- protected class SimpleGroupByClauseStatementHelper extends AbstractGroupByClauseStatementHelper<SimpleSelectStatement> {
+ // Made static final for performance reasons.
+ protected static final class SimpleGroupByClauseStatementHelper extends AbstractGroupByClauseStatementHelper<SimpleSelectStatement> {
+
+ protected SimpleGroupByClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public SimpleHavingClauseStatementHelper getNextHelper() {
- return getSimpleHavingClauseStatementHelper();
+ return visitor.getSimpleHavingClauseStatementHelper();
}
}
- protected class SimpleHavingClauseStatementHelper extends AbstractHavingClauseStatementHelper<SimpleSelectStatement> {
+ // Made static final for performance reasons.
+ protected static final class SimpleHavingClauseStatementHelper extends AbstractHavingClauseStatementHelper<SimpleSelectStatement> {
+
+ protected SimpleHavingClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
@@ -11121,34 +11344,51 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class SimpleSelectClauseCollectionHelper extends AbstractSelectClauseCollectionHelper<SimpleSelectClause> {
+ // Made static final for performance reasons.
+ protected static final class SimpleSelectClauseCollectionHelper extends AbstractSelectClauseCollectionHelper<SimpleSelectClause> {
+
+ protected SimpleSelectClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
}
- protected class SimpleSelectClauseStatementHelper extends AbstractSelectClauseStatementHelper {
+ // Made static final for performance reasons.
+ protected static final class SimpleSelectClauseStatementHelper extends AbstractSelectClauseStatementHelper {
+
+ protected SimpleSelectClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public StatementHelper<SimpleSelectStatement> getNextHelper() {
- return getSimpleFromClauseStatementHelper();
+ return visitor.getSimpleFromClauseStatementHelper();
}
}
- protected class SimpleWhereClauseSelectStatementHelper extends AbstractWhereClauseSelectStatementHelper<SimpleSelectStatement> {
+ // Made static final for performance reasons.
+ protected static final class SimpleWhereClauseSelectStatementHelper extends AbstractWhereClauseSelectStatementHelper<SimpleSelectStatement> {
- /**
+ protected SimpleWhereClauseSelectStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public StatementHelper<SimpleSelectStatement> getNextHelper() {
- return getSimpleGroupByClauseStatementHelper();
+ return visitor.getSimpleGroupByClauseStatementHelper();
}
}
+ // Made static for performance reasons.
/**
* This helper helps to add JPQL identifiers for the clauses that make up a query statement and
* also chains the clauses within the query.
*/
- protected interface StatementHelper<T extends Expression> {
+ protected static interface StatementHelper<T extends Expression> {
/**
* Adds the JPQL identifier of the clause being scanned by this helper.
@@ -11220,7 +11460,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
boolean isRequired();
}
- protected class SubqueryAppendableExpressionVisitor extends AbstractAppendableExpressionVisitor {
+ // Made static final for performance reasons.
+ protected static final class SubqueryAppendableExpressionVisitor extends AbstractAppendableExpressionVisitor {
/**
* For a subquery <code><b>SELECT</b></code> clause identifier to be appendable, it has to be
@@ -11255,10 +11496,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static final for performance reasons.
/**
* This visitor determines if an {@link Expression} is in a subquery.
*/
- protected class SubqueryVisitor extends AbstractTraverseParentVisitor {
+ protected static final class SubqueryVisitor extends AbstractTraverseParentVisitor {
/**
* The subquery {@link Expression} if it's the first clause visitor. Otherwise it will be
@@ -11292,9 +11534,15 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class TripleEncapsulatedCollectionHelper implements CollectionExpressionHelper<AbstractTripleEncapsulatedExpression> {
+ // Made static final for performance reasons.
+ protected static final class TripleEncapsulatedCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<AbstractTripleEncapsulatedExpression> {
- /**
+ protected TripleEncapsulatedCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public void addAtTheEndOfChild(AbstractTripleEncapsulatedExpression expression,
@@ -11312,18 +11560,18 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
if ((index == 0) && !virtualSpace) {
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
}
else {
- if (areArithmeticSymbolsAppendable(child)) {
- addArithmeticIdentifiers();
+ if (visitor.areArithmeticSymbolsAppendable(child)) {
+ visitor.addArithmeticIdentifiers();
}
- if (areComparisonSymbolsAppendable(child)) {
- addComparisonIdentifiers(child);
+ if (visitor.areComparisonSymbolsAppendable(child)) {
+ visitor.addComparisonIdentifiers(child);
}
}
}
@@ -11333,8 +11581,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public void addIdentifier(AbstractTripleEncapsulatedExpression expression, String identifier) {
- proposals.addIdentifier(identifier);
- addFunctionIdentifiers(expression);
+ visitor.proposals.addIdentifier(identifier);
+ visitor.addFunctionIdentifiers(expression);
}
/**
@@ -11345,8 +11593,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
int index,
boolean hasComma) {
- addIdentificationVariables();
- addFunctionIdentifiers(queryBNF(expression, index));
+ visitor.addIdentificationVariables();
+ visitor.addFunctionIdentifiers(queryBNF(expression, index));
}
/**
@@ -11393,17 +11641,23 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(AbstractTripleEncapsulatedExpression expression, int index) {
- return getQueryBNF(expression.getParameterQueryBNFId(index));
+ return visitor.getQueryBNF(expression.getParameterQueryBNFId(index));
}
}
- protected class UpdateClauseStatementHelper implements StatementHelper<UpdateStatement> {
+ // Made static final for performance reasons.
+ protected static final class UpdateClauseStatementHelper
+ extends AbstractVisitorHelper implements StatementHelper<UpdateStatement> {
- /**
+ protected UpdateClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addIdentifier(UPDATE);
+ visitor.addIdentifier(UPDATE);
}
/**
@@ -11424,7 +11678,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public StatementHelper<UpdateStatement> getNextHelper() {
- return getWhereClauseUpdateStatementHelper();
+ return visitor.getWhereClauseUpdateStatementHelper();
}
/**
@@ -11445,7 +11699,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(UpdateStatement expression) {
- return isComplete(expression.getUpdateClause());
+ return visitor.isComplete(expression.getUpdateClause());
}
/**
@@ -11456,7 +11710,13 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class UpdateItemCollectionHelper implements CollectionExpressionHelper<UpdateClause> {
+ // Made static final for performance reasons.
+ protected static final class UpdateItemCollectionHelper
+ extends AbstractVisitorHelper implements CollectionExpressionHelper<UpdateClause> {
+
+ protected UpdateItemCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
@@ -11467,14 +11727,14 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
boolean hasComma,
boolean virtualSpace) {
- addAggregateIdentifiers(NewValueBNF.ID);
+ visitor.addAggregateIdentifiers(NewValueBNF.ID);
}
/**
* {@inheritDoc}
*/
public void addIdentifier(UpdateClause expression, String identifier) {
- proposals.addIdentifier(identifier);
+ visitor.proposals.addIdentifier(identifier);
}
/**
@@ -11485,14 +11745,14 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
int index,
boolean hasComma) {
- addIdentificationVariables();
+ visitor.addIdentificationVariables();
}
/**
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(UpdateClause expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getUpdateItems());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getUpdateItems());
if (collectionExpression == null) {
collectionExpression = expression.buildCollectionExpression();
}
@@ -11539,10 +11799,11 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public JPQLQueryBNF queryBNF(UpdateClause expression, int index) {
- return AbstractContentAssistVisitor.this.getQueryBNF(NewValueBNF.ID);
+ return visitor.getQueryBNF(NewValueBNF.ID);
}
}
+ // Made static final for performance reasons.
/**
* This visitor is meant to adjust the corrections stack when traversing an {@link Expression} in
* order to increase the list of valid proposals.
@@ -11552,14 +11813,23 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* However, due to how {@link AbstractContentAssistVisitor} works, the identifier <code>INDEX</code>
* is not added as a valid proposal. This visitor adds that functionality.
*/
- protected class VisitParentVisitor extends AnonymousExpressionVisitor {
+ protected static final class VisitParentVisitor extends AnonymousExpressionVisitor {
+
+ /**
+ * Enclosing visitor instance.
+ */
+ protected final AbstractContentAssistVisitor visitor;
+
+ protected VisitParentVisitor(AbstractContentAssistVisitor visitor) {
+ this.visitor = visitor;
+ }
/**
* {@inheritDoc}
*/
@Override
protected void visit(Expression expression) {
- expression.getParent().accept(AbstractContentAssistVisitor.this);
+ expression.getParent().accept(visitor);
}
/**
@@ -11568,7 +11838,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
@Override
public void visit(InExpression expression) {
- int position = queryPosition.getPosition(expression) - corrections.peek();
+ int position = visitor.queryPosition.getPosition(expression) - visitor.corrections.peek();
int length = 0;
if (expression.hasExpression()) {
@@ -11576,19 +11846,19 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
// Within "IN"
- if (isPositionWithin(position, length, expression.getIdentifier())) {
+ if (visitor.isPositionWithin(position, length, expression.getIdentifier())) {
boolean hasOnlyIdentifier = !expression.hasExpression() &&
!expression.hasInItems();
if (hasOnlyIdentifier) {
- corrections.add(queryPosition.getPosition(expression));
+ visitor.corrections.add(visitor.queryPosition.getPosition(expression));
}
super.visit(expression);
if (hasOnlyIdentifier) {
- corrections.pop();
+ visitor.corrections.pop();
}
}
else {
@@ -11597,16 +11867,21 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
+ // Made static final for performance reasons.
/**
* This helpers handles adding proposals for {@link WhenClause}.
*/
- protected class WhenClauseConditionalClauseCollectionHelper extends AbstractConditionalClauseCollectionHelper<WhenClause> {
+ protected static final class WhenClauseConditionalClauseCollectionHelper extends AbstractConditionalClauseCollectionHelper<WhenClause> {
- /**
+ protected WhenClauseConditionalClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public CollectionExpression buildCollectionExpression(WhenClause expression) {
- CollectionExpression collectionExpression = getCollectionExpression(expression.getWhenExpression());
+ CollectionExpression collectionExpression = visitor.getCollectionExpression(expression.getWhenExpression());
if (collectionExpression == null) {
collectionExpression = expression.buildWhenCollectionExpression();
}
@@ -11621,13 +11896,19 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class WhereClauseDeleteStatementHelper implements StatementHelper<DeleteStatement> {
+ // Made static final for performance reasons.
+ protected static final class WhereClauseDeleteStatementHelper
+ extends AbstractVisitorHelper implements StatementHelper<DeleteStatement> {
- /**
+ protected WhereClauseDeleteStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addIdentifier(WHERE);
+ visitor.addIdentifier(WHERE);
}
/**
@@ -11669,7 +11950,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(DeleteStatement expression) {
- return isComplete(expression.getWhereClause());
+ return visitor.isComplete(expression.getWhereClause());
}
/**
@@ -11680,23 +11961,34 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class WhereClauseSelectStatementHelper extends AbstractWhereClauseSelectStatementHelper<SelectStatement> {
+ // Made static final for performance reasons.
+ protected static final class WhereClauseSelectStatementHelper extends AbstractWhereClauseSelectStatementHelper<SelectStatement> {
+
+ protected WhereClauseSelectStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public StatementHelper<SelectStatement> getNextHelper() {
- return getGroupByClauseStatementHelper();
+ return visitor.getGroupByClauseStatementHelper();
}
}
- protected class WhereClauseUpdateStatementHelper implements StatementHelper<UpdateStatement> {
+ // Made static final for performance reasons.
+ protected static final class WhereClauseUpdateStatementHelper
+ extends AbstractVisitorHelper implements StatementHelper<UpdateStatement> {
+
+ protected WhereClauseUpdateStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
/**
* {@inheritDoc}
*/
public void addClauseProposals() {
- addIdentifier(WHERE);
+ visitor.addIdentifier(WHERE);
}
/**
@@ -11738,7 +12030,7 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
* {@inheritDoc}
*/
public boolean isClauseComplete(UpdateStatement expression) {
- return isComplete(expression.getWhereClause());
+ return visitor.isComplete(expression.getWhereClause());
}
/**
@@ -11749,7 +12041,8 @@ public abstract class AbstractContentAssistVisitor extends AnonymousExpressionVi
}
}
- protected class WithinInvalidExpressionVisitor extends AbstractTraverseParentVisitor {
+ // Made static final for performance reasons.
+ protected static final class WithinInvalidExpressionVisitor extends AbstractTraverseParentVisitor {
/**
* Determines whether the visited {@link Expression} is an descendant of either a bad or
diff --git a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/EclipseLinkContentAssistVisitor.java b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/EclipseLinkContentAssistVisitor.java
index 9904ebb..12629b2 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/EclipseLinkContentAssistVisitor.java
+++ b/jpa/org.eclipse.persistence.jpa.jpql/src/org/eclipse/persistence/jpa/jpql/tools/EclipseLinkContentAssistVisitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -14,6 +14,7 @@
package org.eclipse.persistence.jpa.jpql.tools;
import java.util.List;
+
import org.eclipse.persistence.jpa.jpql.EclipseLinkVersion;
import org.eclipse.persistence.jpa.jpql.ExpressionTools;
import org.eclipse.persistence.jpa.jpql.LiteralType;
@@ -49,6 +50,7 @@ import org.eclipse.persistence.jpa.jpql.parser.TableVariableDeclaration;
import org.eclipse.persistence.jpa.jpql.parser.UnionClause;
import org.eclipse.persistence.jpa.jpql.tools.ContentAssistProposals.ClassType;
import org.eclipse.persistence.jpa.jpql.tools.resolver.Declaration;
+
import static org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.*;
import static org.eclipse.persistence.jpa.jpql.parser.Expression.*;
@@ -92,7 +94,7 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
*/
@Override
protected AppendableExpressionVisitor buildAppendableExpressionVisitor() {
- return new AppendableExpressionVisitor();
+ return new AppendableExpressionVisitor(this);
}
/**
@@ -100,7 +102,7 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
*/
@Override
protected EndingQueryPositionBuilder buildEndingQueryPositionBuilder() {
- return new EndingQueryPositionBuilder();
+ return new EndingQueryPositionBuilder(this);
}
/**
@@ -116,7 +118,7 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
*/
@Override
protected FromClauseCollectionHelper buildFromClauseCollectionHelper() {
- return new FromClauseCollectionHelper();
+ return new FromClauseCollectionHelper(this);
}
/**
@@ -124,7 +126,7 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
*/
@Override
protected FromClauseStatementHelper buildFromClauseStatementHelper() {
- return new FromClauseStatementHelper();
+ return new FromClauseStatementHelper(this);
}
/**
@@ -132,7 +134,7 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
*/
@Override
protected GroupByClauseCollectionHelper buildGroupByClauseCollectionHelper() {
- return new GroupByClauseCollectionHelper();
+ return new GroupByClauseCollectionHelper(this);
}
/**
@@ -148,7 +150,7 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
*/
@Override
protected OrderByClauseStatementHelper buildOrderByClauseStatementHelper() {
- return new OrderByClauseStatementHelper();
+ return new OrderByClauseStatementHelper(this);
}
/**
@@ -156,7 +158,7 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
*/
@Override
protected SimpleFromClauseStatementHelper buildSimpleFromClauseStatementHelper() {
- return new SimpleFromClauseStatementHelper();
+ return new SimpleFromClauseStatementHelper(this);
}
protected TableExpressionVisitor buildTableExpressionVisitor() {
@@ -769,13 +771,18 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
}
}
- protected class AcceptableTypeVisitor extends AbstractContentAssistVisitor.AcceptableTypeVisitor {
+ // Made static final for performance reasons.
+ protected static final class AcceptableTypeVisitor extends AbstractContentAssistVisitor.AcceptableTypeVisitor {
}
- protected class AppendableExpressionVisitor extends AbstractContentAssistVisitor.AppendableExpressionVisitor
+ // Made static final for performance reasons.
+ protected static final class AppendableExpressionVisitor extends AbstractContentAssistVisitor.AppendableExpressionVisitor
implements EclipseLinkExpressionVisitor {
+ AppendableExpressionVisitor(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
- /**
+ /**
* {@inheritDoc}
*/
public void visit(AsOfClause expression) {
@@ -892,10 +899,15 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
}
}
- protected class EndingQueryPositionBuilder extends AbstractContentAssistVisitor.EndingQueryPositionBuilder
+ // Made static final for performance reasons.
+ protected static final class EndingQueryPositionBuilder extends AbstractContentAssistVisitor.EndingQueryPositionBuilder
implements EclipseLinkExpressionVisitor {
- /**
+ protected EndingQueryPositionBuilder(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
public void visit(AsOfClause expression) {
@@ -1103,10 +1115,11 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
}
}
+ // Made static final for performance reasons.
/**
* This visitor adds support for the additional clauses provided by EclipseLink, such as the
*/
- protected class FollowingClausesVisitor extends AbstractContentAssistVisitor.FollowingClausesVisitor {
+ protected static final class FollowingClausesVisitor extends AbstractContentAssistVisitor.FollowingClausesVisitor {
protected boolean hasAsOfClause;
protected boolean hasConnectByClause;
@@ -1281,7 +1294,11 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
protected class FromClauseCollectionHelper extends AbstractContentAssistVisitor.FromClauseCollectionHelper {
- /**
+ protected FromClauseCollectionHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -1396,6 +1413,10 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
protected class FromClauseStatementHelper extends AbstractContentAssistVisitor.FromClauseStatementHelper {
+ protected FromClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
/**
* {@inheritDoc}
*/
@@ -1448,6 +1469,10 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
protected class OrderByClauseStatementHelper extends AbstractContentAssistVisitor.OrderByClauseStatementHelper {
+ protected OrderByClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
/**
* {@inheritDoc}
*/
@@ -1467,6 +1492,10 @@ public class EclipseLinkContentAssistVisitor extends AbstractContentAssistVisito
protected class SimpleFromClauseStatementHelper extends AbstractContentAssistVisitor.SimpleFromClauseStatementHelper {
+ protected SimpleFromClauseStatementHelper(AbstractContentAssistVisitor visitor) {
+ super(visitor);
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/CMP3Policy.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/CMP3Policy.java
index 7393645..21ec126 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/CMP3Policy.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/CMP3Policy.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -463,13 +463,13 @@ public class CMP3Policy extends CMPPolicy {
noSuchElementException = null;
break;
}
- }
-
- try {
- pkAttributes[i] = new FieldAccessor(getField(currentKeyClass, fieldName), fieldName, field, mapping, currentKeyClass != keyClass);
- fieldToAccessorMap.put(field, pkAttributes[i]);
- noSuchElementException = null;
- } catch (NoSuchFieldException ex) {
+ }
+
+ try {
+ pkAttributes[i] = new FieldAccessor(this, getField(currentKeyClass, fieldName), fieldName, field, mapping, currentKeyClass != keyClass);
+ fieldToAccessorMap.put(field, pkAttributes[i]);
+ noSuchElementException = null;
+ } catch (NoSuchFieldException ex) {
String getMethodName = null;
String setMethodName = null;
if(mapping.isObjectReferenceMapping() && ((ObjectReferenceMapping)mapping).getIndirectionPolicy().isWeavedObjectBasicIndirectionPolicy()) {
@@ -502,13 +502,13 @@ public class CMP3Policy extends CMPPolicy {
} catch (PrivilegedActionException exception) {
throw (NoSuchMethodException)exception.getException();
}
- } else {
- setMethod = PrivilegedAccessHelper.getMethod(currentKeyClass, setMethodName, new Class[] {getMethod.getReturnType()}, true);
- }
- pkAttributes[i] = new PropertyAccessor(getMethod, setMethod, fieldName, field, mapping, currentKeyClass != keyClass);
- this.fieldToAccessorMap.put(field, pkAttributes[i]);
- noSuchElementException = null;
- } catch (NoSuchMethodException exs) {
+ } else {
+ setMethod = PrivilegedAccessHelper.getMethod(currentKeyClass, setMethodName, new Class[] {getMethod.getReturnType()}, true);
+ }
+ pkAttributes[i] = new PropertyAccessor(this, getMethod, setMethod, fieldName, field, mapping, currentKeyClass != keyClass);
+ this.fieldToAccessorMap.put(field, pkAttributes[i]);
+ noSuchElementException = null;
+ } catch (NoSuchMethodException exs) {
// not a field not a method, but a pk class is defined. Check for other mappings
noSuchElementException = exs;
}
@@ -545,28 +545,21 @@ public class CMP3Policy extends CMPPolicy {
* INTERNAL:
* @return Returns the keyClassFields.
*/
- protected KeyElementAccessor[] getKeyClassFields() {
- return this.keyClassFields;
- }
-
- /**
- * INTERNAL:
- * This class is used when the key class element is a property
- */
- private class PropertyAccessor implements KeyElementAccessor {
- protected Method getMethod;
- protected Method setMethod;
- protected String attributeName;
- protected DatabaseField databaseField;
- protected DatabaseMapping mapping;
- protected boolean isNestedAccessor;
-
- public PropertyAccessor(Method getMethod, Method setMethod, String attributeName, DatabaseField field, DatabaseMapping mapping, boolean isNestedAccessor) {
- this.getMethod = getMethod;
- this.setMethod = setMethod;
- this.attributeName = attributeName;
- this.databaseField = field;
- this.mapping = mapping;
+ protected KeyElementAccessor[] getKeyClassFields() {
+ return this.keyClassFields;
+ }
+
+ // Made static for performance reasons.
+ private static abstract class CommonAccessor implements KeyElementAccessor {
+ private final String attributeName;
+ private final DatabaseField databaseField;
+ protected final DatabaseMapping mapping;
+ private final boolean isNestedAccessor;
+
+ public CommonAccessor(String attributeName, DatabaseField field, DatabaseMapping mapping, boolean isNestedAccessor) {
+ this.attributeName = attributeName;
+ this.databaseField = field;
+ this.mapping = mapping;
this.isNestedAccessor = isNestedAccessor;
}
@@ -574,16 +567,39 @@ public class CMP3Policy extends CMPPolicy {
return this.attributeName;
}
- public DatabaseField getDatabaseField() {
- return this.databaseField;
- }
-
- public DatabaseMapping getMapping() {
- return this.mapping;
- }
-
- public Object getValue(Object object, AbstractSession session) {
- try {
+ public DatabaseField getDatabaseField() {
+ return this.databaseField;
+ }
+
+ public DatabaseMapping getMapping() {
+ return this.mapping;
+ }
+
+ public boolean isNestedAccessor() {
+ return isNestedAccessor;
+ }
+
+ }
+
+ // Made static final for performance reasons.
+ /**
+ * INTERNAL:
+ * This class is used when the key class element is a property
+ */
+ private static final class PropertyAccessor extends CommonAccessor {
+ private final Method getMethod;
+ private final Method setMethod;
+ private final CMPPolicy policy;
+
+ public PropertyAccessor(CMPPolicy policy, Method getMethod, Method setMethod, String attributeName, DatabaseField databaseField, DatabaseMapping mapping, boolean isNestedAccessor) {
+ super(attributeName, databaseField, mapping, isNestedAccessor);
+ this.getMethod = getMethod;
+ this.setMethod = setMethod;
+ this.policy = policy;
+ }
+
+ public Object getValue(Object object, AbstractSession session) {
+ try {
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
return AccessController.doPrivileged(new PrivilegedMethodInvoker(this.getMethod, object, new Object[] { }));
@@ -596,20 +612,16 @@ public class CMP3Policy extends CMPPolicy {
}
}
} else {
- return PrivilegedAccessHelper.invokeMethod(this.getMethod, object, new Object[] { });
- }
- } catch (Exception ex) {
- throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), ex);
- }
- }
-
- public boolean isNestedAccessor() {
- return isNestedAccessor;
- }
-
- public void setValue(Object object, Object value) {
- try {
- if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
+ return PrivilegedAccessHelper.invokeMethod(this.getMethod, object, new Object[] { });
+ }
+ } catch (Exception ex) {
+ throw DescriptorException.errorUsingPrimaryKey(object, policy.getDescriptor(), ex);
+ }
+ }
+
+ public void setValue(Object object, Object value) {
+ try {
+ if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
AccessController.doPrivileged(new PrivilegedMethodInvoker(this.setMethod, object, new Object[] {value}));
} catch (PrivilegedActionException exception) {
@@ -621,124 +633,82 @@ public class CMP3Policy extends CMPPolicy {
}
}
} else {
- PrivilegedAccessHelper.invokeMethod(this.setMethod, object, new Object[] {value});
- }
- } catch (Exception ex) {
- throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), ex);
- }
- }
- }
-
+ PrivilegedAccessHelper.invokeMethod(this.setMethod, object, new Object[] {value});
+ }
+ } catch (Exception ex) {
+ throw DescriptorException.errorUsingPrimaryKey(object, policy.getDescriptor(), ex);
+ }
+ }
+ }
+
+ // Made static final for performance reasons.
/**
- * INTERNAL:
- * This class will be used when the element of the keyclass is a field
- */
- private class FieldAccessor implements KeyElementAccessor, Serializable {
- protected Field field;
- protected String attributeName;
- protected DatabaseField databaseField;
- protected DatabaseMapping mapping;
- protected boolean isNestedAccessor;
-
- public FieldAccessor(Field field, String attributeName, DatabaseField databaseField, DatabaseMapping mapping, boolean isNestedAccessor) {
- this.field = field;
- this.attributeName = attributeName;
- this.databaseField = databaseField;
- this.mapping = mapping;
- this.isNestedAccessor = isNestedAccessor;
- }
-
- public String getAttributeName() {
- return this.attributeName;
- }
-
- public DatabaseField getDatabaseField() {
- return this.databaseField;
- }
-
- public DatabaseMapping getMapping() {
- return this.mapping;
- }
-
- public Object getValue(Object object, AbstractSession session) {
- try {
- if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
- try {
- return AccessController.doPrivileged(new PrivilegedGetValueFromField(field, object));
- } catch (PrivilegedActionException exception) {
- throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), exception.getException()); }
- } else {
- return org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getValueFromField(field, object);
- }
- } catch (Exception ex) {
- throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), ex);
- }
- }
-
- public boolean isNestedAccessor() {
- return isNestedAccessor;
- }
-
- public void setValue(Object object, Object value) {
- try {
- Field pkField = null;
+ * INTERNAL:
+ * This class will be used when the element of the keyclass is a field
+ */
+ private static final class FieldAccessor extends CommonAccessor implements Serializable {
+ private final Field field;
+ private final CMPPolicy policy;
+
+ public FieldAccessor(CMPPolicy policy, Field field, String attributeName, DatabaseField databaseField, DatabaseMapping mapping, boolean isNestedAccessor) {
+ super(attributeName, databaseField, mapping, isNestedAccessor);
+ this.field = field;
+ this.policy = policy;
+ }
+
+ public Object getValue(Object object, AbstractSession session) {
+ try {
+ if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
+ try {
+ return AccessController.doPrivileged(new PrivilegedGetValueFromField(field, object));
+ } catch (PrivilegedActionException exception) {
+ throw DescriptorException.errorUsingPrimaryKey(object, policy.getDescriptor(), exception.getException()); }
+ } else {
+ return org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getValueFromField(field, object);
+ }
+ } catch (Exception ex) {
+ throw DescriptorException.errorUsingPrimaryKey(object, policy.getDescriptor(), ex);
+ }
+ }
+
+ public void setValue(Object object, Object value) {
+ try {
+ Field pkField = null;
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
- pkField = (Field)AccessController.doPrivileged(new PrivilegedGetField(object.getClass(), field.getName(), true));
- AccessController.doPrivileged(new PrivilegedSetValueInField(pkField, object, value));
- } catch (PrivilegedActionException exception) {
- throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), exception.getException());
- }
- } else {
- pkField = PrivilegedAccessHelper.getField(object.getClass(), field.getName(), true);
- PrivilegedAccessHelper.setValueInField(pkField, object, value);
- }
- } catch (Exception ex) {
- throw DescriptorException.errorUsingPrimaryKey(object, getDescriptor(), ex);
- }
- }
- }
-
+ pkField = (Field)AccessController.doPrivileged(new PrivilegedGetField(object.getClass(), field.getName(), true));
+ AccessController.doPrivileged(new PrivilegedSetValueInField(pkField, object, value));
+ } catch (PrivilegedActionException exception) {
+ throw DescriptorException.errorUsingPrimaryKey(object, policy.getDescriptor(), exception.getException());
+ }
+ } else {
+ pkField = PrivilegedAccessHelper.getField(object.getClass(), field.getName(), true);
+ PrivilegedAccessHelper.setValueInField(pkField, object, value);
+ }
+ } catch (Exception ex) {
+ throw DescriptorException.errorUsingPrimaryKey(object, policy.getDescriptor(), ex);
+ }
+ }
+ }
+
+ // Made static final for performance reasons.
/**
- * INTERNAL:
- * This class will be used when the element of the keyclass is a virtual field.
- */
- private class ValuesFieldAccessor implements KeyElementAccessor {
- protected String attributeName;
- protected DatabaseField databaseField;
- protected DatabaseMapping mapping;
- protected boolean isNestedAccessor;
-
- public ValuesFieldAccessor(String attributeName, DatabaseField databaseField, DatabaseMapping mapping, boolean isNestedAccessor) {
- this.attributeName = attributeName;
- this.databaseField = databaseField;
- this.mapping = mapping;
- this.isNestedAccessor = isNestedAccessor;
- }
-
- public String getAttributeName() {
- return this.attributeName;
- }
-
- public DatabaseField getDatabaseField() {
- return this.databaseField;
- }
-
- public DatabaseMapping getMapping() {
- return this.mapping;
- }
-
- public Object getValue(Object object, AbstractSession session) {
- return mapping.getRealAttributeValueFromObject(object, session);
- }
-
- public boolean isNestedAccessor() {
- return isNestedAccessor;
- }
-
- public void setValue(Object object, Object value) {
- mapping.setRealAttributeValueInObject(object, value);
- }
+ * INTERNAL:
+ * This class will be used when the element of the keyclass is a virtual field.
+ */
+ private static final class ValuesFieldAccessor extends CommonAccessor {
+
+ public ValuesFieldAccessor(String attributeName, DatabaseField databaseField, DatabaseMapping mapping, boolean isNestedAccessor) {
+ super(attributeName, databaseField, mapping, isNestedAccessor);
+ }
+
+ public Object getValue(Object object, AbstractSession session) {
+ return mapping.getRealAttributeValueFromObject(object, session);
+ }
+
+ public void setValue(Object object, Object value) {
+ mapping.setRealAttributeValueInObject(object, value);
+ }
}
/**
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java
index 8ff24db..d8d4f56 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -477,8 +477,8 @@ public class EntityManagerSetupImpl implements MetadataRefreshListener {
}
}
- protected static String buildSessionNameSuffixFromConnectionProperties(Map properties) {
- String suffix = "";
+ protected static String buildSessionNameSuffixFromConnectionProperties(Map properties) {
+ StringBuilder suffix = new StringBuilder(32);
for (int i=0; i < connectionPropertyNames.length; i++) {
String name = connectionPropertyNames[i];
Object value = properties.get(name);
@@ -498,11 +498,11 @@ public class EntityManagerSetupImpl implements MetadataRefreshListener {
}
// don't set an empty String
if (strValue.length() > 0) {
- suffix += "_" + Helper.getShortClassName(name) + "=" + strValue;
+ suffix.append("_").append(Helper.getShortClassName(name)).append("=").append(strValue);
}
}
}
- return suffix;
+ return suffix.toString();
}
/*
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/deployment/JavaSECMPInitializer.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/deployment/JavaSECMPInitializer.java
index 9afcbbc..8f3ab4b 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/deployment/JavaSECMPInitializer.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/deployment/JavaSECMPInitializer.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -295,13 +295,13 @@ public class JavaSECMPInitializer extends JPAInitializer {
* class loader away. Transformers can then be registered on the real class loader to allow
* weaving to occur.
*
- * It selectively loads classes based on the list of classnames it is instantiated with. Classes
- * not on that list are allowed to be loaded by the parent.
- */
- public class TempEntityLoader extends URLClassLoader {
- Collection classNames;
- boolean shouldOverrideLoadClassForCollectionMembers;
-
+ * It selectively loads classes based on the list of classnames it is instantiated with. Classes
+ * not on that list are allowed to be loaded by the parent.
+ */
+ public static class TempEntityLoader extends URLClassLoader {
+ Collection classNames;
+ boolean shouldOverrideLoadClassForCollectionMembers;
+
//added to resolved gf #589 - without this, the orm.xml url would be returned twice
public Enumeration<URL> getResources(String name) throws java.io.IOException {
return this.getParent().getResources(name);
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/ORMetadata.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/ORMetadata.java
index f88a17d..0db6e22 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/ORMetadata.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/ORMetadata.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -928,15 +928,17 @@ public abstract class ORMetadata {
}
}
+ // Made static final for performance reasons.
/**
- * INTERNAL:
- * Internal class to represent java type objects. XML only.
- */
- private class SimpleORMetadata extends ORMetadata {
- private Object m_value;
-
- /**
- * INTERNAL:
+ * INTERNAL:
+ * Internal class to represent java type objects. XML only.
+ */
+ private static final class SimpleORMetadata extends ORMetadata {
+ // Final only for style and performance reasons.
+ private final Object m_value;
+
+ /**
+ * INTERNAL:
*/
public SimpleORMetadata(Object value, MetadataAccessibleObject accessibleObject, XMLEntityMappings entityMappings, String xmlElement) {
super(xmlElement);
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/MetadataHelper.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/MetadataHelper.java
new file mode 100644
index 0000000..1484c9c
--- /dev/null
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/MetadataHelper.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Tomas Kraus - Initial API and implementation
+ ******************************************************************************/
+package org.eclipse.persistence.internal.jpa.metadata.accessors;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.persistence.internal.helper.StringHelper;
+
+/**
+ * <p><b>Purpose</b>: Define any useful static methods to manipulate with descriptors content.</p>
+ */
+public class MetadataHelper {
+
+ /**
+ * This class is just an envelope for static methods so no instances are allowed.
+ */
+ private MetadataHelper() {
+ throw new UnsupportedOperationException("Instances of MetadataHelper are not allowed");
+ }
+
+ /**
+ * Append list of columns from descriptor class to provided {@link StringBuilder}.
+ * Use to create content of columns brackets in <code>INSERT INTO table (col1, col1) VALUES ...</code>.
+ * @param target Target {@link StringBuilder}.
+ * @param mappings Object attributes mappings.
+ * @param separator String to separate values in list.
+ */
+ public static void buildColsFromMappings(final StringBuilder target,
+ final Collection<? extends MetadataAccessor> mappings, final String separator) {
+ for (Iterator<? extends MetadataAccessor> i = mappings.iterator(); i.hasNext(); ) {
+ target.append(i.next().getName().toUpperCase());
+ if (i.hasNext()) {
+ target.append(separator);
+ }
+ }
+ }
+
+ /**
+ * Append list of values as list of question marks from descriptor class to provided
+ * {@link StringBuilder}.
+ * Use to create content of <code>VALUES</code> brackets in <code>INSERT INTO table ... VALUES (?, ?) ...</code>.
+ * @param target Target {@link StringBuilder}.
+ * @param mappings Object attributes mappings.
+ * @param separator String to separate values in list.
+ */
+ public static void buildValuesAsQMarksFromMappings(final StringBuilder target,
+ final Collection<? extends MetadataAccessor> mappings, final String separator) {
+ final int count = mappings.size();
+ if (count > 0) {
+ for (int i = 0; i < count; i++) {
+ if (i > 0) {
+ target.append(separator);
+ }
+ target.append(StringHelper.QUESTION_MARK);
+ }
+ }
+ }
+
+ /**
+ * Append list of column to value bindings from descriptor class to provided {@link StringBuilder}.
+ * Use to create value to column bindings of <code>SET</code> content in <code>UPDATE table SET col1 = ?2 WHERE ...</code>
+ * @param target Target {@link StringBuilder}.
+ * @param mappings Object attributes mappings.
+ * @param valueIndex First value index in column to value bindings (e.g.
+ * <code>column = ?&gt;valueIndex&gt;</code>).
+ * @param binder String to bind value to column (e.g. <code>" = "</code>
+ * in <code>column = ?&gt;valueIndex&gt;</code>).
+ * @param separator String to separate values in list.
+ */
+ public static void buildColsAndValuesBindingsFromMappings(final StringBuilder target,
+ final Collection<? extends MetadataAccessor> mappings,
+ final int valueIndex, final String binder, final String separator) {
+ int idx = valueIndex;
+ for (Iterator<? extends MetadataAccessor> i = mappings.iterator(); i.hasNext();) {
+ target.append(i.next().getName()).append(binder).append(Integer.toString(++idx));
+ if (i.hasNext()) {
+ target.append(separator);
+ }
+ }
+
+ }
+
+}
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/classes/ConverterAccessor.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/classes/ConverterAccessor.java
index 15d293a..e3c6133 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/classes/ConverterAccessor.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/classes/ConverterAccessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -162,13 +162,13 @@ public class ConverterAccessor extends ORMetadata {
// any generic specifications, e.g. List<String>. We need to be able to
// distinguish between List<String> and List<Integer> etc. to correctly
// handle the auto-apply feature for basics.
- String attributeClassificationName = "";
+ StringBuilder attributeClassificationName = new StringBuilder(32);
for (int i = 2; i < genericTypesSize - 1; i++) {
- attributeClassificationName += genericTypes.get(i);
+ attributeClassificationName.append(genericTypes.get(i));
}
// Cache the classification classes.
- attributeClassification = getMetadataClass(attributeClassificationName);
+ attributeClassification = getMetadataClass(attributeClassificationName.toString());
fieldClassification = getMetadataClass(genericTypes.get(genericTypesSize - 1));
}
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAnnotatedElement.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAnnotatedElement.java
index fbe8d9b..5f21b16 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAnnotatedElement.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAnnotatedElement.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -337,19 +337,20 @@ public class MetadataAnnotatedElement extends MetadataAccessibleObject {
*/
public MetadataClass getRawClassWithGenerics(MetadataDescriptor descriptor) {
if (m_rawClassWithGenerics == null) {
- MetadataClass rawClass = getRawClass(descriptor);
-
- if (getGenericType() != null && (! getGenericType().isEmpty()) && getGenericType().size() > 1) {
- String rawClassName = rawClass.getName();
-
- for (int i = 1; i < getGenericType().size(); i++) {
- rawClassName += getGenericType().get(i);
- }
-
- m_rawClassWithGenerics = getMetadataClass(rawClassName);
- } else {
- m_rawClassWithGenerics = rawClass;
- }
+ MetadataClass rawClass = getRawClass(descriptor);
+
+ if (getGenericType() != null && (! getGenericType().isEmpty()) && getGenericType().size() > 1) {
+ StringBuilder rawClassName = new StringBuilder(32);
+ rawClassName.append(rawClass.getName());
+
+ for (int i = 1; i < getGenericType().size(); i++) {
+ rawClassName.append(getGenericType().get(i));
+ }
+
+ m_rawClassWithGenerics = getMetadataClass(rawClassName.toString());
+ } else {
+ m_rawClassWithGenerics = rawClass;
+ }
}
return m_rawClassWithGenerics;
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/IndexMetadata.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/IndexMetadata.java
index 60976f8..1586539 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/IndexMetadata.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/tables/IndexMetadata.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -20,12 +20,13 @@ package org.eclipse.persistence.internal.jpa.metadata.tables;
import java.util.ArrayList;
import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.persistence.internal.helper.DatabaseTable;
-import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
-import org.eclipse.persistence.internal.jpa.metadata.ORMetadata;
-import org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor;
+import java.util.StringTokenizer;
+
+import org.eclipse.persistence.internal.helper.DatabaseTable;
+import org.eclipse.persistence.internal.helper.StringHelper;
+import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor;
+import org.eclipse.persistence.internal.jpa.metadata.ORMetadata;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor;
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation;
import org.eclipse.persistence.tools.schemaframework.IndexDefinition;
@@ -42,12 +43,17 @@ import org.eclipse.persistence.tools.schemaframework.IndexDefinition;
* - methods should be preserved in alphabetical order.
*
* @author James Sutherland
- * @since EclipseLink 2.2
- */
-public class IndexMetadata extends ORMetadata {
- private Boolean m_unique;
-
- private String m_name;
+ * @since EclipseLink 2.2
+ */
+public class IndexMetadata extends ORMetadata {
+ /** Name prefix. */
+ private static final String INDEX = "INDEX";
+ /** Name parts separator. */
+ private static final char FIELD_SEP = '_';
+
+ private Boolean m_unique;
+
+ private String m_name;
private String m_schema;
private String m_catalog;
private String m_table;
@@ -295,21 +301,30 @@ public class IndexMetadata extends ORMetadata {
* Process the name. If specified it, use it, otherwise create a default.
* e.g. INDEX_tablename_field1_field2_.....
*/
- protected String processName(DatabaseTable table, IndexDefinition indexDefinition) {
- if (hasName()) {
- return m_name;
- } else {
- String name = "INDEX_" + table.getName();
-
- // Append all the field names to it.
- for (String field : indexDefinition.getFields()) {
- name = name + "_" + field;
- }
-
- return name;
- }
- }
-
+ protected String processName(DatabaseTable table, IndexDefinition indexDefinition) {
+ if (hasName()) {
+ return m_name;
+ } else {
+ String tableName = StringHelper.nonNullString(table.getName());
+ // Calculate name length to avoid StringBuilder resizing
+ int length = INDEX.length() + 1 + tableName.length();
+ for (String field : indexDefinition.getFields()) {
+ length += 1;
+ length += StringHelper.nonNullString(field).length();
+ }
+ // Build name
+ StringBuilder name = new StringBuilder(length);
+ name.append(INDEX).append(FIELD_SEP).append(tableName);
+ // Append all the field names to it.
+ for (String field : indexDefinition.getFields()) {
+ name.append(FIELD_SEP);
+ name.append(StringHelper.nonNullString(field));
+ }
+
+ return name.toString();
+ }
+ }
+
/**
* INTERNAL:
* Used for OX mapping.
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/AnnotationsProcessor.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/AnnotationsProcessor.java
index ef6ac94..5bf5956 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/AnnotationsProcessor.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/AnnotationsProcessor.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -4596,15 +4596,16 @@ public class AnnotationsProcessor {
return generatedClass;
}
+ // Made static final for performance reasons.
/**
* Inner class used for ordering a list of Properties alphabetically by
- * property name.
- *
- */
- class PropertyComparitor implements Comparator<Property> {
- public int compare(Property p1, Property p2) {
- return p1.getPropertyName().compareTo(p2.getPropertyName());
- }
+ * property name.
+ *
+ */
+ private static final class PropertyComparitor implements Comparator<Property> {
+ public int compare(Property p1, Property p2) {
+ return p1.getPropertyName().compareTo(p2.getPropertyName());
+ }
}
private String getNextAvailableClassName(String suggestedName) {
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java
index c128b13..7cac252 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -2719,13 +2719,13 @@ public class MappingsGenerator {
throw JAXBException.invalidReferencedXmlPathOnJoin(className, property.getPropertyName(), referenceClass.getQualifiedName(), referencedXmlPath);
}
}
-
-
- private String prefixCustomXPath(String unprefixedXPath, Property property, NamespaceInfo nsInfo) {
- String newXPath = "";
- QName schemaName = property.getSchemaName();
- String namespace = schemaName.getNamespaceURI();
-
+
+
+ private String prefixCustomXPath(String unprefixedXPath, Property property, NamespaceInfo nsInfo) {
+ StringBuilder newXPath = new StringBuilder(32);
+ QName schemaName = property.getSchemaName();
+ String namespace = schemaName.getNamespaceURI();
+
if (null == namespace || namespace.equals(Constants.EMPTY_STRING)) {
return unprefixedXPath;
}
@@ -2739,82 +2739,81 @@ public class MappingsGenerator {
while (st.hasMoreTokens()) {
String nextToken = st.nextToken();
- if (st.hasMoreTokens()) {
- if (nextToken.lastIndexOf(Constants.COLON) != -1) {
- // Token already has a user-supplied prefix
- newXPath += nextToken;
- } else {
- newXPath += prefix + Constants.COLON + nextToken;
- }
- newXPath += Constants.XPATH_SEPARATOR;
- } else {
- // Last token is text()
- newXPath += nextToken;
- }
-
- }
- return newXPath;
- }
-
- public Field getXPathForField(Property property, NamespaceInfo namespaceInfo, boolean isTextMapping, boolean isAny) {
+ if (st.hasMoreTokens()) {
+ if (nextToken.lastIndexOf(Constants.COLON) != -1) {
+ // Token already has a user-supplied prefix
+ newXPath.append(nextToken);
+ } else {
+ newXPath.append(prefix).append(Constants.COLON).append(nextToken);
+ }
+ newXPath.append(Constants.XPATH_SEPARATOR);
+ } else {
+ // Last token is text()
+ newXPath.append(nextToken);
+ }
+
+ }
+ return newXPath.toString();
+ }
+
+ public Field getXPathForField(Property property, NamespaceInfo namespaceInfo, boolean isTextMapping, boolean isAny) {
Field xmlField = null;
String xPath = property.getXmlPath();
if (null != xPath) {
- String newXPath = prefixCustomXPath(xPath, property, namespaceInfo);
- xmlField = new XMLField(newXPath);
- } else {
- xPath = "";
- if (property.isSetXmlElementWrapper()) {
- XmlElementWrapper wrapper = property.getXmlElementWrapper();
- String namespace = wrapper.getNamespace();
+ String newXPath = prefixCustomXPath(xPath, property, namespaceInfo);
+ xmlField = new XMLField(newXPath);
+ } else {
+ StringBuilder xPathBuilder = new StringBuilder();
+ if (property.isSetXmlElementWrapper()) {
+ XmlElementWrapper wrapper = property.getXmlElementWrapper();
+ String namespace = wrapper.getNamespace();
if (namespace.equals(XMLProcessor.DEFAULT)) {
if (namespaceInfo.isElementFormQualified()) {
namespace = namespaceInfo.getNamespace();
} else {
namespace = "";
}
- }
-
- if (namespace.equals("")) {
- xPath += (wrapper.getName() + "/");
- } else {
- String prefix = getPrefixForNamespace(namespace, namespaceInfo.getNamespaceResolverForDescriptor());
- xPath += getQualifiedString(prefix, wrapper.getName() + "/");
- }
-
- if (isAny || property.isMap()) {
- xPath = xPath.substring(0, xPath.length() - 1);
- xmlField = new XMLField(xPath);
- return xmlField;
- }
-
- }
- if (property.isAttribute()) {
- if (property.isSetXmlPath()) {
- xPath += property.getXmlPath();
- } else {
- QName name = property.getSchemaName();
- String namespace = name.getNamespaceURI();
- if (namespace.equals("")) {
- xPath += (ATT + name.getLocalPart());
- } else {
- String prefix = getPrefixForNamespace(namespace, namespaceInfo.getNamespaceResolverForDescriptor());
- xPath += ATT + getQualifiedString(prefix, name.getLocalPart());
- }
- }
- xmlField = new XMLField(xPath);
- } else if (property.isXmlValue()) {
- if(isBinaryData(property.getActualType())){
- xmlField = new XMLField(".");
+ }
+
+ if (namespace.equals("")) {
+ xPathBuilder.append(wrapper.getName()).append("/");
+ } else {
+ String prefix = getPrefixForNamespace(namespace, namespaceInfo.getNamespaceResolverForDescriptor());
+ xPathBuilder.append(getQualifiedString(prefix, wrapper.getName() + "/"));
+ }
+
+ if (isAny || property.isMap()) {
+ xmlField = new XMLField(xPathBuilder.toString());
+ return xmlField;
+ }
+
+ }
+ if (property.isAttribute()) {
+ if (property.isSetXmlPath()) {
+ xPathBuilder.append(property.getXmlPath());
+ } else {
+ QName name = property.getSchemaName();
+ String namespace = name.getNamespaceURI();
+ if (namespace.equals("")) {
+ xPathBuilder.append(ATT).append(name.getLocalPart());
+ } else {
+ String prefix = getPrefixForNamespace(namespace, namespaceInfo.getNamespaceResolverForDescriptor());
+ xPathBuilder.append(ATT).append(getQualifiedString(prefix, name.getLocalPart()));
+ }
+ }
+ xmlField = new XMLField(xPathBuilder.toString());
+ } else if (property.isXmlValue()) {
+ if(isBinaryData(property.getActualType())){
+ xmlField = new XMLField(".");
}else{
xmlField = new XMLField("text()");
- }
- } else {
- QName elementName = property.getSchemaName();
- xmlField = getXPathForElement(xPath, elementName, namespaceInfo, isTextMapping);
- }
- }
-
+ }
+ } else {
+ QName elementName = property.getSchemaName();
+ xmlField = getXPathForElement(xPathBuilder.toString(), elementName, namespaceInfo, isTextMapping);
+ }
+ }
+
QName schemaType = (QName) userDefinedSchemaTypes.get(property.getActualType().getQualifiedName());
if (property.getSchemaType() != null) {
schemaType = property.getSchemaType();
@@ -3249,13 +3248,14 @@ public class MappingsGenerator {
if(generatedMapEntryClasses == null){
generatedMapEntryClasses = new HashMap<MapEntryGeneratedKey, Class>();
}
- return generatedMapEntryClasses;
- }
-
- private class MapEntryGeneratedKey {
- @SuppressWarnings("unused")
- String keyClassName;
- @SuppressWarnings("unused")
+ return generatedMapEntryClasses;
+ }
+
+ // Made static final for performance reasons.
+ private static final class MapEntryGeneratedKey {
+ @SuppressWarnings("unused")
+ String keyClassName;
+ @SuppressWarnings("unused")
String valueClassName;
public MapEntryGeneratedKey(String keyClass, String valueClass){
@@ -3367,6 +3367,7 @@ public class MappingsGenerator {
return areEquals(type, CoreClassConstants.APBYTE) ||areEquals(type, "javax.activation.DataHandler") || areEquals(type, "java.awt.Image") || areEquals(type, "javax.xml.transform.Source") || areEquals(type, "javax.mail.internet.MimeMultipart");
}
+ // Made static final for performance reasons.
/**
* <p>An InstantiationPolicy that does not construct any objects (and therefore
* will not throw validation errors caused by a lack of a no-arg constructor).</p>
@@ -3375,13 +3376,13 @@ public class MappingsGenerator {
* (so we can later set its value through the mapping), but where we will never
* instantiate a Locator from XML (the Locator will be built internally during parsing).</p>
*
- * @see org.eclipse.persistence.internal.descriptors.InstantiationPolicy
- * @see org.xml.sax.Locator
- */
- private class NullInstantiationPolicy extends InstantiationPolicy {
-
- /**
- * Returns a new instance of this InstantiationPolicy's Descriptor's class.
+ * @see org.eclipse.persistence.internal.descriptors.InstantiationPolicy
+ * @see org.xml.sax.Locator
+ */
+ private static final class NullInstantiationPolicy extends InstantiationPolicy {
+
+ /**
+ * Returns a new instance of this InstantiationPolicy's Descriptor's class.
*
* In this case, do nothing and return null.
*/
diff --git a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/SchemaGenerator.java b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/SchemaGenerator.java
index 4f92846..e62a757 100644
--- a/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/SchemaGenerator.java
+++ b/moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/SchemaGenerator.java
@@ -1,8 +1,8 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
@@ -1435,16 +1435,17 @@ public class SchemaGenerator {
return refAttribute;
}
+ // Made static final for performance reasons.
/**
* This class will typically be used when building schema components. It will hold the
* TypeDefParticle (all, sequence, choice), ComplexType, and/or Schema that are to be
- * used by the method that is processing the given property.
- *
- */
- class AddToSchemaResult {
- ComplexType type;
- TypeDefParticle particle;
- Schema schema;
+ * used by the method that is processing the given property.
+ *
+ */
+ private static final class AddToSchemaResult {
+ ComplexType type;
+ TypeDefParticle particle;
+ Schema schema;
ComplexType simpleContentType;
AddToSchemaResult(TypeDefParticle particle, Schema schema) {
diff --git a/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/BaseDBWSBuilderHelper.java b/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/BaseDBWSBuilderHelper.java
index d4b2bdb..149b274 100644
--- a/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/BaseDBWSBuilderHelper.java
+++ b/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/BaseDBWSBuilderHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -30,7 +30,9 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Vector;
import java.util.logging.Level;
+
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.FINEST;
import static java.util.logging.Level.SEVERE;
@@ -50,8 +52,10 @@ import org.eclipse.persistence.exceptions.DBWSException;
import org.eclipse.persistence.expressions.Expression;
import org.eclipse.persistence.expressions.ExpressionBuilder;
import org.eclipse.persistence.internal.databaseaccess.DatabasePlatform;
+import org.eclipse.persistence.internal.descriptors.DescriptorHelper;
import org.eclipse.persistence.internal.helper.ComplexDatabaseType;
import org.eclipse.persistence.internal.helper.DatabaseField;
+import org.eclipse.persistence.internal.helper.StringHelper;
import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings;
import org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappingsWriter;
import org.eclipse.persistence.internal.oxm.XMLConversionManager;
@@ -109,6 +113,7 @@ import org.eclipse.persistence.sessions.factories.XMLProjectWriter;
import org.eclipse.persistence.tools.dbws.NamingConventionTransformer.ElementStyle;
import org.eclipse.persistence.tools.dbws.jdbc.DbColumn;
import org.eclipse.persistence.tools.dbws.jdbc.DbTable;
+
import static org.eclipse.persistence.internal.helper.ClassConstants.APBYTE;
import static org.eclipse.persistence.internal.oxm.schema.SchemaModelGeneratorProperties.ELEMENT_FORM_QUALIFIED_KEY;
import static org.eclipse.persistence.internal.xr.Util.DBWS_OR_LABEL;
@@ -215,7 +220,6 @@ public abstract class BaseDBWSBuilderHelper {
public static final String COMMA_SPACE_STR = COMMA + SINGLE_SPACE;
public static final String EQUALS_BINDING1_STR = " = ?1";
public static final String EQUALS_BINDING_STR = " = ?";
- public static final String QUESTION_STR = "?";
public static final String TIMESTAMP_CLASS = "oracle.sql.TIMESTAMP";
public static final String USER_STR = "user";
public static final String PASSWORD_STR = "password";
@@ -775,28 +779,14 @@ public abstract class BaseDBWSBuilderHelper {
theInstance.setType(theInstanceType);
insertOperation.getParameters().add(theInstance);
dbwsBuilder.xrServiceModel.getOperations().put(insertOperation.getName(), insertOperation);
-
- String sqlStmt = INSERT_STR + tableName + SINGLE_SPACE + OPEN_BRACKET;
- int idx = 1;
- String cols = "";
- for (Iterator j = desc.getMappings().iterator(); j.hasNext();) {
- DatabaseMapping mapping = (DatabaseMapping) j.next();
- cols += mapping.getField().getName();
- if (j.hasNext()) {
- cols += COMMA_SPACE_STR;
- }
- idx++;
- }
- sqlStmt += cols + CLOSE_BRACKET + VALUES_STR + OPEN_BRACKET;
- String vals = "";
- for (int k=1; k<idx; k++) {
- vals += QUESTION_STR + k;
- if (k+1 < idx) {
- vals += COMMA_SPACE_STR;
- }
- }
- sqlStmt += vals + CLOSE_BRACKET;
- ops.put(crudOpName, sqlStmt);
+
+ StringBuilder sqlStmt = new StringBuilder(128);
+ sqlStmt.append(INSERT_STR).append(tableName).append(SINGLE_SPACE).append(OPEN_BRACKET);
+ DescriptorHelper.buildColsFromMappings(sqlStmt, desc.getMappings(), COMMA_SPACE_STR);
+ sqlStmt.append(CLOSE_BRACKET).append(VALUES_STR).append(OPEN_BRACKET);
+ DescriptorHelper.buildValuesAsQMarksFromMappings(sqlStmt, desc.getMappings(), COMMA_SPACE_STR);
+ sqlStmt.append(CLOSE_BRACKET);
+ ops.put(crudOpName, sqlStmt.toString());
// update
crudOpName = UPDATE_OPERATION_NAME + UNDERSCORE + aliasType;
@@ -804,22 +794,13 @@ public abstract class BaseDBWSBuilderHelper {
updateOperation.setName(crudOpName);
updateOperation.getParameters().add(theInstance);
dbwsBuilder.xrServiceModel.getOperations().put(updateOperation.getName(), updateOperation);
-
- sqlStmt = UPDATE_STR + tableName + SET_STR;
- idx = pkCount;
- for (Iterator j = desc.getMappings().iterator(); j.hasNext();) {
- DatabaseMapping mapping = (DatabaseMapping) j.next();
- DatabaseField field = mapping.getField();
- if (!desc.getPrimaryKeyFields().contains(field)) {
- sqlStmt += mapping.getField().getName() + EQUALS_BINDING_STR + (++idx);
- if (j.hasNext()) {
- sqlStmt += COMMA_SPACE_STR;
- }
- }
- }
-
- sqlStmt += WHERE_STR + pks;
- ops.put(crudOpName, sqlStmt);
+
+ sqlStmt = new StringBuilder(128);
+ sqlStmt.append(UPDATE_STR).append(tableName).append(SET_STR);
+ DescriptorHelper.buildColsAndValuesBindingsFromMappings(sqlStmt, desc.getMappings(),
+ desc.getPrimaryKeyFields(), pkCount, EQUALS_BINDING_STR, COMMA_SPACE_STR);
+ sqlStmt.append(WHERE_STR).append(pks);
+ ops.put(crudOpName, sqlStmt.toString());
// delete
crudOpName = REMOVE_OPERATION_NAME + UNDERSCORE + aliasType;
@@ -836,8 +817,9 @@ public abstract class BaseDBWSBuilderHelper {
}
dbwsBuilder.xrServiceModel.getOperations().put(deleteOperation.getName(), deleteOperation);
- sqlStmt = DELETE_STR + tableName + WHERE_STR + pks;
- ops.put(crudOpName, sqlStmt);
+ sqlStmt = new StringBuilder(128);
+ sqlStmt.append(DELETE_STR).append(tableName).append(WHERE_STR).append(pks);
+ ops.put(crudOpName, sqlStmt.toString());
}
}
// check for additional operations
diff --git a/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/DBWSBuilder.java b/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/DBWSBuilder.java
index d98e7bc..adc863a 100644
--- a/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/DBWSBuilder.java
+++ b/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/DBWSBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -13,7 +13,10 @@
package org.eclipse.persistence.tools.dbws;
-//javase imports
+import static java.util.logging.Level.SEVERE;
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.OutputStream;
@@ -34,14 +37,29 @@ import java.util.ServiceLoader;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
-import static java.util.logging.Level.SEVERE;
-//java eXtension imports
import javax.wsdl.WSDLException;
-import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
-import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
-//EclipseLink imports
+// EclipseLink imports
+import static org.eclipse.persistence.internal.xr.Util.DBWS_OR_XML;
+import static org.eclipse.persistence.internal.xr.Util.DBWS_OX_XML;
+import static org.eclipse.persistence.internal.xr.Util.DBWS_SCHEMA_XML;
+import static org.eclipse.persistence.internal.xr.Util.DBWS_SERVICE_XML;
+import static org.eclipse.persistence.internal.xr.Util.DBWS_SESSIONS_XML;
+import static org.eclipse.persistence.internal.xr.Util.DBWS_WSDL;
+import static org.eclipse.persistence.tools.dbws.DBWSPackager.ArchiveUse.archive;
+import static org.eclipse.persistence.tools.dbws.DBWSPackager.ArchiveUse.ignore;
+import static org.eclipse.persistence.tools.dbws.DBWSPackager.ArchiveUse.noArchive;
+import static org.eclipse.persistence.tools.dbws.Util.DBWS_PROVIDER_CLASS_FILE;
+import static org.eclipse.persistence.tools.dbws.Util.DBWS_PROVIDER_SOURCE_FILE;
+import static org.eclipse.persistence.tools.dbws.Util.DEFAULT_PLATFORM_CLASSNAME;
+import static org.eclipse.persistence.tools.dbws.Util.DEFAULT_WSDL_LOCATION_URI;
+import static org.eclipse.persistence.tools.dbws.Util.PROVIDER_LISTENER_CLASS_FILE;
+import static org.eclipse.persistence.tools.dbws.Util.PROVIDER_LISTENER_SOURCE_FILE;
+import static org.eclipse.persistence.tools.dbws.Util.SWAREF_FILENAME;
+import static org.eclipse.persistence.tools.dbws.Util.WEB_XML_FILENAME;
+import static org.eclipse.persistence.tools.dbws.XRPackager.__nullStream;
+
import org.eclipse.persistence.dbws.DBWSModel;
import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.internal.databaseaccess.DatabasePlatform;
@@ -65,25 +83,6 @@ import org.eclipse.persistence.tools.dbws.DBWSPackager.ArchiveUse;
import org.eclipse.persistence.tools.dbws.jdbc.JDBCHelper;
import org.eclipse.persistence.tools.dbws.oracle.OracleHelper;
-import static org.eclipse.persistence.internal.xr.Util.DBWS_OR_XML;
-import static org.eclipse.persistence.internal.xr.Util.DBWS_OX_XML;
-import static org.eclipse.persistence.internal.xr.Util.DBWS_SCHEMA_XML;
-import static org.eclipse.persistence.internal.xr.Util.DBWS_SERVICE_XML;
-import static org.eclipse.persistence.internal.xr.Util.DBWS_SESSIONS_XML;
-import static org.eclipse.persistence.internal.xr.Util.DBWS_WSDL;
-import static org.eclipse.persistence.tools.dbws.DBWSPackager.ArchiveUse.archive;
-import static org.eclipse.persistence.tools.dbws.DBWSPackager.ArchiveUse.ignore;
-import static org.eclipse.persistence.tools.dbws.DBWSPackager.ArchiveUse.noArchive;
-import static org.eclipse.persistence.tools.dbws.Util.DBWS_PROVIDER_CLASS_FILE;
-import static org.eclipse.persistence.tools.dbws.Util.DBWS_PROVIDER_SOURCE_FILE;
-import static org.eclipse.persistence.tools.dbws.Util.DEFAULT_PLATFORM_CLASSNAME;
-import static org.eclipse.persistence.tools.dbws.Util.DEFAULT_WSDL_LOCATION_URI;
-import static org.eclipse.persistence.tools.dbws.Util.PROVIDER_LISTENER_CLASS_FILE;
-import static org.eclipse.persistence.tools.dbws.Util.PROVIDER_LISTENER_SOURCE_FILE;
-import static org.eclipse.persistence.tools.dbws.Util.SWAREF_FILENAME;
-import static org.eclipse.persistence.tools.dbws.Util.WEB_XML_FILENAME;
-import static org.eclipse.persistence.tools.dbws.XRPackager.__nullStream;
-
public class DBWSBuilder extends DBWSBuilderModel {
public static final String BUILDER_FILE_PATH = "-builderFile";
public static final String BUILDER_PACKAGING = "-packageAs";
diff --git a/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/oracle/OracleHelper.java b/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/oracle/OracleHelper.java
index 1fb27f5..b576ef4 100644
--- a/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/oracle/OracleHelper.java
+++ b/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/dbws/oracle/OracleHelper.java
@@ -1,45 +1,90 @@
-/*******************************************************************************
- * Copyright (c) 1998, 2013 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 v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
+/*******************************************************************************
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Mike Norman - from Proof-of-concept, become production code
- ******************************************************************************/
-package org.eclipse.persistence.tools.dbws.oracle;
-
-//javase imports
-import java.sql.Array;
-import java.sql.Struct;
-import java.sql.Types;
+ ******************************************************************************/
+package org.eclipse.persistence.tools.dbws.oracle;
+
+import static java.sql.Types.ARRAY;
+import static java.sql.Types.OTHER;
+import static java.sql.Types.STRUCT;
+import static java.util.logging.Level.FINEST;
+
+import java.sql.Array;
+import java.sql.Struct;
+import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-import static java.sql.Types.ARRAY;
-import static java.sql.Types.OTHER;
-import static java.sql.Types.STRUCT;
-import static java.util.logging.Level.FINEST;
-
-//java eXtension imports
-import javax.xml.namespace.QName;
-
-//EclipseLink imports
-import org.eclipse.persistence.descriptors.ClassDescriptor;
-import org.eclipse.persistence.internal.helper.ClassConstants;
-import org.eclipse.persistence.internal.helper.ComplexDatabaseType;
-import org.eclipse.persistence.internal.helper.DatabaseField;
-import org.eclipse.persistence.internal.oxm.XMLConversionManager;
-import org.eclipse.persistence.internal.xr.Attachment;
-import org.eclipse.persistence.internal.xr.CollectionResult;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+// EclipseLink imports
+import static org.eclipse.persistence.internal.helper.ClassConstants.Object_Class;
+import static org.eclipse.persistence.internal.xr.Util.SXF_QNAME;
+import static org.eclipse.persistence.internal.xr.Util.getJDBCTypeForTypeName;
+import static org.eclipse.persistence.internal.xr.Util.getClassFromJDBCType;
+import static org.eclipse.persistence.internal.xr.XRDynamicClassLoader.COLLECTION_WRAPPER_SUFFIX;
+import static org.eclipse.persistence.oxm.XMLConstants.ANY_QNAME;
+import static org.eclipse.persistence.oxm.XMLConstants.COLON;
+import static org.eclipse.persistence.oxm.XMLConstants.DATE_QNAME;
+import static org.eclipse.persistence.oxm.XMLConstants.DOT;
+import static org.eclipse.persistence.oxm.XMLConstants.EMPTY_STRING;
+import static org.eclipse.persistence.oxm.XMLConstants.INT;
+import static org.eclipse.persistence.oxm.XMLConstants.SCHEMA_INSTANCE_PREFIX;
+import static org.eclipse.persistence.oxm.XMLConstants.SCHEMA_INSTANCE_URL;
+import static org.eclipse.persistence.oxm.XMLConstants.SCHEMA_PREFIX;
+import static org.eclipse.persistence.oxm.XMLConstants.SCHEMA_URL;
+import static org.eclipse.persistence.oxm.XMLConstants.TEXT;
+import static org.eclipse.persistence.oxm.mappings.nullpolicy.XMLNullRepresentationType.XSI_NIL;
+import static org.eclipse.persistence.tools.dbws.Util.SXF_QNAME_CURSOR;
+import static org.eclipse.persistence.tools.dbws.Util.buildCustomQName;
+import static org.eclipse.persistence.tools.dbws.Util.getAttributeClassForDatabaseType;
+import static org.eclipse.persistence.tools.dbws.Util.getGeneratedJavaClassName;
+import static org.eclipse.persistence.tools.dbws.Util.getGeneratedAlias;
+import static org.eclipse.persistence.tools.dbws.Util.getXMLTypeFromJDBCType;
+import static org.eclipse.persistence.tools.dbws.Util.hasPLSQLCursorArg;
+import static org.eclipse.persistence.tools.dbws.Util.hasComplexArgs;
+import static org.eclipse.persistence.tools.dbws.Util.qNameFromString;
+import static org.eclipse.persistence.tools.dbws.Util.shouldSetJavaType;
+import static org.eclipse.persistence.tools.dbws.Util.sqlMatch;
+import static org.eclipse.persistence.tools.dbws.Util.APP_OCTET_STREAM;
+import static org.eclipse.persistence.tools.dbws.Util.AT_SIGN;
+import static org.eclipse.persistence.tools.dbws.Util.BUILDING_QUERYOP_FOR;
+import static org.eclipse.persistence.tools.dbws.Util.CLOSE_PAREN;
+import static org.eclipse.persistence.tools.dbws.Util.CURSOR_STR;
+import static org.eclipse.persistence.tools.dbws.Util.CURSOR_OF_STR;
+import static org.eclipse.persistence.tools.dbws.Util.OPEN_PAREN;
+import static org.eclipse.persistence.tools.dbws.Util.PERCENT;
+import static org.eclipse.persistence.tools.dbws.Util.UNDERSCORE;
+import static org.eclipse.persistence.tools.dbws.Util.SLASH;
+import static org.eclipse.persistence.tools.dbws.Util.TOPLEVEL;
+import static org.eclipse.persistence.tools.dbws.Util.TYPE_STR;
+import static org.eclipse.persistence.tools.dbws.Util.XMLTYPE_STR;
+import static org.eclipse.persistence.tools.oracleddl.metadata.ArgumentTypeDirection.IN;
+import static org.eclipse.persistence.tools.oracleddl.metadata.ArgumentTypeDirection.INOUT;
+import static org.eclipse.persistence.tools.oracleddl.metadata.ArgumentTypeDirection.OUT;
+
+import org.eclipse.persistence.descriptors.ClassDescriptor;
+import org.eclipse.persistence.internal.helper.ClassConstants;
+import org.eclipse.persistence.internal.helper.ComplexDatabaseType;
+import org.eclipse.persistence.internal.helper.DatabaseField;
+import org.eclipse.persistence.internal.helper.StringHelper;
+import org.eclipse.persistence.internal.oxm.XMLConversionManager;
+import org.eclipse.persistence.internal.xr.Attachment;
+import org.eclipse.persistence.internal.xr.CollectionResult;
import org.eclipse.persistence.internal.xr.NamedQueryHandler;
import org.eclipse.persistence.internal.xr.Parameter;
import org.eclipse.persistence.internal.xr.ProcedureArgument;
@@ -104,56 +149,12 @@ import org.eclipse.persistence.tools.oracleddl.metadata.TYPEType;
import org.eclipse.persistence.tools.oracleddl.metadata.TableType;
import org.eclipse.persistence.tools.oracleddl.metadata.VArrayType;
import org.eclipse.persistence.tools.oracleddl.metadata.visit.BaseDatabaseTypeVisitor;
-import org.eclipse.persistence.tools.oracleddl.metadata.visit.DatabaseTypeVisitor;
-import org.eclipse.persistence.tools.oracleddl.parser.ParseException;
-import org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilder;
-import static org.eclipse.persistence.internal.helper.ClassConstants.Object_Class;
-import static org.eclipse.persistence.internal.xr.Util.SXF_QNAME;
-import static org.eclipse.persistence.internal.xr.Util.getJDBCTypeForTypeName;
-import static org.eclipse.persistence.internal.xr.Util.getClassFromJDBCType;
-import static org.eclipse.persistence.internal.xr.XRDynamicClassLoader.COLLECTION_WRAPPER_SUFFIX;
-import static org.eclipse.persistence.oxm.XMLConstants.ANY_QNAME;
-import static org.eclipse.persistence.oxm.XMLConstants.COLON;
-import static org.eclipse.persistence.oxm.XMLConstants.DATE_QNAME;
-import static org.eclipse.persistence.oxm.XMLConstants.DOT;
-import static org.eclipse.persistence.oxm.XMLConstants.EMPTY_STRING;
-import static org.eclipse.persistence.oxm.XMLConstants.INT;
-import static org.eclipse.persistence.oxm.XMLConstants.SCHEMA_INSTANCE_PREFIX;
-import static org.eclipse.persistence.oxm.XMLConstants.SCHEMA_INSTANCE_URL;
-import static org.eclipse.persistence.oxm.XMLConstants.SCHEMA_PREFIX;
-import static org.eclipse.persistence.oxm.XMLConstants.SCHEMA_URL;
-import static org.eclipse.persistence.oxm.XMLConstants.TEXT;
-import static org.eclipse.persistence.oxm.mappings.nullpolicy.XMLNullRepresentationType.XSI_NIL;
-import static org.eclipse.persistence.tools.dbws.Util.SXF_QNAME_CURSOR;
-import static org.eclipse.persistence.tools.dbws.Util.buildCustomQName;
-import static org.eclipse.persistence.tools.dbws.Util.getAttributeClassForDatabaseType;
-import static org.eclipse.persistence.tools.dbws.Util.getGeneratedJavaClassName;
-import static org.eclipse.persistence.tools.dbws.Util.getGeneratedAlias;
-import static org.eclipse.persistence.tools.dbws.Util.getXMLTypeFromJDBCType;
-import static org.eclipse.persistence.tools.dbws.Util.hasPLSQLCursorArg;
-import static org.eclipse.persistence.tools.dbws.Util.hasComplexArgs;
-import static org.eclipse.persistence.tools.dbws.Util.qNameFromString;
-import static org.eclipse.persistence.tools.dbws.Util.shouldSetJavaType;
-import static org.eclipse.persistence.tools.dbws.Util.sqlMatch;
-import static org.eclipse.persistence.tools.dbws.Util.APP_OCTET_STREAM;
-import static org.eclipse.persistence.tools.dbws.Util.AT_SIGN;
-import static org.eclipse.persistence.tools.dbws.Util.BUILDING_QUERYOP_FOR;
-import static org.eclipse.persistence.tools.dbws.Util.CLOSE_PAREN;
-import static org.eclipse.persistence.tools.dbws.Util.CURSOR_STR;
-import static org.eclipse.persistence.tools.dbws.Util.CURSOR_OF_STR;
-import static org.eclipse.persistence.tools.dbws.Util.OPEN_PAREN;
-import static org.eclipse.persistence.tools.dbws.Util.PERCENT;
-import static org.eclipse.persistence.tools.dbws.Util.UNDERSCORE;
-import static org.eclipse.persistence.tools.dbws.Util.SLASH;
-import static org.eclipse.persistence.tools.dbws.Util.TOPLEVEL;
-import static org.eclipse.persistence.tools.dbws.Util.TYPE_STR;
-import static org.eclipse.persistence.tools.dbws.Util.XMLTYPE_STR;
-import static org.eclipse.persistence.tools.oracleddl.metadata.ArgumentTypeDirection.IN;
-import static org.eclipse.persistence.tools.oracleddl.metadata.ArgumentTypeDirection.INOUT;
-import static org.eclipse.persistence.tools.oracleddl.metadata.ArgumentTypeDirection.OUT;
-
-public class OracleHelper extends BaseDBWSBuilderHelper implements DBWSBuilderHelper {
-
+import org.eclipse.persistence.tools.oracleddl.metadata.visit.DatabaseTypeVisitor;
+import org.eclipse.persistence.tools.oracleddl.parser.ParseException;
+import org.eclipse.persistence.tools.oracleddl.util.DatabaseTypeBuilder;
+
+public class OracleHelper extends BaseDBWSBuilderHelper implements DBWSBuilderHelper {
+
protected DatabaseTypeBuilder dtBuilder = new DatabaseTypeBuilder();
public static final String NO_PKG_MSG = "No packages were found matching the following: ";
@@ -587,12 +588,37 @@ public class OracleHelper extends BaseDBWSBuilderHelper implements DBWSBuilderHe
// ignore for now
}
return null;
- }
-
- /**
- * Generates a List<ProcedureType> based on a given set of patterns.
- */
- protected List<ProcedureType> loadProcedures(List<String> catalogPatterns, List<String> schemaPatterns, List<String> procedureNamePatterns) {
+ }
+
+ /**
+ * Build list of name patterns separated by vertical bar.
+ * @param namePatterns {@see List} of name patterns.
+ * @return {@see String} containing list of name patterns separated by vertical bar.
+ */
+ private static String buildNamePatternsList(List<String> namePatterns) {
+ final int count = namePatterns.size();
+ if (count > 0) {
+ int lenhth = count - 1;
+ for (Iterator<String> i = namePatterns.iterator(); i.hasNext(); ) {
+ lenhth += i.next().length();
+ }
+ StringBuilder out = new StringBuilder(lenhth);
+ for (Iterator<String> i = namePatterns.iterator(); i.hasNext(); ) {
+ out.append(i.next());
+ if (i.hasNext()) {
+ out.append(StringHelper.VERTICAL_BAR);
+ }
+ }
+ return out.toString();
+ } else {
+ return StringHelper.EMPTY_STRING;
+ }
+ }
+
+ /**
+ * Generates a List<ProcedureType> based on a given set of patterns.
+ */
+ protected List<ProcedureType> loadProcedures(List<String> catalogPatterns, List<String> schemaPatterns, List<String> procedureNamePatterns) {
List<ProcedureType> allProcsAndFuncs = new ArrayList<ProcedureType>();
List<String> topLevelSchemaPatterns = new ArrayList<String>();
List<String> topLevelProcedureNamePatterns = new ArrayList<String>();
@@ -670,20 +696,14 @@ public class OracleHelper extends BaseDBWSBuilderHelper implements DBWSBuilderHe
if (procs.size() >1) {
for (int i = 0, len = procs.size(); i < len; i++) {
procs.get(i).setOverload(i);
- }
- }
- }
- //check against procedureNamePatterns
- String tmp = "";
- for (int i = 0, len = procedureNamePatterns.size(); i < len; i++) {
- tmp += procedureNamePatterns.get(i);
- if (i < len -1) {
- tmp += "|";
- }
- }
- for (ProcedureType procedure : procedures) {
- if (sqlMatch(tmp, procedure.getProcedureName())) {
- allProcsAndFuncs.add(procedure);
+ }
+ }
+ }
+ // Check against procedureNamePatterns
+ String tmp = buildNamePatternsList(procedureNamePatterns);
+ for (ProcedureType procedure : procedures) {
+ if (sqlMatch(tmp, procedure.getProcedureName())) {
+ allProcsAndFuncs.add(procedure);
}
}
}
diff --git a/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/metadata/generation/JPAMetadataGenerator.java b/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/metadata/generation/JPAMetadataGenerator.java
index f77190c..1e2336f 100755
--- a/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/metadata/generation/JPAMetadataGenerator.java
+++ b/utils/org.eclipse.persistence.dbws.builder/src/org/eclipse/persistence/tools/metadata/generation/JPAMetadataGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -65,7 +65,9 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.persistence.internal.databaseaccess.DatabasePlatform;
+import org.eclipse.persistence.internal.descriptors.DescriptorHelper;
import org.eclipse.persistence.internal.helper.Helper;
+import org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataHelper;
import org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor;
import org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EmbeddableAccessor;
import org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor;
@@ -1016,49 +1018,29 @@ public class JPAMetadataGenerator {
crudQuery.setQuery(SELECT_FROM_STR + tableName);
crudQuery.setResultClassName(entity.getClassName());
entity.getNamedNativeQueries().add(crudQuery);
-
// create
- String sqlStmt = INSERT_STR + tableName + SINGLE_SPACE + OPEN_BRACKET;
- int idx = 1;
- String cols = "";
- for (Iterator i = mappings.iterator(); i.hasNext(); ) {
- MappingAccessor mapping = (MappingAccessor) i.next();
- cols += mapping.getName().toUpperCase();
- if (i.hasNext()) {
- cols += COMMA_SPACE_STR;
- }
- idx++;
- }
- sqlStmt += cols + CLOSE_BRACKET + VALUES_STR + OPEN_BRACKET;
- String vals = "";
- for (int k = 1; k < idx; k++) {
- vals += QUESTION_STR + k;
- if (k+1 < idx) {
- vals += COMMA_SPACE_STR;
- }
- }
- sqlStmt += vals + CLOSE_BRACKET;
+ StringBuilder sqlStmt = new StringBuilder(128);
+ sqlStmt.append(INSERT_STR).append(tableName).append(SINGLE_SPACE).append(OPEN_BRACKET);
+ MetadataHelper.buildColsFromMappings(sqlStmt, mappings, COMMA_SPACE_STR);
+ sqlStmt.append(CLOSE_BRACKET).append(VALUES_STR).append(OPEN_BRACKET);
+ MetadataHelper.buildValuesAsQMarksFromMappings(sqlStmt, mappings, COMMA_SPACE_STR);
+ sqlStmt.append(CLOSE_BRACKET);
crudQuery = new NamedNativeQueryMetadata();
crudQuery.setName(CREATE_OPERATION_NAME + UNDERSCORE + entityType);
- crudQuery.setQuery(sqlStmt);
+ crudQuery.setQuery(sqlStmt.toString());
entity.getNamedNativeQueries().add(crudQuery);
// update
- sqlStmt = UPDATE_STR + tableName + SET_STR;
- idx = pkCount;
- for (Iterator i = basics.iterator(); i.hasNext(); ) {
- BasicAccessor basic = (BasicAccessor) i.next();
- sqlStmt += basic.getName().toUpperCase() + EQUALS_BINDING_STR + (++idx);
- if (i.hasNext()) {
- sqlStmt += COMMA_SPACE_STR;
- }
- }
- sqlStmt += WHERE_STR + pks;
+ sqlStmt = new StringBuilder(128);
+ sqlStmt.append(UPDATE_STR).append(tableName).append(SET_STR);
+ MetadataHelper.buildColsAndValuesBindingsFromMappings(sqlStmt, basics,
+ pkCount, EQUALS_BINDING_STR, COMMA_SPACE_STR);
+ sqlStmt.append(WHERE_STR).append(pks);
crudQuery = new NamedNativeQueryMetadata();
crudQuery.setName(UPDATE_OPERATION_NAME + UNDERSCORE + entityType);
- crudQuery.setQuery(sqlStmt);
+ crudQuery.setQuery(sqlStmt.toString());
entity.getNamedNativeQueries().add(crudQuery);
// delete