Merge branch 'master' into bugfix/6.2.0/TUP-4851_upgradeComponentDaikon

This commit is contained in:
nrousseau
2016-06-16 19:04:00 +08:00
14 changed files with 202 additions and 97 deletions

View File

@@ -45,17 +45,22 @@ public enum EHadoopProperties {
DATABASE,
PORT,
CLOUDERA_NAVIGATOR_USERNAME,
CLOUDERA_NAVIGATOR_PASSWORD,
CLOUDERA_NAVIGATOR_URL,
CLOUDERA_NAVIGATOR_METADATA_URL,
CLOUDERA_NAVIGATOR_CLIENT_URL,
MAPRTICKET_CLUSTER,
MAPRTICKET_DURATION,
MAPR_HOME_DIR,
HADOOP_LOGIN,
;
public String getName() {

View File

@@ -10,7 +10,7 @@
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.runprocess;
package org.talend.core.runtime.process;
import java.util.HashMap;
import java.util.HashSet;

View File

@@ -71,10 +71,10 @@ import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.repository.RepositoryManager;
import org.talend.core.model.repository.job.JobResource;
import org.talend.core.model.repository.job.JobResourceManager;
import org.talend.core.model.runprocess.LastGenerationInfo;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.model.utils.PerlResourcesHelper;
import org.talend.core.runtime.process.ITalendProcessJavaProject;
import org.talend.core.runtime.process.LastGenerationInfo;
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
import org.talend.core.runtime.process.TalendProcessOptionConstants;
import org.talend.core.services.ISVNProviderService;
@@ -905,9 +905,7 @@ public class ProcessorUtilities {
// set the last jobinfos to be able to set check the errors in the problems view (errors of compilations
// only)
// here we recreate a new JobInfo, to be sure to don't have link in memory to Emf or IProcess
JobInfo generatedJobInfo = new JobInfo(jobInfo.getJobId(), jobInfo.getContextName(), jobInfo.getJobVersion());
generatedJobInfo.setJobName(currentProcess.getName());
generatedJobInfo.setTestContainer(jobInfo.isTestContainer());
JobInfo generatedJobInfo = cloneJobInfo(jobInfo);
String projectFolderName;
if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
projectFolderName = JavaResourcesHelper.getProjectFolderName(selectedProcessItem);
@@ -921,6 +919,22 @@ public class ProcessorUtilities {
}
}
/**
* DOC nrousseau Comment method "cloneJobInfo".
* @param jobInfo
* @return
*/
private static JobInfo cloneJobInfo(JobInfo jobInfo) {
if (jobInfo == null) {
return null;
}
JobInfo generatedJobInfo = new JobInfo(jobInfo.getJobId(), jobInfo.getContextName(), jobInfo.getJobVersion());
generatedJobInfo.setJobName(jobInfo.getJobName());
generatedJobInfo.setTestContainer(jobInfo.isTestContainer());
generatedJobInfo.setFatherJobInfo(cloneJobInfo(jobInfo.getFatherJobInfo()));
return generatedJobInfo;
}
private static void generateNodeInfo(JobInfo jobInfo, String selectedContextName, boolean statistics, boolean properties,
int option, IProgressMonitor progressMonitor, IProcess currentProcess) throws ProcessorException {
if (BitwiseOptionUtils.containOption(option, GENERATE_TESTS) && jobInfo.getProcessItem() != null) {
@@ -982,28 +996,30 @@ public class ProcessorUtilities {
}
subJobInfo.setJobVersion(processItem.getProperty().getVersion());
subJobInfo.setJobName(processItem.getProperty().getLabel());
if (!isNeedLoadmodules) {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(subJobInfo.getJobId(),
subJobInfo.getJobVersion(), Collections.<ModuleNeeded> emptySet());
}
if (jobInfo.isApplyContextToChildren()) {
subJobInfo.setApplyContextToChildren(jobInfo.isApplyContextToChildren());
// see bug 0003862: Export job with the flag "Apply to children" if the child don't have
// the
// same context fails.
if (checkIfContextExisted(processItem, selectedContextName)) {
subJobInfo.setContextName(selectedContextName);
} else {
// use the default context of subjob
String defaultContext = processItem.getProcess().getDefaultContext();
node.getElementParameter("PROCESS_TYPE_CONTEXT").setValue(defaultContext); //$NON-NLS-1$
subJobInfo.setContextName(defaultContext);
}
}
subJobInfo.setFatherJobInfo(jobInfo);
if (!jobList.contains(subJobInfo)) {
if (!isNeedLoadmodules) {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(subJobInfo.getJobId(),
subJobInfo.getJobVersion(), Collections.<ModuleNeeded> emptySet());
}
if (jobInfo.isApplyContextToChildren()) {
subJobInfo.setApplyContextToChildren(jobInfo.isApplyContextToChildren());
// see bug 0003862: Export job with the flag "Apply to children" if the child don't have
// the
// same context fails.
if (checkIfContextExisted(processItem, selectedContextName)) {
subJobInfo.setContextName(selectedContextName);
} else {
// use the default context of subjob
String defaultContext = processItem.getProcess().getDefaultContext();
node.getElementParameter("PROCESS_TYPE_CONTEXT").setValue(defaultContext); //$NON-NLS-1$
subJobInfo.setContextName(defaultContext);
}
}
int subJobOption = GENERATE_ALL_CHILDS;
if (BitwiseOptionUtils.containOption(option, GENERATE_WITH_FIRST_CHILD)) {
subJobOption = GENERATE_MAIN_ONLY;
@@ -1019,37 +1035,37 @@ public class ProcessorUtilities {
if (!BitwiseOptionUtils.containOption(option, GENERATE_WITH_FIRST_CHILD)) {
currentProcess.setNeedRegenerateCode(true);
}
}
LastGenerationInfo
.getInstance()
.getModulesNeededWithSubjobPerJob(jobInfo.getJobId(), jobInfo.getJobVersion())
.addAll(LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(
subJobInfo.getJobId(), subJobInfo.getJobVersion()));
LastGenerationInfo
.getInstance()
.getPigudfNeededWithSubjobPerJob(jobInfo.getJobId(), jobInfo.getJobVersion())
.addAll(LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(
subJobInfo.getJobId(), subJobInfo.getJobVersion()));
LastGenerationInfo
.getInstance()
.getModulesNeededWithSubjobPerJob(jobInfo.getJobId(), jobInfo.getJobVersion())
.addAll(LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(
subJobInfo.getJobId(), subJobInfo.getJobVersion()));
LastGenerationInfo
.getInstance()
.getPigudfNeededWithSubjobPerJob(jobInfo.getJobId(), jobInfo.getJobVersion())
.addAll(LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(
subJobInfo.getJobId(), subJobInfo.getJobVersion()));
LastGenerationInfo
.getInstance()
.getRoutinesNeededWithSubjobPerJob(jobInfo.getJobId(), jobInfo.getJobVersion())
.addAll(LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(
subJobInfo.getJobId(), subJobInfo.getJobVersion()));
LastGenerationInfo
.getInstance()
.getRoutinesNeededWithSubjobPerJob(jobInfo.getJobId(), jobInfo.getJobVersion())
.addAll(LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(
subJobInfo.getJobId(), subJobInfo.getJobVersion()));
if (!LastGenerationInfo.getInstance().isUseDynamic(jobInfo.getJobId(), jobInfo.getJobVersion())) {
LastGenerationInfo.getInstance().setUseDynamic(
jobInfo.getJobId(),
jobInfo.getJobVersion(),
LastGenerationInfo.getInstance().isUseDynamic(subJobInfo.getJobId(),
subJobInfo.getJobVersion()));
}
if (!LastGenerationInfo.getInstance().isUsePigUDFs(jobInfo.getJobId(), jobInfo.getJobVersion())) {
LastGenerationInfo.getInstance().setUsePigUDFs(
jobInfo.getJobId(),
jobInfo.getJobVersion(),
LastGenerationInfo.getInstance().isUsePigUDFs(subJobInfo.getJobId(),
subJobInfo.getJobVersion()));
if (!LastGenerationInfo.getInstance().isUseDynamic(jobInfo.getJobId(), jobInfo.getJobVersion())) {
LastGenerationInfo.getInstance().setUseDynamic(
jobInfo.getJobId(),
jobInfo.getJobVersion(),
LastGenerationInfo.getInstance().isUseDynamic(subJobInfo.getJobId(),
subJobInfo.getJobVersion()));
}
if (!LastGenerationInfo.getInstance().isUsePigUDFs(jobInfo.getJobId(), jobInfo.getJobVersion())) {
LastGenerationInfo.getInstance().setUsePigUDFs(
jobInfo.getJobId(),
jobInfo.getJobVersion(),
LastGenerationInfo.getInstance().isUsePigUDFs(subJobInfo.getJobId(),
subJobInfo.getJobVersion()));
}
}
}
}

View File

@@ -149,10 +149,14 @@ public class ProjectPomManager {
}
if (processor != null) {
String mainPom = PomUtil.getPomFileName(processor.getProperty().getLabel(), processor.getProperty().getVersion());
for (JobInfo childJob : processor.getBuildChildrenJobs()) {
modulesList.add(PomUtil.getPomFileName(childJob.getJobName(), childJob.getJobVersion()));
String childPom = PomUtil.getPomFileName(childJob.getJobName(), childJob.getJobVersion());
if (!childPom.equals(mainPom)) {
modulesList.add(childPom);
}
}
modulesList.add(PomUtil.getPomFileName(processor.getProperty().getLabel(), processor.getProperty().getVersion()));
modulesList.add(mainPom);
}
// check the modules
List<String> modules = projectModel.getModules();
@@ -211,7 +215,7 @@ public class ProjectPomManager {
Iterator<Dependency> iterator = withoutChildrenJobDependencies.iterator();
while (iterator.hasNext()) {
Dependency d = iterator.next();
if (d.getGroupId().startsWith(jobGroupPrefix)||d.getGroupId().startsWith(testGroupPrefix)) {
if (d.getGroupId().startsWith(jobGroupPrefix) || d.getGroupId().startsWith(testGroupPrefix)) {
// remove the children job's dependencies
iterator.remove();
}

View File

@@ -29,6 +29,7 @@ import org.talend.core.model.properties.Project;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.runtime.process.LastGenerationInfo;
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
import org.talend.designer.maven.template.ETalendMavenVariables;
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
@@ -117,11 +118,11 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
protected void addDependencies(Model model) {
try {
getProcessorDependenciesManager().updateDependencies(null, model);
// add children jobs in dependencies
final List<Dependency> dependencies = model.getDependencies();
String parentId = getJobProcessor().getProperty().getId();
final Set<JobInfo> clonedChildrenJobInfors = getJobProcessor().getBuildChildrenJobs();
final Set<JobInfo> clonedChildrenJobInfors = getJobProcessor().getBuildChildrenJobs();
for (JobInfo jobInfo : clonedChildrenJobInfors) {
if (jobInfo.getFatherJobInfo() != null && jobInfo.getFatherJobInfo().getJobId().equals(parentId)) {
if (!validChildrenJob(jobInfo)) {

View File

@@ -60,6 +60,7 @@ import org.talend.core.model.repository.SVNConstant;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.process.JobInfoProperties;
import org.talend.core.runtime.process.LastGenerationInfo;
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
import org.talend.core.runtime.projectsetting.IProjectSettingPreferenceConstants;
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
@@ -385,6 +386,22 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
@Override
protected boolean validChildrenJob(JobInfo jobInfo) {
JobInfo fatherJobInfo = null;
for (JobInfo lastGeneratedJobInfo : LastGenerationInfo.getInstance().getLastGeneratedjobs()) {
if (lastGeneratedJobInfo.getJobId().equals(getJobProcessor().getProperty().getId()) && lastGeneratedJobInfo.getJobVersion().equals(getJobProcessor().getProperty().getVersion())) {
fatherJobInfo = lastGeneratedJobInfo;
break;
}
}
if (fatherJobInfo != null) {
fatherJobInfo = fatherJobInfo.getFatherJobInfo();
}
while (fatherJobInfo != null) {
if (fatherJobInfo.getJobId().equals(jobInfo.getJobId()) && fatherJobInfo.getJobVersion().equals(jobInfo.getJobVersion())) {
return false;
}
fatherJobInfo = fatherJobInfo.getFatherJobInfo();
}
// for job, ignore test container for children.
return jobInfo != null && !jobInfo.isTestContainer();
}
@@ -554,6 +571,9 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
List<String> childrenFolderResourcesIncludes = new ArrayList<String>();
final Set<JobInfo> clonedChildrenJobInfors = getJobProcessor().getBuildChildrenJobs();
// main job built, should never be in the children list, even if recursive
clonedChildrenJobInfors.remove(LastGenerationInfo.getInstance().getLastMainJob());
for (JobInfo child : clonedChildrenJobInfors) {
if (child.getFatherJobInfo() != null) {

View File

@@ -12,7 +12,6 @@
// ============================================================================
package org.talend.librariesmanager.utils;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
@@ -112,14 +111,10 @@ abstract public class DownloadModuleRunnable implements IRunnableWithProgress {
// deploy to index as snapshot
installedModules.add(module.getName());
} catch (SocketTimeoutException e) {
downloadFailed.add(module.getName());
connectionTimeOut = true;
MessageBoxExceptionHandler.process(e);
continue;
} catch (Exception e) {
downloadFailed.add(module.getName());
MessageBoxExceptionHandler.process(e);
connectionTimeOut = true;
MessageBoxExceptionHandler.process(new Exception("Download " + module.getName() + " failed!"));
continue;
}
accepted = false;

View File

@@ -399,12 +399,8 @@ public class LocalLibraryManager implements ILibraryManagerService {
}
}
}
} catch (IOException e) {
CommonExceptionHandler.process(e);
} catch (RuntimeException e) {
CommonExceptionHandler.process(e);
} catch (Exception e) {
CommonExceptionHandler.process(e);
CommonExceptionHandler.process(new Exception(getClass().getSimpleName() + " resolve " + mavenUri + " failed !"));
}
try {
if (jarFile == null) {

View File

@@ -1208,7 +1208,8 @@ public class DatabaseForm extends AbstractForm {
maprTUsernameForHiveTxt = new LabelledText(authenticationUserPassComForHive,
Messages.getString("DatabaseForm.hive.MaprTUsernameTxt.label"), 2); //$NON-NLS-1$
maprTPasswordForHiveTxt = new LabelledText(authenticationUserPassComForHive,
Messages.getString("DatabaseForm.hive.MaprTPasswordTxt.label"), 2, SWT.PASSWORD); //$NON-NLS-1$
Messages.getString("DatabaseForm.hive.MaprTPasswordTxt.label"), 2, SWT.PASSWORD | SWT.BORDER | SWT.SINGLE); //$NON-NLS-1$
maprTPasswordForHiveTxt.getTextControl().setEchoChar('*');
maprTClusterForHiveTxt = new LabelledText(authenticationMaprTComForHive,
Messages.getString("DatabaseForm.hive.MaprTClusterTxt.label"), 2); //$NON-NLS-1$
@@ -1290,7 +1291,8 @@ public class DatabaseForm extends AbstractForm {
maprTUsernameForHBaseTxt = new LabelledText(authenticationUserPassComForHBase,
Messages.getString("DatabaseForm.hbaseMaprTUsernameTxt.label"), 2); //$NON-NLS-1$
maprTPasswordForHBaseTxt = new LabelledText(authenticationUserPassComForHBase,
Messages.getString("DatabaseForm.hbaseMaprTPasswordTxt.label"), 2, SWT.PASSWORD); //$NON-NLS-1$
Messages.getString("DatabaseForm.hbaseMaprTPasswordTxt.label"), 2, SWT.PASSWORD | SWT.BORDER | SWT.SINGLE); //$NON-NLS-1$
maprTPasswordForHBaseTxt.getTextControl().setEchoChar('*');
maprTClusterForHBaseTxt = new LabelledText(authenticationMaprTComForHBase,
Messages.getString("DatabaseForm.hbaseMaprTClusterTxt.label"), 2); //$NON-NLS-1$

View File

@@ -12,11 +12,21 @@
// ============================================================================
package org.talend.repository.viewer.content;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.internal.navigator.ContributorTrackingSet;
import org.eclipse.ui.internal.navigator.NavigatorContentService;
import org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor;
import org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension;
import org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider;
import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.ICommonContentExtensionSite;
import org.eclipse.ui.navigator.INavigatorContentDescriptor;
import org.eclipse.ui.navigator.INavigatorContentService;
import org.eclipse.ui.navigator.IPipelinedTreeContentProvider;
import org.eclipse.ui.navigator.PipelinedShapeModification;
import org.eclipse.ui.navigator.PipelinedViewerUpdate;
@@ -46,15 +56,16 @@ import org.eclipse.ui.navigator.PipelinedViewerUpdate;
* */
public class EmptyContentProvider implements IPipelinedTreeContentProvider {
private Viewer viewer;
@Override
public void dispose() {
// left empty on purpose
this.viewer = null;
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// left empty on purpose
this.viewer = viewer;
}
@Override
@@ -118,9 +129,56 @@ public class EmptyContentProvider implements IPipelinedTreeContentProvider {
*/
@Override
public void getPipelinedChildren(Object aParent, Set theCurrentChildren) {
removeResourceVisitorForOverride(theCurrentChildren);
theCurrentChildren.clear();
}
@SuppressWarnings({ "restriction", "rawtypes" })
private void removeResourceVisitorForOverride(Set theCurrentChildren) {
if (this.viewer instanceof CommonViewer && theCurrentChildren instanceof ContributorTrackingSet) {
INavigatorContentService navigatorContentService = ((CommonViewer) this.viewer).getNavigatorContentService();
if (navigatorContentService instanceof NavigatorContentService) {
ContributorTrackingSet contributorTrackingSet = (ContributorTrackingSet) theCurrentChildren;
// have override
INavigatorContentDescriptor firstClassContributor = contributorTrackingSet.getFirstClassContributor();
if (!firstClassContributor.hasOverridingExtensions()) {
return;
}
// check override
boolean isOverride = false;
INavigatorContentDescriptor descriptor = contributorTrackingSet.getContributor();
NavigatorContentDescriptor overridingDescriptor;
for (Iterator contentDescriptorsItr = firstClassContributor.getOverriddingExtensions().iterator(); contentDescriptorsItr
.hasNext();) {
overridingDescriptor = (NavigatorContentDescriptor) contentDescriptorsItr.next();
if (overridingDescriptor.getId().equals(descriptor.getId())) {
isOverride = true;
}
}
if (!isOverride) {
return;
}
// remove ResourceVisitor
NavigatorContentExtension firstClassExtension = ((NavigatorContentService) navigatorContentService)
.getExtension(firstClassContributor);
if (firstClassExtension != null) {
SafeDelegateTreeContentProvider internalGetContentProvider = firstClassExtension.internalGetContentProvider();
if (internalGetContentProvider != null) {
ITreeContentProvider delegateContentProvider = internalGetContentProvider.getDelegateContentProvider();
if (delegateContentProvider instanceof FolderListenerSingleTopContentProvider) {
// try to remove the ResourceVisitor of FolderListenerSingleTopContentProvider
delegateContentProvider.dispose();
}
}
}
}
}
}
/*
* (non-Javadoc)
*
@@ -128,6 +186,7 @@ public class EmptyContentProvider implements IPipelinedTreeContentProvider {
*/
@Override
public void getPipelinedElements(Object anInput, Set theCurrentElements) {
removeResourceVisitorForOverride(theCurrentElements);
theCurrentElements.clear();
}

View File

@@ -243,13 +243,13 @@ public abstract class FolderListenerSingleTopContentProvider extends SingleTopLe
CommonNavigator commonNavigator = ((RepoViewCommonViewer) this.viewer).getCommonNavigator();
if (commonNavigator instanceof RepoViewCommonNavigator) {
((RepoViewCommonNavigator) commonNavigator).removeVisitor(this.visitor);
this.visitor = null;
}
}
}
// to help garbage collection
topLevelNodeToPathMap.clear();
topLevelNodeToPathMap = null;
super.dispose();
}
}

View File

@@ -26,13 +26,12 @@ public final class StringFormatUtil {
public static final int PERCENT = 0;
public static final int NUMBER = 1;
public static final int INT_NUMBER = 1;
public static final int DOUBLE_NUMBER = 2;
public static final int OTHER = 99999;
private StringFormatUtil() {
}
/**
* Method "padString".
*
@@ -41,14 +40,14 @@ public final class StringFormatUtil {
* @return the given string completed with white spaces up the the given size.
*/
public static String padString(String stringToPad, int size) {
return String.format("%" + size + "s", stringToPad);
return String.format("%" + size + "s", stringToPad); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* DOC Zqin Comment method "format".
*
* @param input the object that was formated.
* @param style the style of formated, it should be 0, 1, 99999.
* @param style the style of formated, it should be 0, 1,2,99999.
* @return the formated object.
*/
public static Object format(Object input, int style) {
@@ -64,29 +63,37 @@ public final class StringFormatUtil {
BigDecimal max = new BigDecimal(9999 * 10E-5);
boolean isUseScientific = false;
switch (style) {
case 0:
case PERCENT:
if (temp.compareTo(min) == -1 && temp.compareTo(zero) == 1) {
isUseScientific = true;
} else if (temp.compareTo(max) == 1 && temp.compareTo(new BigDecimal(1)) == -1) {
input = max.toString();
}
format = (DecimalFormat) DecimalFormat.getPercentInstance(Locale.ENGLISH);
format.applyPattern("0.00%");
format.applyPattern("0.00%"); //$NON-NLS-1$
break;
case 1:
case INT_NUMBER:
min = new BigDecimal(10E-3);
if (temp.compareTo(min) == -1 && temp.compareTo(zero) == 1) {
isUseScientific = true;
}
format = (DecimalFormat) DecimalFormat.getNumberInstance(Locale.ENGLISH);
format.applyPattern("0.00");
format.applyPattern("0"); //$NON-NLS-1$
break;
case DOUBLE_NUMBER:
min = new BigDecimal(10E-3);
if (temp.compareTo(min) == -1 && temp.compareTo(zero) == 1) {
isUseScientific = true;
}
format = (DecimalFormat) DecimalFormat.getNumberInstance(Locale.ENGLISH);
format.applyPattern("0.00"); //$NON-NLS-1$
break;
default:
format = (DecimalFormat) DecimalFormat.getInstance(Locale.getDefault());
return format.parse(input.toString());
}
if (isUseScientific) {
format.applyPattern("0.###E0%");
format.applyPattern("0.###E0%"); //$NON-NLS-1$
}
return format.format(new Double(input.toString()));
@@ -109,7 +116,7 @@ public final class StringFormatUtil {
if (checkInput(input)) {
Double db = new Double(input.toString());
DecimalFormat format = (DecimalFormat) DecimalFormat.getPercentInstance(Locale.ENGLISH);
format.applyPattern("0.00%");
format.applyPattern("0.00%"); //$NON-NLS-1$
return format.format(db);
}
@@ -127,7 +134,7 @@ public final class StringFormatUtil {
if (checkInput(input)) {
Double db = new Double(input.toString());
DecimalFormat format = (DecimalFormat) DecimalFormat.getNumberInstance(Locale.ENGLISH);
format.applyPattern("0.00");
format.applyPattern("0.00"); //$NON-NLS-1$
return Double.valueOf(format.format(db));
}
@@ -145,7 +152,7 @@ public final class StringFormatUtil {
if (checkInput(input)) {
Double db = new Double(input.toString());
DecimalFormat format = (DecimalFormat) DecimalFormat.getNumberInstance(Locale.ENGLISH);
format.applyPattern("0.0000");
format.applyPattern("0.0000"); //$NON-NLS-1$
return Double.valueOf(format.format(db));
}
@@ -181,7 +188,7 @@ public final class StringFormatUtil {
* @return true if the input is valid, else false;
*/
private static boolean checkInput(Object input) {
if (input == null || "".equals(input)) {
if (input == null || "".equals(input)) { //$NON-NLS-1$
return false;
} else {
Double db = new Double(input.toString());
@@ -196,7 +203,7 @@ public final class StringFormatUtil {
public static Double formatPercentDecimalDouble(Object input) {
if (checkInput(input)) {
BigDecimal bd1 = new BigDecimal(input.toString());
BigDecimal bd2 = new BigDecimal("100");
BigDecimal bd2 = new BigDecimal("100"); //$NON-NLS-1$
return bd1.multiply(bd2).doubleValue();
}
return null;