Skip to content

Commit

Permalink
Replace calls to StringUtil with CoreStringUtil
Browse files Browse the repository at this point in the history
* Replaces calls to the teiid class StringUtil with the designer class
  CoreStringUtil
  • Loading branch information
Paul Richardson committed Oct 15, 2012
1 parent e55f4d7 commit 03042dc
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.teiid.core.designer.CoreModelerPlugin;
import org.teiid.core.designer.TeiidDesignerException;
import org.teiid.core.designer.util.OperationUtil.Unreliable;
import org.teiid.core.util.StringUtil;

/**
* @since 8.0
Expand Down Expand Up @@ -140,7 +139,7 @@ public static boolean isFilenameValid(String newName) {
* @return
*/
public static String getBaseFileNameWithoutExtension(String path) {
return StringUtil.getFirstToken(StringUtil.getLastToken(path, "/"), "."); //$NON-NLS-1$ //$NON-NLS-2$
return CoreStringUtil.getFirstToken(CoreStringUtil.getLastToken(path, "/"), "."); //$NON-NLS-1$ //$NON-NLS-2$
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.util.ArrayList;
import java.util.List;
import org.teiid.core.util.StringUtil;
import org.teiid.core.designer.util.CoreStringUtil;

//We also need to bring back our SAX handler "header reader"
//that reads a stream and extracts the model information
Expand Down Expand Up @@ -52,7 +52,7 @@ public void addModelImportInfo( final ModelImportInfo modelImportInfo ) {
}

public void addNamespaceURI( final String uri ) {
if (!StringUtil.isEmpty(uri) && !this.namespaceURIs.contains(uri)) this.namespaceURIs.add(uri);
if (!CoreStringUtil.isEmpty(uri) && !this.namespaceURIs.contains(uri)) this.namespaceURIs.add(uri);
}

public String getDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.internal.ConnectionProfile;
import org.teiid.core.designer.util.CoreArgCheck;
import org.teiid.core.util.StringUtil;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.workspace.ModelResource;
import org.teiid.designer.core.workspace.ModelWorkspaceException;
Expand Down Expand Up @@ -236,7 +236,7 @@ public Properties getTranslatorProperties( ModelResource modelResource ) {
@Override
public String getTranslatorName( ModelResource modelResource ) {
if( modelResource == null ) {
return StringUtil.Constants.EMPTY_STRING;
return CoreStringUtil.Constants.EMPTY_STRING;
}

Properties props = null;
Expand All @@ -250,7 +250,7 @@ public String getTranslatorName( ModelResource modelResource ) {
modelResource.getItemName()));
}

return props.getProperty(TRANSLATOR_NAMESPACE + TRANSLATOR_NAME_KEY, StringUtil.Constants.EMPTY_STRING);
return props.getProperty(TRANSLATOR_NAMESPACE + TRANSLATOR_NAME_KEY, CoreStringUtil.Constants.EMPTY_STRING);
}

public void setTranslatorName( ModelResource modelResource, String translatorName ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.core.designer.util.I18nUtil;
import org.teiid.core.util.StringUtil;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.DqpUiPlugin;
import org.teiid.designer.runtime.ui.DqpUiStringUtil;
Expand Down Expand Up @@ -490,13 +490,13 @@ void restoreDefaultButtonPressed() {
this.basicSecurityButton.setSelection(false);
this.wsSecurityButton.setSelection(false);
this.mtomButton.setSelection(false);
this.txfSecurityRealm.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityRealm.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityRealm.setEnabled(false);
this.txfSecurityRole.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityRole.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityRole.setEnabled(false);
this.txfSecurityUsername.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityUsername.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityUsername.setEnabled(false);
this.txfSecurityPassword.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityPassword.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityPassword.setEnabled(false);
}

Expand Down Expand Up @@ -527,13 +527,13 @@ void handleMtomButtonSelected() {
void noSecurityButtonSelected() {
if (this.noSecurityButton.getSelection()) {
WarDataserviceModel.getInstance().setSecurityTypeDefault(NOSECURITY);
this.txfSecurityRealm.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityRealm.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityRealm.setEnabled(false);
this.txfSecurityRole.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityRole.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityRole.setEnabled(false);
this.txfSecurityUsername.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityUsername.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityUsername.setEnabled(false);
this.txfSecurityPassword.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityPassword.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityPassword.setEnabled(false);
}
}
Expand All @@ -550,9 +550,9 @@ void basicSecurityButtonSelected() {
this.txfSecurityRole.setText("MyRole"); //$NON-NLS-1$
WarDataserviceModel.getInstance().setSecurityRoleDefault("MyRole"); //$NON-NLS-1$
this.txfSecurityRole.setEnabled(true);
this.txfSecurityUsername.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityUsername.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityUsername.setEnabled(false);
this.txfSecurityPassword.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityPassword.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityPassword.setEnabled(false);
}
}
Expand All @@ -563,13 +563,13 @@ void basicSecurityButtonSelected() {
void wsSecurityButtonSelected() {
if (this.wsSecurityButton.getSelection()) {
WarDataserviceModel.getInstance().setSecurityTypeDefault(WSSE);
this.txfSecurityRealm.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityRealm.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityRealm.setEnabled(false);
this.txfSecurityRole.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityRole.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityRole.setEnabled(false);
this.txfSecurityUsername.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityUsername.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityUsername.setEnabled(true);
this.txfSecurityPassword.setText(StringUtil.Constants.EMPTY_STRING);
this.txfSecurityPassword.setText(CoreStringUtil.Constants.EMPTY_STRING);
this.txfSecurityPassword.setEnabled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
Expand All @@ -47,8 +45,8 @@
import org.eclipse.xsd.XSDSchema;
import org.eclipse.xsd.XSDSchemaContent;
import org.eclipse.xsd.util.XSDParser;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.core.designer.util.FileUtils;
import org.teiid.core.util.StringUtil;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.types.DatatypeConstants;
import org.teiid.designer.core.util.TempDirectory;
Expand All @@ -70,7 +68,7 @@ public class DefaultWebArchiveBuilderImpl implements WebArchiveBuilder {
private IPath webServicePluginPath = null;
private List<String> ports = new ArrayList<String>();
private Map<String, String> operationToProcedureMap = new HashMap<String, String>();
private String wsdlFilename = StringUtil.Constants.EMPTY_STRING;
private String wsdlFilename = CoreStringUtil.Constants.EMPTY_STRING;
private static final String JNDI_PREFIX = "java:"; //$NON-NLS-1$

// =============================================================
Expand Down Expand Up @@ -131,14 +129,14 @@ public IStatus validateContextName( String contextName ) {
// Check for invalid characters
String[] invalidChars = new String[] {"/" //$NON-NLS-1$
, "\\" //$NON-NLS-1$
, StringUtil.Constants.SPACE};
, CoreStringUtil.Constants.SPACE};
final String invalidChar = validateInvalidCharactersInContextName(contextName, invalidChars);

// Perform validation
if (invalidChar != null) {

String msg = null;
if (StringUtil.Constants.SPACE.equals(invalidChar)) {
if (CoreStringUtil.Constants.SPACE.equals(invalidChar)) {
msg = getString("ContextNameValidationFailed_InvalidSpace"); //$NON-NLS-1$
} else {
final Object[] params = new Object[] {invalidChar};
Expand All @@ -147,7 +145,7 @@ public IStatus validateContextName( String contextName ) {

return new Status(IStatus.ERROR, WebServicePlugin.PLUGIN_ID,
WebArchiveBuilderConstants.STATUS_CODE_CONTEXT_NAME_VALIDATION_FAILED, msg, null);
} else if (StringUtil.Constants.EMPTY_STRING.equals(contextName)) {
} else if (CoreStringUtil.Constants.EMPTY_STRING.equals(contextName)) {

final String msg = getString("ContextNameValidationFailed_Empty"); //$NON-NLS-1$
return new Status(IStatus.ERROR, WebServicePlugin.PLUGIN_ID,
Expand Down Expand Up @@ -428,7 +426,7 @@ protected void replaceWebXmlVariables( String webInfDirectoryName,
AntTasks.replace(webXmlFile, "${roleName}", role); //$NON-NLS-1$
AntTasks.replace(webXmlFile, "</login-config>-->", "</login-config>"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
AntTasks.replace(webXmlFile, "<!--${basic_auth}-->", StringUtil.Constants.EMPTY_STRING); //$NON-NLS-1$
AntTasks.replace(webXmlFile, "<!--${basic_auth}-->", CoreStringUtil.Constants.EMPTY_STRING); //$NON-NLS-1$
}

AntTasks.replace(webXmlFile, "${warname}", contextName); //$NON-NLS-1$
Expand Down Expand Up @@ -725,8 +723,8 @@ public void generateWsdl( Properties properties,

wsdlGenerator.setName(webServiceName);
wsdlGenerator.setTargetNamespace(tns);
wsdlGenerator.setUrlRootForReferences(StringUtil.Constants.EMPTY_STRING);
wsdlGenerator.setUrlSuffixForReferences(StringUtil.Constants.EMPTY_STRING);
wsdlGenerator.setUrlRootForReferences(CoreStringUtil.Constants.EMPTY_STRING);
wsdlGenerator.setUrlSuffixForReferences(CoreStringUtil.Constants.EMPTY_STRING);
wsdlGenerator.setUrlForWsdlService("http://" + host + ":" + port + "/" + contextName + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
final IStatus status = wsdlGenerator.generate(new NullProgressMonitor());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import javax.tools.Diagnostic;
import javax.tools.Diagnostic.Kind;
import javax.tools.DiagnosticCollector;
Expand All @@ -34,15 +33,14 @@
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.core.designer.util.FileUtils;
import org.teiid.core.util.StringUtil;
import org.teiid.designer.core.util.TempDirectory;
import org.teiid.designer.webservice.WebServicePlugin;
import org.teiid.designer.webservice.util.AntTasks;
Expand Down Expand Up @@ -104,14 +102,14 @@ public IStatus validateContextName( String contextName ) {
// Check for invalid characters
String[] invalidChars = new String[] {"/" //$NON-NLS-1$
, "\\" //$NON-NLS-1$
, StringUtil.Constants.SPACE};
, CoreStringUtil.Constants.SPACE};
final String invalidChar = validateInvalidCharactersInContextName(contextName, invalidChars);

// Perform validation
if (invalidChar != null) {

String msg = null;
if (StringUtil.Constants.SPACE.equals(invalidChar)) {
if (CoreStringUtil.Constants.SPACE.equals(invalidChar)) {
msg = getString("ContextNameValidationFailed_InvalidSpace"); //$NON-NLS-1$
} else {
final Object[] params = new Object[] {invalidChar};
Expand All @@ -120,7 +118,7 @@ public IStatus validateContextName( String contextName ) {

return new Status(IStatus.ERROR, WebServicePlugin.PLUGIN_ID,
WebArchiveBuilderConstants.STATUS_CODE_CONTEXT_NAME_VALIDATION_FAILED, msg, null);
} else if (StringUtil.Constants.EMPTY_STRING.equals(contextName)) {
} else if (CoreStringUtil.Constants.EMPTY_STRING.equals(contextName)) {

final String msg = getString("ContextNameValidationFailed_Empty"); //$NON-NLS-1$
return new Status(IStatus.ERROR, WebServicePlugin.PLUGIN_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.teiid.core.util.StringUtil;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.designer.common.util.ErrorMessageKeys;
import org.teiid.designer.common.util.I18nUtil;

Expand Down Expand Up @@ -133,7 +132,7 @@ public final String getNameComponent( int index ) {
public List getNameComponents() {
if (this.atomicNames == null) {
if (this.fullName.indexOf(IDVerifier.DELIMITER_CHARACTER) != -1) {
this.atomicNames = StringUtil.split(this.fullName, DELIMITER);
this.atomicNames = CoreStringUtil.split(this.fullName, DELIMITER);
} else {
this.atomicNames = new ArrayList(1);
this.atomicNames.add(this.fullName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.util.ArrayList;
import java.util.List;
import org.teiid.core.util.StringUtil;
import org.teiid.core.designer.util.CoreStringUtil;

//We also need to bring back our SAX handler "header reader"
//that reads a stream and extracts the model information
Expand Down Expand Up @@ -110,7 +110,7 @@ public String getXmiVersion() {
}

public void addNamespaceURI( final String uri ) {
if (!StringUtil.isEmpty(uri) && !this.namespaceURIs.contains(uri)) {
if (!CoreStringUtil.isEmpty(uri) && !this.namespaceURIs.contains(uri)) {
this.namespaceURIs.add(uri);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
package org.teiid.designer.common.xml;

import org.jdom.Verifier;

import org.teiid.core.util.StringUtil;
import org.teiid.core.designer.util.CoreStringUtil;

/**
* Utility class for XML documents and related items.
Expand Down Expand Up @@ -83,12 +82,12 @@ public static String escapeCharacterData(String text) {
/*
* We must do this one first so as not to disturb the other &s in the escaped string.
*/
String escaped = StringUtil.replace(text, "&", "&amp;"); //$NON-NLS-1$ //$NON-NLS-2$
String escaped = CoreStringUtil.replace(text, "&", "&amp;"); //$NON-NLS-1$ //$NON-NLS-2$

escaped = StringUtil.replace(escaped, ">", "&gt;"); //$NON-NLS-1$ //$NON-NLS-2$
escaped = StringUtil.replace(escaped, "<", "&lt;"); //$NON-NLS-1$ //$NON-NLS-2$
escaped = StringUtil.replace(escaped, "\"", "&quot;"); //$NON-NLS-1$ //$NON-NLS-2$
escaped = StringUtil.replace(escaped, "'", "&apos;"); //$NON-NLS-1$ //$NON-NLS-2$
escaped = CoreStringUtil.replace(escaped, ">", "&gt;"); //$NON-NLS-1$ //$NON-NLS-2$
escaped = CoreStringUtil.replace(escaped, "<", "&lt;"); //$NON-NLS-1$ //$NON-NLS-2$
escaped = CoreStringUtil.replace(escaped, "\"", "&quot;"); //$NON-NLS-1$ //$NON-NLS-2$
escaped = CoreStringUtil.replace(escaped, "'", "&apos;"); //$NON-NLS-1$ //$NON-NLS-2$

return escaped;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
import java.util.Random;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import org.teiid.core.designer.util.CoreArgCheck;
import org.teiid.core.util.Assertion;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.core.designer.util.FileUtils;
import org.teiid.core.util.StringUtil;
import org.teiid.core.util.Assertion;
import org.teiid.designer.core.util.AssertionUtil;
import org.teiid.designer.core.util.FileUtil;
import org.teiid.designer.core.util.TempDirectory;
Expand Down Expand Up @@ -510,7 +509,7 @@ public InputStream getFileContent( final String path,
for (int i = 0; i < tokens.length; i++) {
final String token = tokens[i];
final String tokenReplacement = tokenReplacements[i];
fileContents = StringUtil.replaceAll(fileContents, token, tokenReplacement);
fileContents = CoreStringUtil.replaceAll(fileContents, token, tokenReplacement);
}
this.fileSize = fileContents.length();
return new ByteArrayInputStream(fileContents.getBytes());
Expand Down

0 comments on commit 03042dc

Please sign in to comment.