Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2010-01-02 03:05:38 +0000
committerddunne2010-01-02 03:05:38 +0000
commit3011eeeb0d3f7bdfbfab3520617d9d1674664b25 (patch)
tree1e9b04ad7034cac41e147702207506bb948821bb
parente090dd8b562065ca01ba798b64f3f4877b5140dc (diff)
downloadorg.eclipse.osee-3011eeeb0d3f7bdfbfab3520617d9d1674664b25.tar.gz
org.eclipse.osee-3011eeeb0d3f7bdfbfab3520617d9d1674664b25.tar.xz
org.eclipse.osee-3011eeeb0d3f7bdfbfab3520617d9d1674664b25.zip
add intern() to share string instances
-rw-r--r--org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/ATSLog.java4
-rw-r--r--org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsUtil.java4
-rw-r--r--org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/SMAState.java4
-rw-r--r--org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java75
4 files changed, 25 insertions, 62 deletions
diff --git a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/ATSLog.java b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/ATSLog.java
index 77d37b6321f..f2b0547e319 100644
--- a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/ATSLog.java
+++ b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/artifact/ATSLog.java
@@ -107,7 +107,9 @@ public class ATSLog {
if (!xml.equals("")) {
Matcher m = LOG_ITEM_PATTERN.matcher(xml);
while (m.find()) {
- LogItem item = new LogItem(m.group(4), m.group(1), m.group(5), m.group(3), AXml.xmlToText(m.group(2)));
+ LogItem item =
+ new LogItem(m.group(4), m.group(1), m.group(5).intern(), m.group(3).intern(),
+ AXml.xmlToText(m.group(2)));
logItems.add(item);
}
diff --git a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsUtil.java b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsUtil.java
index 8a1df459685..fbf9f0feb19 100644
--- a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsUtil.java
+++ b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsUtil.java
@@ -204,6 +204,10 @@ public class AtsUtil implements IAtsLib {
public static String doubleToI18nString(double d, boolean blankIfZero) {
if (blankIfZero && d == 0) {
return "";
+ }
+ // This enables java to use same string for all 0 cases instead of creating new one
+ else if (d == 0) {
+ return "0.00";
} else {
return String.format("%4.2f", d);
}
diff --git a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/SMAState.java b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/SMAState.java
index 3287304644b..350e591bfe7 100644
--- a/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/SMAState.java
+++ b/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/SMAState.java
@@ -39,14 +39,14 @@ public class SMAState {
}
public SMAState(String name, Collection<User> assignees) {
- this.name = name;
+ this.name = name.intern();
if (assignees != null) {
this.assignees = assignees;
}
}
public SMAState(String name, User assignee) {
- this.name = name;
+ this.name = name.intern();
if (assignee != null) {
this.assignees.add(assignee);
}
diff --git a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
index f8895dcb5bc..5baa4644d8f 100644
--- a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
+++ b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
@@ -26,6 +26,7 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.model.ArtifactType;
+import org.eclipse.osee.framework.core.model.AttributeType;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.RelationType;
import org.eclipse.osee.framework.core.model.TransactionRecord;
@@ -39,6 +40,8 @@ import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
+import org.eclipse.osee.framework.skynet.core.attribute.BooleanAttribute;
+import org.eclipse.osee.framework.skynet.core.attribute.EnumeratedAttribute;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.internal.Activator;
import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
@@ -60,17 +63,6 @@ public final class ArtifactLoader {
/**
* (re)loads the artifacts selected by sql and then returns them in a list
- *
- * @param sql
- * @param queryParameters
- * @param artifactCountEstimate
- * @param loadLevel
- * @param reload
- * @param confirmer
- * @param transactionId
- * @param allowDeleted
- * @return list of artifacts resulting for the sql query
- * @throws OseeCoreException
*/
public static List<Artifact> getArtifacts(String sql, Object[] queryParameters, int artifactCountEstimate, ArtifactLoad loadLevel, boolean reload, ISearchConfirmer confirmer, TransactionRecord transactionId, boolean allowDeleted) throws OseeCoreException {
int queryId = getNewQueryId();
@@ -85,32 +77,12 @@ public final class ArtifactLoader {
/**
* (re)loads the artifacts selected by sql and then returns them in a list
- *
- * @param sql
- * @param queryParameters
- * @param artifactCountEstimate
- * @param loadLevel
- * @param reload
- * @param allowDeleted allow the inclusion of deleted artifacts in the results
- * @param historical
- * @return list of artifacts resulting for the sql query
- * @throws OseeCoreException
*/
public static List<Artifact> getArtifacts(String sql, Object[] queryParameters, int artifactCountEstimate, ArtifactLoad loadLevel, boolean reload, TransactionRecord transactionId, boolean allowDeleted) throws OseeCoreException {
return getArtifacts(sql, queryParameters, artifactCountEstimate, loadLevel, reload, null, transactionId,
allowDeleted);
}
- /**
- * @param queryId
- * @param loadLevel
- * @param confirmer used to prompt user whether to proceed if certain conditions are met
- * @param fetchSize
- * @param reload
- * @param historical
- * @param allowDeleted allow the inclusion of deleted artifacts in the results
- * @throws OseeCoreException
- */
public static List<Artifact> loadArtifactsFromQueryId(int queryId, ArtifactLoad loadLevel, ISearchConfirmer confirmer, int fetchSize, boolean reload, boolean historical, boolean allowDeleted) throws OseeCoreException {
List<Artifact> artifacts = new ArrayList<Artifact>(fetchSize);
try {
@@ -157,28 +129,12 @@ public final class ArtifactLoader {
return artifacts;
}
- /**
- * loads or reloads artifacts based on artifact ids and branch ids
- *
- * @param artIds
- * @param branch
- * @param loadLevel
- * @return list of the loaded artifacts
- * @throws OseeCoreException
- */
public static List<Artifact> loadArtifacts(Collection<Integer> artIds, IOseeBranch branch, ArtifactLoad loadLevel, boolean reload) throws OseeCoreException {
return loadArtifacts(artIds, branch, loadLevel, null, reload);
}
/**
* loads or reloads artifacts based on artifact ids and branch ids
- *
- * @param artIds
- * @param branch
- * @param loadLevel
- * @param transactionId
- * @return list of the loaded artifacts
- * @throws OseeCoreException
*/
public static List<Artifact> loadArtifacts(Collection<Integer> artIds, IOseeBranch branch, ArtifactLoad loadLevel, TransactionRecord transactionId, boolean reload) throws OseeCoreException {
ArrayList<Artifact> artifacts = new ArrayList<Artifact>();
@@ -226,9 +182,6 @@ public final class ArtifactLoader {
/**
* must be call in a try block with a finally clause which calls clearQuery()
- *
- * @param insertParameters
- * @throws OseeDataStoreException
*/
public static int insertIntoArtifactJoin(OseeConnection connection, List<Object[]> insertParameters) throws OseeDataStoreException {
return ConnectionHandler.runBatchUpdate(connection, INSERT_JOIN_ARTIFACT, insertParameters);
@@ -236,9 +189,6 @@ public final class ArtifactLoader {
/**
* must be call in a try block with a finally clause which calls clearQuery()
- *
- * @param insertParameters
- * @throws OseeDataStoreException
*/
public static int insertIntoArtifactJoin(List<Object[]> insertParameters) throws OseeDataStoreException {
return insertIntoArtifactJoin(null, insertParameters);
@@ -269,11 +219,7 @@ public final class ArtifactLoader {
}
/**
- * @param queryId
* @param insertParameters will be populated by this method
- * @param sql
- * @param queryParameters
- * @param artifactCountEstimate
*/
public static void selectArtifacts(int queryId, CompositeKeyHashMap<Integer, Integer, Object[]> insertParameters, String sql, Object[] queryParameters, int artifactCountEstimate, TransactionRecord transactionId) throws OseeDataStoreException {
IOseeStatement chStmt = ConnectionHandler.getStatement();
@@ -474,8 +420,19 @@ public final class ArtifactLoader {
attrId, artifactId, branchId, previousGammaId, gammaId, previousModType, modType));
}
} else if (artifact != null) { //artifact will have been set to null if artifact.isAttributesLoaded() returned true
- artifact.internalInitializeAttribute(AttributeTypeManager.getType(chStmt.getInt("attr_type_id")),
- attrId, gammaId, ModificationType.getMod(modType), false, chStmt.getString("value"),
+ AttributeType attributeType = AttributeTypeManager.getType(chStmt.getInt("attr_type_id"));
+ boolean isBooleanAttribute =
+ AttributeTypeManager.isBaseTypeCompatible(BooleanAttribute.class, attributeType);
+ boolean isEnumAttribute =
+ AttributeTypeManager.isBaseTypeCompatible(EnumeratedAttribute.class, attributeType);
+ // If boolean or enumerated attribute type, the string value can be shared by using .intern()
+ artifact.internalInitializeAttribute(
+ attributeType,
+ attrId,
+ gammaId,
+ ModificationType.getMod(modType),
+ false,
+ isBooleanAttribute || isEnumAttribute ? chStmt.getString("value").intern() : chStmt.getString("value"),
chStmt.getString("uri"));
}

Back to the top