From d8e0dd4a56697c482abd27d41d9552b950edaee7 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Fri, 3 Feb 2012 21:14:17 +0100 Subject: [PATCH] Checkstyle --- .../.settings/org.eclipse.jdt.core.prefs | 9 ++- .../.settings/org.eclipse.jdt.ui.prefs | 55 ++++++++++++- Kieker.WebGUI/nb-configuration.xml | 18 +++++ .../AvailableDependenciesBean.java | 2 +- .../application/AvailableProjectsBean.java | 44 +++++----- .../beans/application/ThemeSwitcherBean.java | 72 +++++++++-------- .../request/SelectedDependenciesBean.java | 10 +-- .../webgui/beans/request/StringBean.java | 4 +- .../beans/session/CurrentThemeBean.java | 11 +-- .../session/DependencyUploadController.java | 11 ++- .../beans/session/SelectedProjectBean.java | 19 +++-- .../kieker/webgui/common/FileManager.java | 81 ++++++++++--------- .../kieker/webgui/common/PluginFinder.java | 19 +++-- .../converter/MIDependencyToIntConverter.java | 17 ++-- .../MIDependencyToStringConverter.java | 58 ++++++++----- .../converter/MIProjectToStringConverter.java | 51 ++++++++++-- 16 files changed, 325 insertions(+), 156 deletions(-) create mode 100644 Kieker.WebGUI/nb-configuration.xml diff --git a/Kieker.WebGUI/.settings/org.eclipse.jdt.core.prefs b/Kieker.WebGUI/.settings/org.eclipse.jdt.core.prefs index 4ad575de..0cc6f704 100644 --- a/Kieker.WebGUI/.settings/org.eclipse.jdt.core.prefs +++ b/Kieker.WebGUI/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,14 @@ -#Thu Jan 26 11:46:13 CET 2012 +#Fri Feb 03 21:01:28 CET 2012 eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false diff --git a/Kieker.WebGUI/.settings/org.eclipse.jdt.ui.prefs b/Kieker.WebGUI/.settings/org.eclipse.jdt.ui.prefs index 9d66836f..36d8a56b 100644 --- a/Kieker.WebGUI/.settings/org.eclipse.jdt.ui.prefs +++ b/Kieker.WebGUI/.settings/org.eclipse.jdt.ui.prefs @@ -1,4 +1,4 @@ -#Thu Jan 26 11:46:13 CET 2012 +#Fri Feb 03 21:03:00 CET 2012 cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -53,5 +53,58 @@ cleanup.use_this_for_non_static_method_access_only_if_necessary=false cleanup_profile=_Kieker - Clean Up cleanup_settings_version=2 eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Kieker - Profile formatter_settings_version=12 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=true +sp_cleanup.always_use_this_for_non_static_method_access=true +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=true +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=true +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false diff --git a/Kieker.WebGUI/nb-configuration.xml b/Kieker.WebGUI/nb-configuration.xml new file mode 100644 index 00000000..8e1e369b --- /dev/null +++ b/Kieker.WebGUI/nb-configuration.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project-shared-configuration> + <!-- +This file contains additional configuration written by modules in the NetBeans IDE. +The configuration is intended to be shared among all the users of project and +therefore it is assumed to be part of version control checkout. +Without this configuration present, some functionality in the IDE may be limited or fail altogether. +--> + <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"> + <!-- +Properties that influence various parts of the IDE, especially code formatting and the like. +You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up. +That way multiple projects can share the same settings (useful for formatting rules for example). +Any value defined here will override the pom.xml file value but is only applicable to the current project. +--> + <netbeans.checkstyle.format>true</netbeans.checkstyle.format> + </properties> +</project-shared-configuration> diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableDependenciesBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableDependenciesBean.java index 2132b640..7230e399 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableDependenciesBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableDependenciesBean.java @@ -41,7 +41,7 @@ public class AvailableDependenciesBean { } public List<MIDependency> getDependencies() { - return dependencies; + return this.dependencies; } public void upload(final UploadedFile file) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java index fde98d72..d176369b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java @@ -1,20 +1,22 @@ -/************************************************************************** - * Copyright 2012 by + Christian-Albrechts-University of Kiel + Department of - * Computer Science + Software Engineering Group and others. +/*************************************************************************** + * Copyright 2012 by + * + Christian-Albrechts-University of Kiel + * + Department of Computer Science + * + Software Engineering Group + * and others. * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - ************************************************************************** - */ + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ package kieker.webgui.beans.application; import java.util.List; @@ -44,15 +46,15 @@ public class AvailableProjectsBean { private final MAnalysisMetaModelFactory factory; public AvailableProjectsBean() { - projects = FileManager.getInstance().loadAllProjects(); - factory = new MAnalysisMetaModelFactory(); + this.projects = FileManager.getInstance().loadAllProjects(); + this.factory = new MAnalysisMetaModelFactory(); } public synchronized void addProject(final String projectName) { /* * Create a new project. */ - final MIProject project = factory.createProject(); + final MIProject project = this.factory.createProject(); project.setName(projectName); /* @@ -63,22 +65,22 @@ public class AvailableProjectsBean { * Set the new project as the main project, if the current user * doesn't have one. */ - FacesContext context = FacesContext.getCurrentInstance(); - SelectedProjectBean bean = (SelectedProjectBean) context.getApplication().evaluateExpressionGet(context, "#{selectedProjectBean}", + final FacesContext context = FacesContext.getCurrentInstance(); + final SelectedProjectBean bean = context.getApplication().evaluateExpressionGet(context, "#{selectedProjectBean}", SelectedProjectBean.class); if (bean.getMainProject() == null) { bean.setMainProject(project); } - projects.add(project); + this.projects.add(project); } } @SuppressWarnings("unused") public synchronized TreeNode getProjectsRoot() { - TreeNode root = new DefaultTreeNode("Root", null); + final TreeNode root = new DefaultTreeNode("Root", null); - for (final MIProject project : projects) { + for (final MIProject project : this.projects) { final TreeNode projectNode = new DefaultTreeNode("project", project, root); final TreeNode dependenciesNode = new DefaultTreeNode("dependencies", "Dependencies", projectNode); final TreeNode usedPluginsNode = new DefaultTreeNode("usedPlugins", "Used Plugins", projectNode); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java index 7f0424a7..a712e102 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java @@ -22,6 +22,7 @@ package kieker.webgui.beans.application; import java.util.Map; import java.util.TreeMap; + import javax.annotation.PostConstruct; import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; @@ -38,13 +39,18 @@ public class ThemeSwitcherBean { private Map<String, String> themes; + /** + * Creates a new instance of this class. + */ + public ThemeSwitcherBean() {} + /** * Returns the available themes. * * @return A map containing the user readable names of the themes as a key and the actual theme-names as the corresponding value. */ public Map<String, String> getThemes() { - return themes; + return this.themes; } /** @@ -52,38 +58,38 @@ public class ThemeSwitcherBean { */ @PostConstruct public void init() { - themes = new TreeMap<String, String>(); + this.themes = new TreeMap<String, String>(); - themes.put("Aristo", "aristo"); - themes.put("Black-Tie", "black-tie"); - themes.put("Blitzer", "blitzer"); - themes.put("Bluesky", "bluesky"); - themes.put("Casablanca", "casablanca"); - themes.put("Cupertino", "cupertino"); - themes.put("Dark-Hive", "dark-hive"); - themes.put("Dot-Luv", "dot-luv"); - themes.put("Eggplant", "eggplant"); - themes.put("Excite-Bike", "excite-bike"); - themes.put("Flick", "flick"); - themes.put("Glass-X", "glass-x"); - themes.put("Hot-Sneaks", "hot-sneaks"); - themes.put("Humanity", "humanity"); - themes.put("Le-Frog", "le-frog"); - themes.put("Midnight", "midnight"); - themes.put("Mint-Choc", "mint-choc"); - themes.put("Overcast", "overcast"); - themes.put("Pepper-Grinder", "pepper-grinder"); - themes.put("Redmond", "redmond"); - themes.put("Rocket", "rocket"); - themes.put("Sam", "sam"); - themes.put("Smoothness", "smoothness"); - themes.put("South-Street", "south-street"); - themes.put("Start", "start"); - themes.put("Sunny", "sunny"); - themes.put("Swanky-Purse", "swanky-purse"); - themes.put("Trontastic", "trontastic"); - themes.put("UI-Darkness", "ui-darkness"); - themes.put("UI-Lightness", "ui-lightness"); - themes.put("Vader", "vader"); + this.themes.put("Aristo", "aristo"); + this.themes.put("Black-Tie", "black-tie"); + this.themes.put("Blitzer", "blitzer"); + this.themes.put("Bluesky", "bluesky"); + this.themes.put("Casablanca", "casablanca"); + this.themes.put("Cupertino", "cupertino"); + this.themes.put("Dark-Hive", "dark-hive"); + this.themes.put("Dot-Luv", "dot-luv"); + this.themes.put("Eggplant", "eggplant"); + this.themes.put("Excite-Bike", "excite-bike"); + this.themes.put("Flick", "flick"); + this.themes.put("Glass-X", "glass-x"); + this.themes.put("Hot-Sneaks", "hot-sneaks"); + this.themes.put("Humanity", "humanity"); + this.themes.put("Le-Frog", "le-frog"); + this.themes.put("Midnight", "midnight"); + this.themes.put("Mint-Choc", "mint-choc"); + this.themes.put("Overcast", "overcast"); + this.themes.put("Pepper-Grinder", "pepper-grinder"); + this.themes.put("Redmond", "redmond"); + this.themes.put("Rocket", "rocket"); + this.themes.put("Sam", "sam"); + this.themes.put("Smoothness", "smoothness"); + this.themes.put("South-Street", "south-street"); + this.themes.put("Start", "start"); + this.themes.put("Sunny", "sunny"); + this.themes.put("Swanky-Purse", "swanky-purse"); + this.themes.put("Trontastic", "trontastic"); + this.themes.put("UI-Darkness", "ui-darkness"); + this.themes.put("UI-Lightness", "ui-lightness"); + this.themes.put("Vader", "vader"); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java index df6337a8..625fc06b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java @@ -35,20 +35,20 @@ public class SelectedDependenciesBean { private DualListModel<String> dependencies; public SelectedDependenciesBean() { - List<String> source = new ArrayList<String>(); - List<String> target = new ArrayList<String>(); + final List<String> source = new ArrayList<String>(); + final List<String> target = new ArrayList<String>(); source.add("Lib 1"); source.add("Lib 2"); - dependencies = new DualListModel<String>(source, target); + this.dependencies = new DualListModel<String>(source, target); } public DualListModel<String> getDependencies() { - return dependencies; + return this.dependencies; } - public void setDependencies(DualListModel<String> dependencies) { + public void setDependencies(final DualListModel<String> dependencies) { this.dependencies = dependencies; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java index c61a58bd..5310f8a4 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java @@ -47,7 +47,7 @@ public class StringBean { * @return The current string stored within this bean. */ public String getString() { - return string; + return this.string; } /** @@ -56,7 +56,7 @@ public class StringBean { * @param string * The new string to be stored within this bean. */ - public void setString(String string) { + public void setString(final String string) { this.string = string; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java index 8f0aefcc..06731b9e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java @@ -21,6 +21,7 @@ package kieker.webgui.beans.session; import java.util.Map; + import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.faces.context.FacesContext; @@ -47,13 +48,13 @@ public class CurrentThemeBean { */ public CurrentThemeBean() { /* Get the parameters within the current context. */ - Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); + final Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); /* Try to find the default theme. */ if (params.containsKey("theme")) { - theme = params.get("theme"); + this.theme = params.get("theme"); } else { /* Use the default theme. */ - theme = DEFAULT_THEME; + this.theme = CurrentThemeBean.DEFAULT_THEME; } } @@ -63,7 +64,7 @@ public class CurrentThemeBean { * @return The currently used theme. */ public String getTheme() { - return theme; + return this.theme; } /** @@ -72,7 +73,7 @@ public class CurrentThemeBean { * @param theme * The new theme to be stored within this instance. */ - public void setTheme(String theme) { + public void setTheme(final String theme) { this.theme = theme; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/DependencyUploadController.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/DependencyUploadController.java index 036c651e..1b80e64f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/DependencyUploadController.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/DependencyUploadController.java @@ -37,15 +37,20 @@ public class DependencyUploadController { private UploadedFile file; + /** + * Creates a new instance of this class. + */ + public DependencyUploadController() {} + public UploadedFile getFile() { - return file; + return this.file; } - public void setFile(UploadedFile file) { + public void setFile(final UploadedFile file) { this.file = file; } public void upload() { - FileManager.getInstance().uploadDependency(file); + FileManager.getInstance().uploadDependency(this.file); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java index 0a6e68e3..8ed87922 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java @@ -21,6 +21,7 @@ package kieker.webgui.beans.session; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; + import kieker.analysis.model.analysisMetaModel.MIProject; import org.primefaces.model.DefaultTreeNode; @@ -51,7 +52,7 @@ public class SelectedProjectBean { * @return The user's main project. */ public MIProject getMainProject() { - return mainProject; + return this.mainProject; } /** @@ -70,7 +71,7 @@ public class SelectedProjectBean { * @return The user's currently selected project. */ public MIProject getSelectedProject() { - return selectedProject; + return this.selectedProject; } public void setSelectedProject(final MIProject selectedProject) { @@ -78,20 +79,24 @@ public class SelectedProjectBean { } public TreeNode getSelectedNode() { - return selectedNode; + return this.selectedNode; } public void setSelectedNode(final TreeNode selectedNode) { this.selectedNode = selectedNode; if (selectedNode != null && selectedNode.getData() instanceof MIProject) { - setSelectedProject((MIProject) selectedNode.getData()); + this.setSelectedProject((MIProject) selectedNode.getData()); } else { - setSelectedProject(null); + this.setSelectedProject(null); } } public String getFontWeight(final MIProject project) { - return (project == this.mainProject) ? "bold" : "normal"; + if (project == this.mainProject) { + return "bold"; + } else { + return "normal"; + } } /** @@ -100,7 +105,7 @@ public class SelectedProjectBean { * @return A tree with the available plugins. */ public TreeNode getAvailablePluginsRoot() { - TreeNode root = new DefaultTreeNode("Root", null); + final TreeNode root = new DefaultTreeNode("Root", null); final TreeNode readerNode = new DefaultTreeNode("default", "Reader", root); final TreeNode analysisPluginsNode = new DefaultTreeNode("default", "AnalysisPlugins", root); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java index 56459e0b..b836ae0a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java @@ -1,20 +1,22 @@ -/************************************************************************* - * Copyright 2012 by + Christian-Albrechts-University of Kiel + Department of - * Computer Science + Software Engineering Group and others. +/*************************************************************************** + * Copyright 2012 by + * + Christian-Albrechts-University of Kiel + * + Department of Computer Science + * + Software Engineering Group + * and others. * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - ************************************************************************** - */ + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ package kieker.webgui.common; import java.io.File; @@ -23,11 +25,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import org.primefaces.model.UploadedFile; - import kieker.analysis.AnalysisController; import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIProject; @@ -35,6 +34,8 @@ import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; +import org.primefaces.model.UploadedFile; + /** * This is a singleton class for the access to the file system. It makes sure * that the necessary directories for the execution of the application exist. @@ -50,16 +51,16 @@ public final class FileManager { private static final Log LOG = LogFactory.getLog(FileManager.class); private static final String ROOT_DIR = "data"; - private static final String PROJECT_DIR = ROOT_DIR + File.separator + "projects"; - private static final String LIB_DIR = ROOT_DIR + File.separator + "libraries"; + private static final String PROJECT_DIR = FileManager.ROOT_DIR + File.separator + "projects"; + private static final String LIB_DIR = FileManager.ROOT_DIR + File.separator + "libraries"; private static final String EXTENSION = ".kax"; private static final String JAR_EXTENSION = ".jar"; private static final int BUF_SIZE = 1024; - private static final FileManager instance = new FileManager(); + private static final FileManager INSTANCE = new FileManager(); private final MAnalysisMetaModelFactory factory; private FileManager() { - checkAndCreateDirectories(); + this.checkAndCreateDirectories(); this.factory = new MAnalysisMetaModelFactory(); } @@ -67,8 +68,8 @@ public final class FileManager { /* * Make sure that the directories exist and create them if necessary. */ - final File dirProj = new File(PROJECT_DIR); - final File dirLib = new File(LIB_DIR); + final File dirProj = new File(FileManager.PROJECT_DIR); + final File dirLib = new File(FileManager.LIB_DIR); boolean couldCreated = true; if (!dirProj.exists()) { @@ -95,7 +96,7 @@ public final class FileManager { public synchronized boolean saveProject(final MIProject project) { final String projectName = project.getName(); - final File dirProject = new File(PROJECT_DIR + File.separator + projectName); + final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); /* * Make sure that the directory for the project exists. @@ -129,7 +130,7 @@ public final class FileManager { public synchronized boolean saveNewProject(final MIProject project) { final String projectName = project.getName(); - final File dirProject = new File(PROJECT_DIR + File.separator + projectName); + final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); /* * Make sure that the project does not already exist and create the @@ -141,7 +142,7 @@ public final class FileManager { /* * The directory should exist now. Store the project. */ - return saveProject(project); + return this.saveProject(project); } } @@ -152,14 +153,14 @@ public final class FileManager { * an empty list will be returned, never null. */ public synchronized List<MIProject> loadAllProjects() { - List<MIProject> resultList = new ArrayList<MIProject>(); + final List<MIProject> resultList = new ArrayList<MIProject>(); /* * Try to get all directories within the project directory. */ - final File[] directories = new File(PROJECT_DIR).listFiles(); + final File[] directories = new File(FileManager.PROJECT_DIR).listFiles(); if (directories != null) { - for (File directory : directories) { + for (final File directory : directories) { if (directory.isDirectory()) { /* * If there is a project file within the directory, we know @@ -171,11 +172,11 @@ public final class FileManager { /* * Try to load the project. */ - MIProject project = AnalysisController.loadFromFile(projectFile); + final MIProject project = AnalysisController.loadFromFile(projectFile); if (project != null) { resultList.add(project); } - } catch (Exception ex) { + } catch (final Exception ex) { FileManager.LOG.error("Could not load project '" + directory.getName() + "'."); } } @@ -197,7 +198,7 @@ public final class FileManager { * otherwise. */ public MIDependency uploadDependency(final UploadedFile file) { - final File depFile = new File(LIB_DIR, file.getFileName()); + final File depFile = new File(FileManager.LIB_DIR, file.getFileName()); InputStream in = null; OutputStream out = null; @@ -207,7 +208,7 @@ public final class FileManager { */ in = file.getInputstream(); out = new FileOutputStream(depFile); - final byte[] buf = new byte[BUF_SIZE]; + final byte[] buf = new byte[FileManager.BUF_SIZE]; int count; /* @@ -231,11 +232,11 @@ public final class FileManager { if (out != null) { out.close(); } - } catch (IOException ex) { + } catch (final IOException ex) { // Ignore } } - final MIDependency dependency = factory.createDependency(); + final MIDependency dependency = this.factory.createDependency(); dependency.setFilePath(depFile.getAbsolutePath()); return dependency; } @@ -246,7 +247,7 @@ public final class FileManager { * @return The singleton instance of this class. */ public static FileManager getInstance() { - return instance; + return FileManager.INSTANCE; } public List<MIDependency> loadAllDependencies() { @@ -254,12 +255,12 @@ public final class FileManager { /* * Try to get all files within the library directory. */ - final File[] files = new File(LIB_DIR).listFiles(); + final File[] files = new File(FileManager.LIB_DIR).listFiles(); if (files != null) { - for (File file : files) { + for (final File file : files) { if (file.isFile()) { - if (file.getName().endsWith(JAR_EXTENSION)) { - MIDependency dependency = factory.createDependency(); + if (file.getName().endsWith(FileManager.JAR_EXTENSION)) { + final MIDependency dependency = this.factory.createDependency(); dependency.setFilePath(file.getAbsolutePath()); resultList.add(dependency); } @@ -271,7 +272,7 @@ public final class FileManager { } public boolean deleteDependency(final MIDependency dependency) { - File file = new File(dependency.getFilePath()); + final File file = new File(dependency.getFilePath()); if (file.isFile()) { return file.delete(); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java index 4970badc..2bc674e8 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java @@ -17,7 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ - package kieker.webgui.common; import java.io.File; @@ -29,12 +28,18 @@ import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; + import kieker.analysis.plugin.port.Plugin; /** * @author Nils Christian Ehmke */ -public class PluginFinder { +public final class PluginFinder { + + /** + * Creates a new instance of this class. + */ + private PluginFinder() {} /** * This method delivers all classes which are available in the given jar and @@ -57,9 +62,9 @@ public class PluginFinder { */ final JarFile jarFile = new JarFile(new File(url.getPath())); final List<Class<?>> result = new ArrayList<Class<?>>(); - Enumeration<JarEntry> jarEntries = jarFile.entries(); + final Enumeration<JarEntry> jarEntries = jarFile.entries(); while (jarEntries.hasMoreElements()) { - JarEntry jarEntry = (JarEntry) jarEntries.nextElement(); + final JarEntry jarEntry = jarEntries.nextElement(); try { String name = jarEntry.toString(); name = name.replace('/', '.'); @@ -67,7 +72,7 @@ public class PluginFinder { /* * Try to find a class with the same name. */ - Class<?> c = classLoader.loadClass(name); + final Class<?> c = classLoader.loadClass(name); /* * If it is a class and has the annotation - put it into our * list. @@ -75,11 +80,11 @@ public class PluginFinder { if (c.isAnnotationPresent(Plugin.class)) { result.add(c); } - } catch (Throwable ex) { + } catch (final Throwable ex) { } } return result; - } catch (IOException ex) { + } catch (final IOException ex) { return null; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToIntConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToIntConverter.java index 1103a930..56754181 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToIntConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToIntConverter.java @@ -17,15 +17,16 @@ * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ - package kieker.webgui.converter; import java.io.File; import java.text.DecimalFormat; + import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; + import kieker.analysis.model.analysisMetaModel.MIDependency; /** @@ -38,22 +39,28 @@ import kieker.analysis.model.analysisMetaModel.MIDependency; public class MIDependencyToIntConverter implements Converter { public static final String NAME = "kieker.webgui.converter.MIDependencyToIntConverter"; + private static final double FACTOR = 1.0 / 1024 / 1024; + + /** + * Creates a new instance of this class. + */ + public MIDependencyToIntConverter() {} /** * Delivers always null */ @Override - public Object getAsObject(FacesContext fc, UIComponent uic, String string) { + public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { return null; } @Override - public String getAsString(FacesContext fc, UIComponent uic, Object o) { + public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) { if (o == null || !(o instanceof MIDependency)) { return null; } else { - long size = new File(((MIDependency) o).getFilePath()).length(); - return new DecimalFormat("#.##").format(size / 1024f / 1024).concat(" [MiByte]"); + final long size = new File(((MIDependency) o).getFilePath()).length(); + return new DecimalFormat("#.##").format(size * MIDependencyToIntConverter.FACTOR).concat(" [MiByte]"); } } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java index b503c342..f4d4cf12 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java @@ -1,28 +1,31 @@ -/** - * ************************************************************************* - * Copyright 2012 by + Christian-Albrechts-University of Kiel + Department of - * Computer Science + Software Engineering Group and others. +/*************************************************************************** + * Copyright 2012 by + * + Christian-Albrechts-University of Kiel + * + Department of Computer Science + * + Software Engineering Group + * and others. * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - * ************************************************************************* - */ + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ package kieker.webgui.converter; import java.io.File; + import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; + import kieker.analysis.model.analysisMetaModel.MIDependency; /** @@ -34,15 +37,24 @@ import kieker.analysis.model.analysisMetaModel.MIDependency; @FacesConverter(value = MIDependencyToStringConverter.NAME) public class MIDependencyToStringConverter implements Converter { + /** + * This is the name of the converter. + */ public static final String NAME = "kieker.webgui.converter.MIDependencyToStringConverter"; + /** + * Creates a new instance of this class. + */ + public MIDependencyToStringConverter() {} + /** * This method delivers always null and should not be used. * * @param fc - * The faces context. + * The FacesContext for the request being processed. * @param uic - * The component. + * The component with which this model object value is + * associated. * @param string * The string to be converted. * @return null @@ -57,9 +69,10 @@ public class MIDependencyToStringConverter implements Converter { * instance of the class <code>MIDependency</code>) to a human readable string. * * @param fc - * The faces context. + * The FacesContext for the request being processed. * @param uic - * The component. + * The component with which this model object value is + * associated. * @param o * The object to be converted. * @return A human readable represantation of the given object or null, of @@ -67,6 +80,13 @@ public class MIDependencyToStringConverter implements Converter { */ @Override public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) { - return (o == null || !(o instanceof MIDependency)) ? null : (new File(((MIDependency) o).getFilePath()).getName()); + /* + * Make sure that the given object is well-defined. + */ + if (o == null || !(o instanceof MIDependency)) { + return null; + } else { + return new File(((MIDependency) o).getFilePath()).getName(); + } } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIProjectToStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIProjectToStringConverter.java index 104b8ecd..254dbaad 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIProjectToStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIProjectToStringConverter.java @@ -17,35 +17,74 @@ * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ - package kieker.webgui.converter; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; + import kieker.analysis.model.analysisMetaModel.MIProject; /** - * This converter can be used to convert an instance of <i>MIProject</i> to a human readable string, but <b>not</b> vice versa. + * This converter can be used to convert an instance of <i>MIProject</i> to a + * human readable string, but <b>not</b> vice versa. * * @author Nils Christian Ehmke */ @FacesConverter(value = MIProjectToStringConverter.NAME) public class MIProjectToStringConverter implements Converter { + /** + * This is the name of this converter. + */ public static final String NAME = "kieker.webgui.converter.MIProjectToStringConverter"; /** - * Delivers always null + * Creates a new instance of this class. + */ + public MIProjectToStringConverter() {} + + /** + * This method delivers always null and should not be used. + * + * @param fc + * The FacesContext for the request being processed. + * @param uic + * The component with which this model object value is + * associated. + * @param string + * The string to be converted. + * @return null */ @Override - public Object getAsObject(FacesContext fc, UIComponent uic, String string) { + public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { return null; } + /** + * This method delivers the name of the given object, if the object is not + * null and the object is an instance of the class <code>MIProject</code>. + * + * @param fc + * The FacesContext for the request being processed. + * @param uic + * The component with which this model object value is + * associated. + * @param o + * The object to be converted. + * @return A human readable representation of the given object if possible, + * null otherwise. + */ @Override - public String getAsString(FacesContext fc, UIComponent uic, Object o) { - return (o == null || !(o instanceof MIProject)) ? null : ((MIProject) o).getName(); + public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) { + /* + * Make sure that the given object is well-defined. + */ + if (o == null || !(o instanceof MIProject)) { + return null; + } else { + return ((MIProject) o).getName(); + } } } -- GitLab