Skip to main content
summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorRick Sapir2012-09-11 10:12:02 -0400
committerRick Sapir2012-09-11 10:12:02 -0400
commit17e4fe4ef05e01e8a786c72a48284a8dc351ea1b (patch)
tree721e4032b2df418a55ad2842d99545788d959b23 /common
parent8e0365779296d9be8fc41a2f70b35f664037c59c (diff)
parentff1d9b0c5eb44c6306ed711b8ac47d05336a01aa (diff)
downloadwebtools.dali-17e4fe4ef05e01e8a786c72a48284a8dc351ea1b.tar.gz
webtools.dali-17e4fe4ef05e01e8a786c72a48284a8dc351ea1b.tar.xz
webtools.dali-17e4fe4ef05e01e8a786c72a48284a8dc351ea1b.zip
Merge branch 'master' of ssh://rsapir@git.eclipse.org/gitroot/dali/webtools.dali.git
Diffstat (limited to 'common')
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/feature.xml2
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.xml2
-rw-r--r--common/features/org.eclipse.jpt.common.feature/feature.xml2
-rw-r--r--common/features/org.eclipse.jpt.common.tests.feature/feature.xml2
-rw-r--r--common/features/org.eclipse.jpt.common_sdk.feature/feature.xml2
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/META-INF/MANIFEST.MF2
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/component.xml9
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF2
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/build.properties8
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/model/common.ecore4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAbstractType.java3
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceField.java2
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMethod.java2
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java20
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JavaResourceTypeBinding.java10
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/CommonPackage.java48
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObject.java40
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObjectImpl.java124
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java2
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/META-INF/MANIFEST.MF2
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/component.xml7
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/META-INF/MANIFEST.MF2
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF2
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/build.properties6
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF2
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/component.xml11
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java120
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/META-INF/MANIFEST.MF2
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/META-INF/MANIFEST.MF2
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/build.properties7
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/META-INF/MANIFEST.MF2
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java78
32 files changed, 442 insertions, 87 deletions
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.xml b/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.xml
index 6a40c08f53..fcfbc593c5 100644
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.xml
+++ b/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.jpt.common.eclipselink.feature"
label="%featureName"
- version="1.2.0.qualifier"
+ version="1.3.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.jpt.common.eclipselink.branding"
license-feature="org.eclipse.license"
diff --git a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.xml b/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.xml
index fcb356af4c..6a958642a4 100644
--- a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.xml
+++ b/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.jpt.common.eclipselink_sdk.feature"
label="%featureName"
- version="1.2.0.qualifier"
+ version="1.3.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="1.0.0.qualifier">
diff --git a/common/features/org.eclipse.jpt.common.feature/feature.xml b/common/features/org.eclipse.jpt.common.feature/feature.xml
index e8f1ba703e..cb7f30cc31 100644
--- a/common/features/org.eclipse.jpt.common.feature/feature.xml
+++ b/common/features/org.eclipse.jpt.common.feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.jpt.common.feature"
label="%featureName"
- version="1.2.0.qualifier"
+ version="1.3.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.jpt.common.branding"
license-feature="org.eclipse.license"
diff --git a/common/features/org.eclipse.jpt.common.tests.feature/feature.xml b/common/features/org.eclipse.jpt.common.tests.feature/feature.xml
index 02150807b4..f81eaba570 100644
--- a/common/features/org.eclipse.jpt.common.tests.feature/feature.xml
+++ b/common/features/org.eclipse.jpt.common.tests.feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.jpt.common.tests.feature"
label="%featureName"
- version="1.2.0.qualifier"
+ version="1.3.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="1.0.0.qualifier">
diff --git a/common/features/org.eclipse.jpt.common_sdk.feature/feature.xml b/common/features/org.eclipse.jpt.common_sdk.feature/feature.xml
index 058f3ef776..ff615e5caf 100644
--- a/common/features/org.eclipse.jpt.common_sdk.feature/feature.xml
+++ b/common/features/org.eclipse.jpt.common_sdk.feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.jpt.common_sdk.feature"
label="%featureName"
- version="1.2.0.qualifier"
+ version="1.3.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="1.0.0.qualifier">
diff --git a/common/plugins/org.eclipse.jpt.common.branding/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.branding/META-INF/MANIFEST.MF
index 5c65eca88d..fda2ca4b4d 100644
--- a/common/plugins/org.eclipse.jpt.common.branding/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.branding/META-INF/MANIFEST.MF
@@ -2,6 +2,6 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jpt.common.branding;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Localization: plugin
Bundle-Vendor: %providerName
diff --git a/common/plugins/org.eclipse.jpt.common.branding/component.xml b/common/plugins/org.eclipse.jpt.common.branding/component.xml
deleted file mode 100644
index f437ec94d5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/component.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.common.branding">
-<description url=""></description>
-<component-depends unrestricted="true"></component-depends>
-<plugin id="org.eclipse.jpt.common.branding" fragment="false"/>
-<plugin id="org.eclipse.jpt.common.utility" fragment="false"/>
-<plugin id="org.eclipse.jpt.common.core" fragment="false"/>
-<plugin id="org.eclipse.jpt.common.ui" fragment="false"/>
-</component> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF
index c358a6c051..d93ade8c7b 100644
--- a/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jpt.common.core;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Activator: org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.jpt.common.core.internal.content"
Bundle-ClassPath: .
diff --git a/common/plugins/org.eclipse.jpt.common.core/build.properties b/common/plugins/org.eclipse.jpt.common.core/build.properties
index 559c6fab57..8dedd9e6a2 100644
--- a/common/plugins/org.eclipse.jpt.common.core/build.properties
+++ b/common/plugins/org.eclipse.jpt.common.core/build.properties
@@ -1,5 +1,5 @@
################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
+# Copyright (c) 2011, 2012 Oracle. All rights reserved.
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v1.0, which accompanies this distribution
# and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -14,6 +14,8 @@ bin.includes = .,\
META-INF/,\
about.html,\
plugin.xml,\
- plugin.properties
+ plugin.properties,\
+ .options
jars.compile.order = .
-src.includes = schema/
+src.includes = schema/,\
+ model/
diff --git a/common/plugins/org.eclipse.jpt.common.core/model/common.ecore b/common/plugins/org.eclipse.jpt.common.core/model/common.ecore
index 5c57f5c1e1..5463a6c9dd 100644
--- a/common/plugins/org.eclipse.jpt.common.core/model/common.ecore
+++ b/common/plugins/org.eclipse.jpt.common.core/model/common.ecore
@@ -3,9 +3,9 @@
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="xml" nsURI="jpt.common.xmi" nsPrefix="org.eclipse.jpt.jpa.core.resource.xml">
<eClassifiers xsi:type="ecore:EClass" name="ERootObjectImpl" abstract="true" eSuperTypes="#//ERootObject"/>
<eClassifiers xsi:type="ecore:EClass" name="ERootObject" abstract="true" interface="true">
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="version" lowerBound="1"
- eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="version" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="schemaLocation" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="impliedVersion" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAbstractType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAbstractType.java
index 11c7f64c16..3517a70910 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAbstractType.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAbstractType.java
@@ -48,7 +48,7 @@ abstract class SourceAbstractType<A extends AbstractType>
protected void initialize(AbstractTypeDeclaration typeDeclaration) {
super.initialize(typeDeclaration, typeDeclaration.getName());
this.initialize(typeDeclaration.resolveBinding());
-}
+ }
// ********** synchronize **********
@@ -61,6 +61,7 @@ abstract class SourceAbstractType<A extends AbstractType>
public void synchronizeWith(AbstractTypeDeclaration typeDeclaration) {
super.synchronizeWith(typeDeclaration, typeDeclaration.getName());
+ this.synchronizeWith(typeDeclaration.resolveBinding());
}
@Override
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceField.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceField.java
index 778a55bea3..97525d1d6e 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceField.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceField.java
@@ -84,7 +84,7 @@ final class SourceField
@Override
protected ITypeBinding getJdtTypeBinding(IBinding binding) {
- return ((IVariableBinding) binding).getType();
+ return binding == null ? null : ((IVariableBinding) binding).getType();
}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMethod.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMethod.java
index 4602bafe1c..75596f0f23 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMethod.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMethod.java
@@ -80,7 +80,7 @@ final class SourceMethod
@Override
protected ITypeBinding getJdtTypeBinding(IBinding binding) {
- return ((IMethodBinding) binding).getReturnType();
+ return binding == null ? null : ((IMethodBinding) binding).getReturnType();
}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java
index f3d8958616..109f0b9df8 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java
@@ -175,13 +175,15 @@ final class SourceType
FieldDeclaration[] fieldDeclarations = typeDeclaration.getFields();
CounterMap counters = new CounterMap(fieldDeclarations.length);
+ HashSet<JavaResourceField> remainingFields = new HashSet<JavaResourceField>(this.fields);
for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) {
String fieldName = fragment.getName().getFullyQualifiedName();
int occurrence = counters.increment(fieldName);
- JavaResourceField field = this.getField(fieldName, occurrence);
+ JavaResourceField field = getField(remainingFields, fieldName, occurrence);
field.resolveTypes(fieldDeclaration, fragment);
+ remainingFields.remove(field);
}
}
@@ -470,8 +472,8 @@ final class SourceType
this.addItemToCollection(field, this.fields, FIELDS_COLLECTION);
}
- private JavaResourceField getField(String fieldName, int occurrence) {
- for (JavaResourceField field : this.getFields()) {
+ private static JavaResourceField getField(Collection<JavaResourceField> fields, String fieldName, int occurrence) {
+ for (JavaResourceField field : fields) {
if (field.isFor(fieldName, occurrence)) {
return field;
}
@@ -504,7 +506,7 @@ final class SourceType
String fieldName = fragment.getName().getFullyQualifiedName();
int occurrence = counters.increment(fieldName);
- JavaResourceField field = this.getField(fieldName, occurrence);
+ JavaResourceField field = getField(fieldsToRemove, fieldName, occurrence);
if (field == null) {
this.addField(this.buildField(fieldName, occurrence, fieldDeclaration, fragment));
} else {
@@ -658,6 +660,9 @@ final class SourceType
// ***** inherited field/method types *****
private void initInheritedFieldTypes(ITypeBinding typeBinding) {
+ if (typeBinding == null) {
+ return;
+ }
ITypeBinding scTypeBinding = typeBinding.getSuperclass();
while (scTypeBinding != null && scTypeBinding.isParameterizedType()) {
// if the superclass is not parameterized,
@@ -682,7 +687,7 @@ final class SourceType
}
private void syncInheritedFieldTypes(ITypeBinding typeBinding) {
- ITypeBinding scTypeBinding = typeBinding.getSuperclass();
+ ITypeBinding scTypeBinding = typeBinding == null ? null : typeBinding.getSuperclass();
Map<InheritedAttributeKey, JavaResourceTypeBinding> removedTypes =
new HashMap<InheritedAttributeKey, JavaResourceTypeBinding>(this.inheritedFieldTypes);
while (scTypeBinding != null && scTypeBinding.isParameterizedType()) {
@@ -712,6 +717,9 @@ final class SourceType
}
private void initInheritedMethodTypes(ITypeBinding typeBinding) {
+ if (typeBinding == null) {
+ return;
+ }
ITypeBinding scTypeBinding = typeBinding.getSuperclass();
while (scTypeBinding != null && scTypeBinding.isParameterizedType()) {
// if the superclass is not parameterized,
@@ -741,7 +749,7 @@ final class SourceType
}
private void syncInheritedMethodTypes(ITypeBinding typeBinding) {
- ITypeBinding scTypeBinding = typeBinding.getSuperclass();
+ ITypeBinding scTypeBinding = typeBinding == null ? null : typeBinding.getSuperclass();
Map<InheritedAttributeKey, JavaResourceTypeBinding> removedTypes =
new HashMap<InheritedAttributeKey, JavaResourceTypeBinding>(this.inheritedMethodTypes);
while (scTypeBinding != null && scTypeBinding.isParameterizedType()) {
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JavaResourceTypeBinding.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JavaResourceTypeBinding.java
index dd20d992ff..9c8baa5132 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JavaResourceTypeBinding.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JavaResourceTypeBinding.java
@@ -54,7 +54,7 @@ public class JavaResourceTypeBinding
public JavaResourceTypeBinding(ITypeBinding jdtTypeBinding) {
- this.key = jdtTypeBinding.getKey();
+ this.key = jdtTypeBinding == null ? null : jdtTypeBinding.getKey();
this.qualifiedName = buildQualifiedName(jdtTypeBinding);
this.simpleName = buildSimpleName(jdtTypeBinding);
this.packageName = buildPackageName(jdtTypeBinding);
@@ -71,6 +71,12 @@ public class JavaResourceTypeBinding
public boolean isEquivalentTo(ITypeBinding typeBinding) {
+ if (this.key == null) {
+ return typeBinding == null;
+ }
+ if (typeBinding == null) {
+ return false;
+ }
return this.key.equals(typeBinding.getKey());
}
@@ -145,7 +151,7 @@ public class JavaResourceTypeBinding
}
private boolean buildIsGenericTypeDeclaration(ITypeBinding typeBinding) {
- return typeBinding.isGenericType();
+ return typeBinding != null && typeBinding.isGenericType();
}
public boolean isMemberTypeDeclaration() {
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/CommonPackage.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/CommonPackage.java
index 62860008af..32ef119952 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/CommonPackage.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/CommonPackage.java
@@ -13,6 +13,7 @@ package org.eclipse.jpt.common.core.resource.xml;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EPackageImpl;
@@ -99,13 +100,22 @@ public class CommonPackage extends EPackageImpl
public static final int EROOT_OBJECT__SCHEMA_LOCATION = 1;
/**
+ * The feature id for the '<em><b>Implied Version</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int EROOT_OBJECT__IMPLIED_VERSION = 2;
+
+ /**
* The number of structural features of the '<em>ERoot Object</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- public static final int EROOT_OBJECT_FEATURE_COUNT = 2;
+ public static final int EROOT_OBJECT_FEATURE_COUNT = 3;
/**
* The meta object id for the '{@link org.eclipse.jpt.common.core.resource.xml.ERootObjectImpl <em>ERoot Object Impl</em>}' class.
@@ -136,6 +146,15 @@ public class CommonPackage extends EPackageImpl
public static final int EROOT_OBJECT_IMPL__SCHEMA_LOCATION = EROOT_OBJECT__SCHEMA_LOCATION;
/**
+ * The feature id for the '<em><b>Implied Version</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public static final int EROOT_OBJECT_IMPL__IMPLIED_VERSION = EROOT_OBJECT__IMPLIED_VERSION;
+
+ /**
* The number of structural features of the '<em>ERoot Object Impl</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -281,6 +300,21 @@ public class CommonPackage extends EPackageImpl
/**
+ * Returns the meta object for the attribute '{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getImpliedVersion <em>Implied Version</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Implied Version</em>'.
+ * @see org.eclipse.jpt.common.core.resource.xml.ERootObject#getImpliedVersion()
+ * @see #getERootObject()
+ * @generated
+ */
+ public EAttribute getERootObject_ImpliedVersion()
+ {
+ return (EAttribute)eRootObjectEClass.getEStructuralFeatures().get(2);
+ }
+
+
+ /**
* Returns the factory that creates the instances of the model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -317,6 +351,7 @@ public class CommonPackage extends EPackageImpl
eRootObjectEClass = createEClass(EROOT_OBJECT);
createEAttribute(eRootObjectEClass, EROOT_OBJECT__VERSION);
createEAttribute(eRootObjectEClass, EROOT_OBJECT__SCHEMA_LOCATION);
+ createEAttribute(eRootObjectEClass, EROOT_OBJECT__IMPLIED_VERSION);
}
/**
@@ -354,8 +389,9 @@ public class CommonPackage extends EPackageImpl
initEClass(eRootObjectImplEClass, ERootObjectImpl.class, "ERootObjectImpl", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEClass(eRootObjectEClass, ERootObject.class, "ERootObject", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEAttribute(getERootObject_Version(), ecorePackage.getEString(), "version", null, 1, 1, ERootObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getERootObject_Version(), ecorePackage.getEString(), "version", null, 0, 1, ERootObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getERootObject_SchemaLocation(), ecorePackage.getEString(), "schemaLocation", null, 1, 1, ERootObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getERootObject_ImpliedVersion(), ecorePackage.getEString(), "impliedVersion", null, 0, 1, ERootObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
// Create resource
createResource(eNS_URI);
@@ -411,6 +447,14 @@ public class CommonPackage extends EPackageImpl
*/
public static final EAttribute EROOT_OBJECT__SCHEMA_LOCATION = eINSTANCE.getERootObject_SchemaLocation();
+ /**
+ * The meta object literal for the '<em><b>Implied Version</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final EAttribute EROOT_OBJECT__IMPLIED_VERSION = eINSTANCE.getERootObject_ImpliedVersion();
+
}
} //CommonPackage
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObject.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObject.java
index 8f9fec5fbc..0117173846 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObject.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObject.java
@@ -30,6 +30,7 @@ import org.eclipse.jpt.common.core.utility.TextRange;
* <ul>
* <li>{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getVersion <em>Version</em>}</li>
* <li>{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getSchemaLocation <em>Schema Location</em>}</li>
+ * <li>{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getImpliedVersion <em>Implied Version</em>}</li>
* </ul>
* </p>
*
@@ -51,7 +52,7 @@ public interface ERootObject extends EBaseObject
* @return the value of the '<em>Version</em>' attribute.
* @see #setVersion(String)
* @see org.eclipse.jpt.common.core.resource.xml.CommonPackage#getERootObject_Version()
- * @model required="true"
+ * @model
* @generated
*/
String getVersion();
@@ -92,5 +93,42 @@ public interface ERootObject extends EBaseObject
*/
void setSchemaLocation(String value);
+ /**
+ * Returns the value of the '<em><b>Implied Version</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Implied Version</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Implied Version</em>' attribute.
+ * @see #setImpliedVersion(String)
+ * @see org.eclipse.jpt.common.core.resource.xml.CommonPackage#getERootObject_ImpliedVersion()
+ * @model
+ * @generated
+ */
+ String getImpliedVersion();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.common.core.resource.xml.ERootObject#getImpliedVersion <em>Implied Version</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Implied Version</em>' attribute.
+ * @see #getImpliedVersion()
+ * @generated
+ */
+ void setImpliedVersion(String value);
+
+ /**
+ * Return either the value of {@link #getVersion()} (if set) or failing that, the version
+ * implied by the schema location ({@link #getImpliedVersion()})
+ */
+ String getDocumentVersion();
+
+ /**
+ * Sets the version and updates the schema location to correspond to the version
+ */
+ void setDocumentVersion(String versionString);
+
TextRange getVersionTextRange();
}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObjectImpl.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObjectImpl.java
index c11f483a0a..f0463e6f11 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObjectImpl.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/ERootObjectImpl.java
@@ -11,13 +11,15 @@
package org.eclipse.jpt.common.core.resource.xml;
+import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.jpt.common.core.internal.utility.translators.EnumeratedValueTranslator;
import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.wst.common.internal.emf.resource.ConstantAttributeTranslator;
import org.eclipse.wst.common.internal.emf.resource.Translator;
@@ -80,6 +82,26 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
protected String schemaLocation = SCHEMA_LOCATION_EDEFAULT;
/**
+ * The default value of the '{@link #getImpliedVersion() <em>Implied Version</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getImpliedVersion()
+ * @generated
+ * @ordered
+ */
+ protected static final String IMPLIED_VERSION_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getImpliedVersion() <em>Implied Version</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getImpliedVersion()
+ * @generated
+ * @ordered
+ */
+ protected String impliedVersion = IMPLIED_VERSION_EDEFAULT;
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -111,7 +133,7 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
* @return the value of the '<em>Version</em>' attribute.
* @see #setVersion(String)
* @see org.eclipse.jpt.common.core.resource.xml.CommonPackage#getERootObject_Version()
- * @model required="true"
+ * @model
* @generated
*/
public String getVersion()
@@ -127,7 +149,7 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
* @see #getVersion()
* @generated
*/
- protected void setVersionGen(String newVersion)
+ public void setVersion(String newVersion)
{
String oldVersion = version;
version = newVersion;
@@ -135,9 +157,14 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
eNotify(new ENotificationImpl(this, Notification.SET, CommonPackage.EROOT_OBJECT_IMPL__VERSION, oldVersion, version));
}
- public void setVersion(String newVersion) {
- setVersionGen(newVersion);
- setSchemaLocation(buildSchemaLocationString(getNamespace(), getSchemaLocationForVersion(newVersion)));
+ public String getDocumentVersion() {
+ String version = getVersion();
+ return (version == null) ? getImpliedVersion() : version;
+ }
+
+ public void setDocumentVersion(String newVersion) {
+ setVersion(newVersion);
+ setSchemaLocation(getSchemaLocationForVersion(newVersion));
}
/**
@@ -167,13 +194,59 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
* @see #getSchemaLocation()
* @generated
*/
- public void setSchemaLocation(String newSchemaLocation)
+ public void setSchemaLocationGen(String newSchemaLocation)
{
String oldSchemaLocation = schemaLocation;
schemaLocation = newSchemaLocation;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CommonPackage.EROOT_OBJECT_IMPL__SCHEMA_LOCATION, oldSchemaLocation, schemaLocation));
}
+
+ public void setSchemaLocation(String newSchemaLocation) {
+ setSchemaLocationGen(newSchemaLocation);
+ for (Entry<String, String> entry : schemaLocations().entrySet()) {
+ if (entry.getValue().equals(newSchemaLocation)) {
+ setImpliedVersion(entry.getKey());
+ return;
+ }
+ }
+ setImpliedVersion(null);
+ }
+
+ /**
+ * Returns the value of the '<em><b>Implied Version</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Implied Version</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Implied Version</em>' attribute.
+ * @see #setImpliedVersion(String)
+ * @see org.eclipse.jpt.common.core.resource.xml.CommonPackage#getERootObject_ImpliedVersion()
+ * @model
+ * @generated
+ */
+ public String getImpliedVersion()
+ {
+ return impliedVersion;
+ }
+
+ /**
+ * Sets the value of the '{@link org.eclipse.jpt.common.core.resource.xml.ERootObjectImpl#getImpliedVersion <em>Implied Version</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Implied Version</em>' attribute.
+ * @see #getImpliedVersion()
+ * @generated
+ */
+ public void setImpliedVersion(String newImpliedVersion)
+ {
+ String oldImpliedVersion = impliedVersion;
+ impliedVersion = newImpliedVersion;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, CommonPackage.EROOT_OBJECT_IMPL__IMPLIED_VERSION, oldImpliedVersion, impliedVersion));
+ }
/**
* <!-- begin-user-doc -->
@@ -189,6 +262,8 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
return getVersion();
case CommonPackage.EROOT_OBJECT_IMPL__SCHEMA_LOCATION:
return getSchemaLocation();
+ case CommonPackage.EROOT_OBJECT_IMPL__IMPLIED_VERSION:
+ return getImpliedVersion();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -209,6 +284,9 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
case CommonPackage.EROOT_OBJECT_IMPL__SCHEMA_LOCATION:
setSchemaLocation((String)newValue);
return;
+ case CommonPackage.EROOT_OBJECT_IMPL__IMPLIED_VERSION:
+ setImpliedVersion((String)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -229,6 +307,9 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
case CommonPackage.EROOT_OBJECT_IMPL__SCHEMA_LOCATION:
setSchemaLocation(SCHEMA_LOCATION_EDEFAULT);
return;
+ case CommonPackage.EROOT_OBJECT_IMPL__IMPLIED_VERSION:
+ setImpliedVersion(IMPLIED_VERSION_EDEFAULT);
+ return;
}
super.eUnset(featureID);
}
@@ -247,6 +328,8 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
return VERSION_EDEFAULT == null ? version != null : !VERSION_EDEFAULT.equals(version);
case CommonPackage.EROOT_OBJECT_IMPL__SCHEMA_LOCATION:
return SCHEMA_LOCATION_EDEFAULT == null ? schemaLocation != null : !SCHEMA_LOCATION_EDEFAULT.equals(schemaLocation);
+ case CommonPackage.EROOT_OBJECT_IMPL__IMPLIED_VERSION:
+ return IMPLIED_VERSION_EDEFAULT == null ? impliedVersion != null : !IMPLIED_VERSION_EDEFAULT.equals(impliedVersion);
}
return super.eIsSet(featureID);
}
@@ -266,6 +349,8 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
result.append(version);
result.append(", schemaLocation: ");
result.append(schemaLocation);
+ result.append(", impliedVersion: ");
+ result.append(impliedVersion);
result.append(')');
return result.toString();
}
@@ -282,7 +367,11 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
protected abstract String getNamespace();
- protected abstract String getSchemaLocationForVersion(String version);
+ protected abstract HashMap<String, String> schemaLocations();
+
+ protected String getSchemaLocationForVersion(String version) {
+ return schemaLocations().get(version);
+ }
private static String buildSchemaLocationString(String namespace, String schemaLocation) {
return namespace + ' ' + schemaLocation;
@@ -323,12 +412,19 @@ public abstract class ERootObjectImpl extends EBaseObjectImpl implements ERootOb
@Override
protected Iterable<String> getEnumeratedObjectValues() {
- return new TransformationIterable<String, String>(versionsToSchemaLocations.values()) {
- @Override
- protected String transform(String next) {
- return buildSchemaLocationString(namespace, next);
- }
- };
+ return versionsToSchemaLocations.values();
+ }
+
+ @Override
+ public Object convertStringToValue(String string, EObject owner) {
+ String[] split = string.split("\\s+"); // splits on any whitespace
+ int length = split.length;
+ return (length == 0) ? null : split[length - 1];
+ }
+
+ @Override
+ public String convertValueToString(Object value, EObject owner) {
+ return buildSchemaLocationString(namespace, (String) value);
}
};
}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java
index 7ee51dc154..db5d391b07 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java
@@ -85,7 +85,7 @@ public class JptXmlResource
public String getVersion() {
ERootObject root = this.getRootObject();
- return (root == null) ? null : root.getVersion();
+ return (root == null) ? null : root.getDocumentVersion();
}
/**
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/META-INF/MANIFEST.MF
index 8ca53128d7..976595cec3 100644
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/META-INF/MANIFEST.MF
@@ -2,6 +2,6 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jpt.common.eclipselink.branding;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Localization: plugin
Bundle-Vendor: %providerName
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/component.xml b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/component.xml
deleted file mode 100644
index a433d25681..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/component.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.common.eclipselink.branding">
-<description url=""></description>
-<component-depends unrestricted="true"></component-depends>
-<plugin id="org.eclipse.jpt.common.eclipselink.branding" fragment="false"/>
-<plugin id="org.eclipse.jpt.common.eclipselink.core" fragment="false"/>
-</component> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.eclipselink.core/META-INF/MANIFEST.MF
index 7dbb4c0d76..b0106f55a5 100644
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.eclipselink.core/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jpt.common.eclipselink.core;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Activator: org.eclipse.jpt.common.eclipselink.core.internal.plugin.JptCommonEclipseLinkCorePlugin
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
diff --git a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
index f184f9571c..1607c5623d 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jpt.common.ui;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Activator: org.eclipse.jpt.common.ui.internal.plugin.JptCommonUiPlugin
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
diff --git a/common/plugins/org.eclipse.jpt.common.ui/build.properties b/common/plugins/org.eclipse.jpt.common.ui/build.properties
index 7fc780eaa0..09040302a1 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/build.properties
+++ b/common/plugins/org.eclipse.jpt.common.ui/build.properties
@@ -1,5 +1,5 @@
################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
+# Copyright (c) 2011, 2012 Oracle. All rights reserved.
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v1.0, which accompanies this distribution
# and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -13,5 +13,7 @@ output.. = bin/
bin.includes = .,\
META-INF/,\
about.html,\
- plugin.properties
+ plugin.xml,\
+ plugin.properties,\
+ .options
jars.compile.order = .
diff --git a/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
index 32e2a3b888..a61978980d 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jpt.common.utility;singleton:=true
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 2.2.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Localization: plugin
diff --git a/common/plugins/org.eclipse.jpt.common.utility/component.xml b/common/plugins/org.eclipse.jpt.common.utility/component.xml
deleted file mode 100644
index 80c3a500b9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/component.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2007, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0, which accompanies this distribution
- and is available at http://www.eclipse.org/legal/epl-v10.html.
-
- Contributors:
- Oracle - initial API and implementation
- -->
-<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.common.utility"><description url=""></description><component-depends unrestricted="true"></component-depends><plugin id="org.eclipse.jpt.common.utility" fragment="false"/></component> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java
index 093e713da9..6e27dbeca4 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -35,7 +35,7 @@ public final class StringTools {
public static final char QUOTE = '"';
/** XML double quote */
- public static final String XML_QUOTE = "&quot;";
+ public static final String XML_QUOTE = "&quot;"; //$NON-NLS-1$
/** parenthesis */
public static final char OPEN_PARENTHESIS = '(';
@@ -4815,6 +4815,16 @@ public final class StringTools {
return sb.toString();
}
+ public static String convertToJavaStringLiteralContent(String string) {
+ int len = string.length();
+ if (len == 0) {
+ return EMPTY_JAVA_STRING_LITERAL;
+ }
+ StringBuilder sb = new StringBuilder(len + 5);
+ convertToJavaStringLiteralContentOn_(string.toCharArray(), sb, len);
+ return sb.toString();
+ }
+
public static char[] convertToJavaStringLiteral(char[] string) {
int len = string.length;
if (len == 0) {
@@ -4828,10 +4838,27 @@ public final class StringTools {
return result;
}
+ public static char[] convertToJavaStringLiteralContent(char[] string) {
+ int len = string.length;
+ if (len == 0) {
+ return EMPTY_JAVA_STRING_LITERAL_CHAR_ARRAY;
+ }
+ StringBuilder sb = new StringBuilder(len + 5);
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ len = sb.length();
+ char[] result = new char[len];
+ sb.getChars(0, len, result, 0);
+ return result;
+ }
+
public static Iterable<String> convertToJavaStringLiterals(Iterable<String> strings) {
return new TransformationIterable<String, String>(strings, STRING_TO_JAVA_STRING_LITERAL_TRANSFORMER);
}
+ public static Iterable<String> convertToJavaStringLiteralContents(Iterable<String> strings) {
+ return new TransformationIterable<String, String>(strings, STRING_TO_JAVA_STRING_LITERAL_CONTENT_TRANSFORMER);
+ }
+
public static Iterator<String> convertToJavaStringLiterals(Iterator<String> strings) {
return new TransformationIterator<String, String>(strings, STRING_TO_JAVA_STRING_LITERAL_TRANSFORMER);
}
@@ -4842,6 +4869,12 @@ public final class StringTools {
}
};
+ private static final Transformer<String, String> STRING_TO_JAVA_STRING_LITERAL_CONTENT_TRANSFORMER = new Transformer<String, String>() {
+ public String transform(String string) {
+ return StringTools.convertToJavaStringLiteralContent(string);
+ }
+ };
+
// cannot name method simply 'convertToJavaStringLiterals' because of type-erasure...
public static Iterable<char[]> convertToJavaCharArrayLiterals(Iterable<char[]> strings) {
return new TransformationIterable<char[], char[]>(strings, CHAR_ARRAY_TO_JAVA_STRING_LITERAL_TRANSFORMER);
@@ -4867,6 +4900,15 @@ public final class StringTools {
}
}
+ public static void convertToJavaStringLiteralContentOn(String string, StringBuffer sb) {
+ int len = string.length();
+ if (len == 0) {
+ sb.append(EMPTY_JAVA_STRING_LITERAL);
+ } else {
+ convertToJavaStringLiteralContentOn_(string.toCharArray(), sb, len);
+ }
+ }
+
public static void convertToJavaStringLiteralOn(char[] string, StringBuffer sb) {
int len = string.length;
if (len == 0) {
@@ -4876,12 +4918,30 @@ public final class StringTools {
}
}
+ public static void convertToJavaStringLiteralContentOn(char[] string, StringBuffer sb) {
+ int len = string.length;
+ if (len == 0) {
+ sb.append(EMPTY_JAVA_STRING_LITERAL);
+ } else {
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ }
+ }
+
/*
* no length checks
*/
private static void convertToJavaStringLiteralOn_(char[] string, StringBuffer sb, int len) {
sb.ensureCapacity(sb.length() + len + 5);
sb.append(QUOTE);
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ sb.append(QUOTE);
+ }
+
+ /*
+ * no length checks
+ */
+ private static void convertToJavaStringLiteralContentOn_(char[] string, StringBuffer sb, int len) {
+ sb.ensureCapacity(sb.length() + len + 5);
for (char c : string) {
switch (c) {
case '\b': // backspace
@@ -4913,7 +4973,6 @@ public final class StringTools {
break;
}
}
- sb.append(QUOTE);
}
public static void convertToJavaStringLiteralOn(String string, StringBuilder sb) {
@@ -4934,12 +4993,39 @@ public final class StringTools {
}
}
+ public static void convertToJavaStringLiteralContentOn(String string, StringBuilder sb) {
+ int len = string.length();
+ if (len == 0) {
+ sb.append(EMPTY_JAVA_STRING_LITERAL);
+ } else {
+ convertToJavaStringLiteralContentOn_(string.toCharArray(), sb, len);
+ }
+ }
+
+ public static void convertToJavaStringLiteralContentOn(char[] string, StringBuilder sb) {
+ int len = string.length;
+ if (len == 0) {
+ sb.append(EMPTY_JAVA_STRING_LITERAL);
+ } else {
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ }
+ }
+
/*
* no length checks
*/
private static void convertToJavaStringLiteralOn_(char[] string, StringBuilder sb, int len) {
sb.ensureCapacity(sb.length() + len + 5);
sb.append(QUOTE);
+ convertToJavaStringLiteralContentOn_(string, sb, len);
+ sb.append(QUOTE);
+ }
+
+ /*
+ * no length checks
+ */
+ private static void convertToJavaStringLiteralContentOn_(char[] string, StringBuilder sb, int len) {
+ sb.ensureCapacity(sb.length() + len + 5);
for (char c : string) {
switch (c) {
case '\b': // backspace
@@ -4971,7 +5057,6 @@ public final class StringTools {
break;
}
}
- sb.append(QUOTE);
}
public static void convertToJavaStringLiteralOn(String string, Writer writer) {
@@ -4990,11 +5075,35 @@ public final class StringTools {
}
}
+ public static void convertToJavaStringLiteralContentOn(String string, Writer writer) {
+ if (string.length() == 0) {
+ writeStringOn(EMPTY_JAVA_STRING_LITERAL, writer);
+ } else {
+ convertToJavaStringLiteralContentOn_(string.toCharArray(), writer);
+ }
+ }
+
+ public static void convertToJavaStringLiteralContentOn(char[] string, Writer writer) {
+ if (string.length == 0) {
+ writeStringOn(EMPTY_JAVA_STRING_LITERAL, writer);
+ } else {
+ convertToJavaStringLiteralContentOn_(string, writer);
+ }
+ }
+
/*
* no length checks
*/
private static void convertToJavaStringLiteralOn_(char[] string, Writer writer) {
writeCharOn(QUOTE, writer);
+ convertToJavaStringLiteralContentOn_(string, writer);
+ writeCharOn(QUOTE, writer);
+ }
+
+ /*
+ * no length checks
+ */
+ private static void convertToJavaStringLiteralContentOn_(char[] string, Writer writer) {
for (char c : string) {
switch (c) {
case '\b': // backspace
@@ -5026,7 +5135,6 @@ public final class StringTools {
break;
}
}
- writeCharOn(QUOTE, writer);
}
// ********** convert to XML string literal **********
@@ -5048,7 +5156,7 @@ public final class StringTools {
for (char c : string) {
switch (c) {
case '"': // double-quote
- sb.append(XML_QUOTE); //$NON-NLS-1$
+ sb.append(XML_QUOTE);
break;
default:
sb.append(c);
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/META-INF/MANIFEST.MF b/common/tests/org.eclipse.jpt.common.core.tests/META-INF/MANIFEST.MF
index 81e03aa192..29771c1656 100644
--- a/common/tests/org.eclipse.jpt.common.core.tests/META-INF/MANIFEST.MF
+++ b/common/tests/org.eclipse.jpt.common.core.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jpt.common.core.tests;singleton:=true
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Localization: plugin
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/META-INF/MANIFEST.MF b/common/tests/org.eclipse.jpt.common.ui.tests/META-INF/MANIFEST.MF
index 93f23db55c..c615ce280f 100644
--- a/common/tests/org.eclipse.jpt.common.ui.tests/META-INF/MANIFEST.MF
+++ b/common/tests/org.eclipse.jpt.common.ui.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jpt.common.ui.tests;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.2.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Localization: plugin
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/build.properties b/common/tests/org.eclipse.jpt.common.ui.tests/build.properties
index 4dce676b59..68d2e421f6 100644
--- a/common/tests/org.eclipse.jpt.common.ui.tests/build.properties
+++ b/common/tests/org.eclipse.jpt.common.ui.tests/build.properties
@@ -1,5 +1,5 @@
################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
+# Copyright (c) 2011, 2012 Oracle. All rights reserved.
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v1.0, which accompanies this distribution
# and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -9,5 +9,6 @@
################################################################################
source.. = src/
output.. = bin/
-bin.includes = META-INF/,\
- .
+bin.includes = .,\
+ META-INF/,\
+ plugin.properties
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/META-INF/MANIFEST.MF b/common/tests/org.eclipse.jpt.common.utility.tests/META-INF/MANIFEST.MF
index 810de02604..0dbd2d58d3 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/META-INF/MANIFEST.MF
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jpt.common.utility.tests;singleton:=true
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 2.2.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Localization: plugin
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java
index b34bab2474..9af1578506 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -1868,4 +1868,80 @@ public class StringToolsTests extends TestCase {
assertEquals(expected, writer.toString());
}
+ // ********** converting to Java string literal content **********
+
+ public void testConvertToJavaStringLiteralContent() {
+ this.verifyConvertToJavaStringLiteralContent("", "\"\"");
+ this.verifyConvertToJavaStringLiteralContent("\"\"", "\\\"\\\"");
+ this.verifyConvertToJavaStringLiteralContent("'foo'", "'foo'");
+ this.verifyConvertToJavaStringLiteralContent("foo\bbar", "foo\\bbar");
+ this.verifyConvertToJavaStringLiteralContent("foo\n\tbar", "foo\\n\\tbar");
+ this.verifyConvertToJavaStringLiteralContent("foo\"bar", "foo\\\"bar");
+ this.verifyConvertToJavaStringLiteralContent("foo\\bar", "foo\\\\bar");
+ }
+
+ private void verifyConvertToJavaStringLiteralContent(String s, String expected) {
+ assertEquals(expected, StringTools.convertToJavaStringLiteralContent(s));
+ assertEquals(expected, StringTools.convertToJavaStringLiteralContent(s.toCharArray()));
+ }
+
+ public void testConvertToJavaStringLiteralContentOnStringBuffer() {
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("", "\"\"");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("\"\"", "\\\"\\\"");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("'foo'", "'foo'");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("foo\bbar", "foo\\bbar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("foo\n\tbar", "foo\\n\\tbar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("foo\"bar", "foo\\\"bar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuffer("foo\\bar", "foo\\\\bar");
+ }
+
+ private void verifyConvertToJavaStringLiteralContentOnStringBuffer(String s, String expected) {
+ StringBuffer sb = new StringBuffer();
+ StringTools.convertToJavaStringLiteralContentOn(s, sb);
+ assertEquals(expected, sb.toString());
+
+ sb = new StringBuffer();
+ StringTools.convertToJavaStringLiteralContentOn(s.toCharArray(), sb);
+ assertEquals(expected, sb.toString());
+ }
+
+ public void testConvertToJavaStringLiteralContentOnStringBuilder() {
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("", "\"\"");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("\"\"", "\\\"\\\"");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("'foo'", "'foo'");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("foo\bbar", "foo\\bbar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("foo\n\tbar", "foo\\n\\tbar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("foo\"bar", "foo\\\"bar");
+ this.verifyConvertToJavaStringLiteralContentOnStringBuilder("foo\\bar", "foo\\\\bar");
+ }
+
+ private void verifyConvertToJavaStringLiteralContentOnStringBuilder(String s, String expected) {
+ StringBuilder sb = new StringBuilder();
+ StringTools.convertToJavaStringLiteralContentOn(s, sb);
+ assertEquals(expected, sb.toString());
+
+ sb = new StringBuilder();
+ StringTools.convertToJavaStringLiteralContentOn(s.toCharArray(), sb);
+ assertEquals(expected, sb.toString());
+ }
+
+ public void testConvertToJavaStringLiteralContentOnWriter() {
+ this.verifyConvertToJavaStringLiteralContentOnWriter("", "\"\"");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("\"\"", "\\\"\\\"");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("'foo'", "'foo'");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("foo\bbar", "foo\\bbar");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("foo\n\tbar", "foo\\n\\tbar");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("foo\"bar", "foo\\\"bar");
+ this.verifyConvertToJavaStringLiteralContentOnWriter("foo\\bar", "foo\\\\bar");
+ }
+
+ private void verifyConvertToJavaStringLiteralContentOnWriter(String s, String expected) {
+ Writer writer = new StringWriter();
+ StringTools.convertToJavaStringLiteralContentOn(s, writer);
+ assertEquals(expected, writer.toString());
+
+ writer = new StringWriter();
+ StringTools.convertToJavaStringLiteralContentOn(s.toCharArray(), writer);
+ assertEquals(expected, writer.toString());
+ }
}

Back to the top