repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsFactory.java
// Path: src/main/java/info/gianlucacosta/easypmd/system/SystemPropertiesService.java // public interface SystemPropertiesService { // // String getJavaVersion(); // // Path getUserHomeDirectory(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/LanguageVersionParser.java // public interface LanguageVersionParser { // // LanguageVersion parse(String versionString); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // }
import java.util.Arrays; import java.util.List; import java.util.logging.Logger; import info.gianlucacosta.easypmd.system.SystemPropertiesService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.LanguageVersionParser; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.regex.OsSpecificPathCompositeRegex; import net.sourceforge.pmd.RulePriority; import org.openide.util.lookup.ServiceProvider; import java.util.ArrayList;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsFactory */ @ServiceProvider(service = OptionsFactory.class) public class DefaultOptionsFactory implements OptionsFactory { private static final Logger logger = Logger.getLogger(DefaultOptionsFactory.class.getName()); private static final String fallbackJavaLanguageVersion = "1.8"; private final StandardRuleSetsCatalog standardRulesetsCatalog; private final SystemPropertiesService systemPropertiesService;
// Path: src/main/java/info/gianlucacosta/easypmd/system/SystemPropertiesService.java // public interface SystemPropertiesService { // // String getJavaVersion(); // // Path getUserHomeDirectory(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/LanguageVersionParser.java // public interface LanguageVersionParser { // // LanguageVersion parse(String versionString); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsFactory.java import java.util.Arrays; import java.util.List; import java.util.logging.Logger; import info.gianlucacosta.easypmd.system.SystemPropertiesService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.LanguageVersionParser; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.regex.OsSpecificPathCompositeRegex; import net.sourceforge.pmd.RulePriority; import org.openide.util.lookup.ServiceProvider; import java.util.ArrayList; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsFactory */ @ServiceProvider(service = OptionsFactory.class) public class DefaultOptionsFactory implements OptionsFactory { private static final Logger logger = Logger.getLogger(DefaultOptionsFactory.class.getName()); private static final String fallbackJavaLanguageVersion = "1.8"; private final StandardRuleSetsCatalog standardRulesetsCatalog; private final SystemPropertiesService systemPropertiesService;
private final LanguageVersionParser languageVersionParser;
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsFactory.java
// Path: src/main/java/info/gianlucacosta/easypmd/system/SystemPropertiesService.java // public interface SystemPropertiesService { // // String getJavaVersion(); // // Path getUserHomeDirectory(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/LanguageVersionParser.java // public interface LanguageVersionParser { // // LanguageVersion parse(String versionString); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // }
import java.util.Arrays; import java.util.List; import java.util.logging.Logger; import info.gianlucacosta.easypmd.system.SystemPropertiesService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.LanguageVersionParser; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.regex.OsSpecificPathCompositeRegex; import net.sourceforge.pmd.RulePriority; import org.openide.util.lookup.ServiceProvider; import java.util.ArrayList;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsFactory */ @ServiceProvider(service = OptionsFactory.class) public class DefaultOptionsFactory implements OptionsFactory { private static final Logger logger = Logger.getLogger(DefaultOptionsFactory.class.getName()); private static final String fallbackJavaLanguageVersion = "1.8"; private final StandardRuleSetsCatalog standardRulesetsCatalog; private final SystemPropertiesService systemPropertiesService; private final LanguageVersionParser languageVersionParser; public DefaultOptionsFactory() {
// Path: src/main/java/info/gianlucacosta/easypmd/system/SystemPropertiesService.java // public interface SystemPropertiesService { // // String getJavaVersion(); // // Path getUserHomeDirectory(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/LanguageVersionParser.java // public interface LanguageVersionParser { // // LanguageVersion parse(String versionString); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsFactory.java import java.util.Arrays; import java.util.List; import java.util.logging.Logger; import info.gianlucacosta.easypmd.system.SystemPropertiesService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.LanguageVersionParser; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.regex.OsSpecificPathCompositeRegex; import net.sourceforge.pmd.RulePriority; import org.openide.util.lookup.ServiceProvider; import java.util.ArrayList; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsFactory */ @ServiceProvider(service = OptionsFactory.class) public class DefaultOptionsFactory implements OptionsFactory { private static final Logger logger = Logger.getLogger(DefaultOptionsFactory.class.getName()); private static final String fallbackJavaLanguageVersion = "1.8"; private final StandardRuleSetsCatalog standardRulesetsCatalog; private final SystemPropertiesService systemPropertiesService; private final LanguageVersionParser languageVersionParser; public DefaultOptionsFactory() {
standardRulesetsCatalog = Injector.lookup(StandardRuleSetsCatalog.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/CacheEntry.java
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // }
import java.util.Set; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages.cache; /** * Entry for the in-memory cache */ public class CacheEntry { private final long lastModificationMillis;
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/CacheEntry.java import java.util.Set; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages.cache; /** * Entry for the in-memory cache */ public class CacheEntry { private final long lastModificationMillis;
private final Set<ScanMessage> scanMessages;
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/RuleSetsPanel.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java // public class RuleSetWrapper { // // private final RuleSet ruleSet; // // public RuleSetWrapper(RuleSet ruleSet) { // this.ruleSet = ruleSet; // } // // public RuleSet getRuleSet() { // return ruleSet; // } // // @Override // public String toString() { // return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName()); // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // }
import java.util.Arrays; import java.util.Collection; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.filechooser.FileFilter; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.conversions.CollectionToArrayConverter; import info.gianlucacosta.helios.product.ProductInfoService; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import java.io.File;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel dedicated to editing rulesets */ public class RuleSetsPanel extends JPanel { private final AdvancedSelectionListModel<String> ruleSetsModel = new AdvancedSelectionListModel<>();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java // public class RuleSetWrapper { // // private final RuleSet ruleSet; // // public RuleSetWrapper(RuleSet ruleSet) { // this.ruleSet = ruleSet; // } // // public RuleSet getRuleSet() { // return ruleSet; // } // // @Override // public String toString() { // return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName()); // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/RuleSetsPanel.java import java.util.Arrays; import java.util.Collection; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.filechooser.FileFilter; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.conversions.CollectionToArrayConverter; import info.gianlucacosta.helios.product.ProductInfoService; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import java.io.File; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel dedicated to editing rulesets */ public class RuleSetsPanel extends JPanel { private final AdvancedSelectionListModel<String> ruleSetsModel = new AdvancedSelectionListModel<>();
private final DialogService dialogService;
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/RuleSetsPanel.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java // public class RuleSetWrapper { // // private final RuleSet ruleSet; // // public RuleSetWrapper(RuleSet ruleSet) { // this.ruleSet = ruleSet; // } // // public RuleSet getRuleSet() { // return ruleSet; // } // // @Override // public String toString() { // return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName()); // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // }
import java.util.Arrays; import java.util.Collection; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.filechooser.FileFilter; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.conversions.CollectionToArrayConverter; import info.gianlucacosta.helios.product.ProductInfoService; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import java.io.File;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel dedicated to editing rulesets */ public class RuleSetsPanel extends JPanel { private final AdvancedSelectionListModel<String> ruleSetsModel = new AdvancedSelectionListModel<>(); private final DialogService dialogService; private final ProductInfoService pluginInfoService;
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java // public class RuleSetWrapper { // // private final RuleSet ruleSet; // // public RuleSetWrapper(RuleSet ruleSet) { // this.ruleSet = ruleSet; // } // // public RuleSet getRuleSet() { // return ruleSet; // } // // @Override // public String toString() { // return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName()); // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/RuleSetsPanel.java import java.util.Arrays; import java.util.Collection; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.filechooser.FileFilter; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.conversions.CollectionToArrayConverter; import info.gianlucacosta.helios.product.ProductInfoService; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import java.io.File; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel dedicated to editing rulesets */ public class RuleSetsPanel extends JPanel { private final AdvancedSelectionListModel<String> ruleSetsModel = new AdvancedSelectionListModel<>(); private final DialogService dialogService; private final ProductInfoService pluginInfoService;
private final StandardRuleSetsCatalog standardRulesetsCatalog;
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/RuleSetsPanel.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java // public class RuleSetWrapper { // // private final RuleSet ruleSet; // // public RuleSetWrapper(RuleSet ruleSet) { // this.ruleSet = ruleSet; // } // // public RuleSet getRuleSet() { // return ruleSet; // } // // @Override // public String toString() { // return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName()); // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // }
import java.util.Arrays; import java.util.Collection; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.filechooser.FileFilter; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.conversions.CollectionToArrayConverter; import info.gianlucacosta.helios.product.ProductInfoService; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import java.io.File;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel dedicated to editing rulesets */ public class RuleSetsPanel extends JPanel { private final AdvancedSelectionListModel<String> ruleSetsModel = new AdvancedSelectionListModel<>(); private final DialogService dialogService; private final ProductInfoService pluginInfoService; private final StandardRuleSetsCatalog standardRulesetsCatalog; private final JFileChooser ruleSetsFileChooser = new JFileChooser(); public RuleSetsPanel() { initComponents();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java // public class RuleSetWrapper { // // private final RuleSet ruleSet; // // public RuleSetWrapper(RuleSet ruleSet) { // this.ruleSet = ruleSet; // } // // public RuleSet getRuleSet() { // return ruleSet; // } // // @Override // public String toString() { // return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName()); // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/RuleSetsPanel.java import java.util.Arrays; import java.util.Collection; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.filechooser.FileFilter; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import info.gianlucacosta.helios.conversions.CollectionToArrayConverter; import info.gianlucacosta.helios.product.ProductInfoService; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import java.io.File; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel dedicated to editing rulesets */ public class RuleSetsPanel extends JPanel { private final AdvancedSelectionListModel<String> ruleSetsModel = new AdvancedSelectionListModel<>(); private final DialogService dialogService; private final ProductInfoService pluginInfoService; private final StandardRuleSetsCatalog standardRulesetsCatalog; private final JFileChooser ruleSetsFileChooser = new JFileChooser(); public RuleSetsPanel() { initComponents();
dialogService = Injector.lookup(DialogService.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // }
import info.gianlucacosta.easypmd.ide.options.Options;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * The overall context of profiles and current active profile. */ public interface ProfileContext { ProfileMap getProfiles(); String getActiveProfileName();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java import info.gianlucacosta.easypmd.ide.options.Options; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * The overall context of profiles and current active profile. */ public interface ProfileContext { ProfileMap getProfiles(); String getActiveProfileName();
Options getActiveOptions();
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/strategies/NoOpPmdScannerStrategy.java
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScannerStrategy.java // public interface PmdScannerStrategy { // // Set<ScanMessage> scan(Path path); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // }
import info.gianlucacosta.easypmd.pmdscanner.PmdScannerStrategy; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import java.nio.file.Path; import java.util.Collections; import java.util.Set;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.strategies; /** * Scanning strategy that always returns an empty set */ public class NoOpPmdScannerStrategy implements PmdScannerStrategy { @Override
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScannerStrategy.java // public interface PmdScannerStrategy { // // Set<ScanMessage> scan(Path path); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/strategies/NoOpPmdScannerStrategy.java import info.gianlucacosta.easypmd.pmdscanner.PmdScannerStrategy; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import java.nio.file.Path; import java.util.Collections; import java.util.Set; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.strategies; /** * Scanning strategy that always returns an empty set */ public class NoOpPmdScannerStrategy implements PmdScannerStrategy { @Override
public Set<ScanMessage> scan(Path path) {
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/regexes/RegexesPanel.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // }
import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import javax.swing.*; import java.util.Collection; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.regexes; /** * Panel for managing regular expressions */ public class RegexesPanel extends JPanel { private final AdvancedSelectionListModel<String> regexesModel = new AdvancedSelectionListModel<>();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/regexes/RegexesPanel.java import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import javax.swing.*; import java.util.Collection; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.regexes; /** * Panel for managing regular expressions */ public class RegexesPanel extends JPanel { private final AdvancedSelectionListModel<String> regexesModel = new AdvancedSelectionListModel<>();
private final DialogService dialogService;
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/regexes/RegexesPanel.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // }
import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import javax.swing.*; import java.util.Collection; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.regexes; /** * Panel for managing regular expressions */ public class RegexesPanel extends JPanel { private final AdvancedSelectionListModel<String> regexesModel = new AdvancedSelectionListModel<>(); private final DialogService dialogService; private final RegexTemplateSelectionDialog regexTemplateSelectionDialog; /** * Creates new form RegexPanel */ public RegexesPanel() { initComponents();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/regexes/RegexesPanel.java import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import javax.swing.*; import java.util.Collection; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.regexes; /** * Panel for managing regular expressions */ public class RegexesPanel extends JPanel { private final AdvancedSelectionListModel<String> regexesModel = new AdvancedSelectionListModel<>(); private final DialogService dialogService; private final RegexTemplateSelectionDialog regexTemplateSelectionDialog; /** * Creates new form RegexPanel */ public RegexesPanel() { initComponents();
dialogService = Injector.lookup(DialogService.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/HsqlDbStorage.java
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // }
import java.sql.SQLException; import java.sql.Statement; import java.util.Optional; import java.util.Set; import java.util.logging.Logger; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import info.gianlucacosta.easypmd.util.Throwables; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet;
); try { dbConnection = DriverManager.getConnection(connectionString); dbConnection.setAutoCommit(true); try (Statement statement = dbConnection.createStatement()) { statement.execute(TABLE_CREATION_DDL); } selectStatement = dbConnection.prepareStatement(SELECT_QUERY); insertStatement = dbConnection.prepareStatement(INSERT_DDL); updateStatement = dbConnection.prepareStatement(UPDATE_DDL); clearStatement = dbConnection.prepareStatement(CLEAR_DDL); } catch (SQLException ex) { throw new RuntimeException(ex); } } @Override public Optional<CacheEntry> getEntry(String pathString) { try { selectStatement.setString(1, pathString); try (ResultSet resultSet = selectStatement.executeQuery()) { if (resultSet.next()) { long lastModificationMillis = resultSet.getLong(1);
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/HsqlDbStorage.java import java.sql.SQLException; import java.sql.Statement; import java.util.Optional; import java.util.Set; import java.util.logging.Logger; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import info.gianlucacosta.easypmd.util.Throwables; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; ); try { dbConnection = DriverManager.getConnection(connectionString); dbConnection.setAutoCommit(true); try (Statement statement = dbConnection.createStatement()) { statement.execute(TABLE_CREATION_DDL); } selectStatement = dbConnection.prepareStatement(SELECT_QUERY); insertStatement = dbConnection.prepareStatement(INSERT_DDL); updateStatement = dbConnection.prepareStatement(UPDATE_DDL); clearStatement = dbConnection.prepareStatement(CLEAR_DDL); } catch (SQLException ex) { throw new RuntimeException(ex); } } @Override public Optional<CacheEntry> getEntry(String pathString) { try { selectStatement.setString(1, pathString); try (ResultSet resultSet = selectStatement.executeQuery()) { if (resultSet.next()) { long lastModificationMillis = resultSet.getLong(1);
Set<ScanMessage> scanMessages = (Set<ScanMessage>) resultSet.getObject(2);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/HsqlDbStorage.java
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // }
import java.sql.SQLException; import java.sql.Statement; import java.util.Optional; import java.util.Set; import java.util.logging.Logger; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import info.gianlucacosta.easypmd.util.Throwables; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet;
updateStatement = dbConnection.prepareStatement(UPDATE_DDL); clearStatement = dbConnection.prepareStatement(CLEAR_DDL); } catch (SQLException ex) { throw new RuntimeException(ex); } } @Override public Optional<CacheEntry> getEntry(String pathString) { try { selectStatement.setString(1, pathString); try (ResultSet resultSet = selectStatement.executeQuery()) { if (resultSet.next()) { long lastModificationMillis = resultSet.getLong(1); Set<ScanMessage> scanMessages = (Set<ScanMessage>) resultSet.getObject(2); CacheEntry cacheEntry = new CacheEntry(lastModificationMillis, scanMessages); return Optional.of(cacheEntry); } else { return Optional.empty(); } } } catch (Exception ex) { logger.warning( () -> String.format( "Error while retrieving db-cached scan messages for path: %s.\nCause: %s", pathString,
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/HsqlDbStorage.java import java.sql.SQLException; import java.sql.Statement; import java.util.Optional; import java.util.Set; import java.util.logging.Logger; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import info.gianlucacosta.easypmd.util.Throwables; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; updateStatement = dbConnection.prepareStatement(UPDATE_DDL); clearStatement = dbConnection.prepareStatement(CLEAR_DDL); } catch (SQLException ex) { throw new RuntimeException(ex); } } @Override public Optional<CacheEntry> getEntry(String pathString) { try { selectStatement.setString(1, pathString); try (ResultSet resultSet = selectStatement.executeQuery()) { if (resultSet.next()) { long lastModificationMillis = resultSet.getLong(1); Set<ScanMessage> scanMessages = (Set<ScanMessage>) resultSet.getObject(2); CacheEntry cacheEntry = new CacheEntry(lastModificationMillis, scanMessages); return Optional.of(cacheEntry); } else { return Optional.empty(); } } } catch (Exception ex) { logger.warning( () -> String.format( "Error while retrieving db-cached scan messages for path: %s.\nCause: %s", pathString,
Throwables.toStringWithStackTrace(ex)
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/ScanViolation.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/annotations/BasicAnnotation.java // public class BasicAnnotation extends Annotation { // // private final String annotationType; // private final String message; // // public BasicAnnotation(String annotationType, String message) { // this.annotationType = annotationType; // this.message = message; // } // // @Override // public String getAnnotationType() { // return annotationType; // } // // @Override // public String getShortDescription() { // return message; // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // }
import info.gianlucacosta.easypmd.ide.annotations.BasicAnnotation; import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleViolation; import org.netbeans.spi.tasklist.Task; import org.openide.filesystems.FileObject; import org.openide.text.Annotation;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages; public class ScanViolation implements ScanMessage { private static final String ANNOTATION_TOKEN_SEPARATOR = "\n"; private static final String TASK_TOKEN_SEPARATOR = " "; private final int lineNumber; private final String description; private final String ruleName; private final String ruleSetName; private final RulePriority priority; public ScanViolation(RuleViolation ruleViolation) { lineNumber = ruleViolation.getBeginLine(); description = ruleViolation.getDescription(); ruleName = ruleViolation.getRule().getName(); ruleSetName = ruleViolation.getRule().getRuleSetName(); priority = ruleViolation.getRule().getPriority(); } @Override public boolean isShowableInGuardedSections() { return false; } @Override public int getLineNumber() { return lineNumber; } @Override
// Path: src/main/java/info/gianlucacosta/easypmd/ide/annotations/BasicAnnotation.java // public class BasicAnnotation extends Annotation { // // private final String annotationType; // private final String message; // // public BasicAnnotation(String annotationType, String message) { // this.annotationType = annotationType; // this.message = message; // } // // @Override // public String getAnnotationType() { // return annotationType; // } // // @Override // public String getShortDescription() { // return message; // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/ScanViolation.java import info.gianlucacosta.easypmd.ide.annotations.BasicAnnotation; import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleViolation; import org.netbeans.spi.tasklist.Task; import org.openide.filesystems.FileObject; import org.openide.text.Annotation; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages; public class ScanViolation implements ScanMessage { private static final String ANNOTATION_TOKEN_SEPARATOR = "\n"; private static final String TASK_TOKEN_SEPARATOR = " "; private final int lineNumber; private final String description; private final String ruleName; private final String ruleSetName; private final RulePriority priority; public ScanViolation(RuleViolation ruleViolation) { lineNumber = ruleViolation.getBeginLine(); description = ruleViolation.getDescription(); ruleName = ruleViolation.getRule().getName(); ruleSetName = ruleViolation.getRule().getRuleSetName(); priority = ruleViolation.getRule().getPriority(); } @Override public boolean isShowableInGuardedSections() { return false; } @Override public int getLineNumber() { return lineNumber; } @Override
public Task createTask(Options options, FileObject fileObject) {
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/ScanViolation.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/annotations/BasicAnnotation.java // public class BasicAnnotation extends Annotation { // // private final String annotationType; // private final String message; // // public BasicAnnotation(String annotationType, String message) { // this.annotationType = annotationType; // this.message = message; // } // // @Override // public String getAnnotationType() { // return annotationType; // } // // @Override // public String getShortDescription() { // return message; // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // }
import info.gianlucacosta.easypmd.ide.annotations.BasicAnnotation; import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleViolation; import org.netbeans.spi.tasklist.Task; import org.openide.filesystems.FileObject; import org.openide.text.Annotation;
case HIGH: return "info.gianlucacosta.easypmd.ide.tasklist.High"; case MEDIUM_HIGH: return "info.gianlucacosta.easypmd.ide.tasklist.MediumHigh"; case MEDIUM: return "info.gianlucacosta.easypmd.ide.tasklist.Medium"; case MEDIUM_LOW: return "info.gianlucacosta.easypmd.ide.tasklist.MediumLow"; case LOW: return "info.gianlucacosta.easypmd.ide.tasklist.Low"; default: throw new RuntimeException(String.format("Unexpected priority value: '%s'", priority)); } } private String formatTaskText(Options options) { return formatViolationComponents( TASK_TOKEN_SEPARATOR, options.isShowRulePriorityInTasks(), options.isShowDescriptionInTasks(), options.isShowRuleInTasks(), options.isShowRuleSetInTasks() ); } @Override public Annotation createAnnotation(Options options) { String annotationType = getAnnotationType(); String annotationMessage = formatAnnotationText();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/annotations/BasicAnnotation.java // public class BasicAnnotation extends Annotation { // // private final String annotationType; // private final String message; // // public BasicAnnotation(String annotationType, String message) { // this.annotationType = annotationType; // this.message = message; // } // // @Override // public String getAnnotationType() { // return annotationType; // } // // @Override // public String getShortDescription() { // return message; // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/ScanViolation.java import info.gianlucacosta.easypmd.ide.annotations.BasicAnnotation; import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleViolation; import org.netbeans.spi.tasklist.Task; import org.openide.filesystems.FileObject; import org.openide.text.Annotation; case HIGH: return "info.gianlucacosta.easypmd.ide.tasklist.High"; case MEDIUM_HIGH: return "info.gianlucacosta.easypmd.ide.tasklist.MediumHigh"; case MEDIUM: return "info.gianlucacosta.easypmd.ide.tasklist.Medium"; case MEDIUM_LOW: return "info.gianlucacosta.easypmd.ide.tasklist.MediumLow"; case LOW: return "info.gianlucacosta.easypmd.ide.tasklist.Low"; default: throw new RuntimeException(String.format("Unexpected priority value: '%s'", priority)); } } private String formatTaskText(Options options) { return formatViolationComponents( TASK_TOKEN_SEPARATOR, options.isShowRulePriorityInTasks(), options.isShowDescriptionInTasks(), options.isShowRuleInTasks(), options.isShowRuleSetInTasks() ); } @Override public Annotation createAnnotation(Options options) { String annotationType = getAnnotationType(); String annotationMessage = formatAnnotationText();
return new BasicAnnotation(
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextRepository.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // }
import info.gianlucacosta.easypmd.ide.PathService; import info.gianlucacosta.easypmd.util.Throwables; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.nio.file.Files; import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStreamWriter; import java.util.logging.Logger; import java.nio.file.Path;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextRepository. */ @ServiceProvider(service = ProfileContextRepository.class) public class DefaultProfileContextRepository implements ProfileContextRepository { private static final Logger logger = Logger.getLogger(DefaultProfileContextFactory.class.getName()); private static final String PROFILES_FILE_NAME = "Profiles.xml"; private final EasyPmdXStream xmlStream = new EasyPmdXStream(); private final Path profilesPath; private ProfileContext profileContext; public DefaultProfileContextRepository() {
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextRepository.java import info.gianlucacosta.easypmd.ide.PathService; import info.gianlucacosta.easypmd.util.Throwables; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.nio.file.Files; import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStreamWriter; import java.util.logging.Logger; import java.nio.file.Path; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextRepository. */ @ServiceProvider(service = ProfileContextRepository.class) public class DefaultProfileContextRepository implements ProfileContextRepository { private static final Logger logger = Logger.getLogger(DefaultProfileContextFactory.class.getName()); private static final String PROFILES_FILE_NAME = "Profiles.xml"; private final EasyPmdXStream xmlStream = new EasyPmdXStream(); private final Path profilesPath; private ProfileContext profileContext; public DefaultProfileContextRepository() {
PathService pathService = Injector.lookup(PathService.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextRepository.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // }
import info.gianlucacosta.easypmd.ide.PathService; import info.gianlucacosta.easypmd.util.Throwables; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.nio.file.Files; import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStreamWriter; import java.util.logging.Logger; import java.nio.file.Path;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextRepository. */ @ServiceProvider(service = ProfileContextRepository.class) public class DefaultProfileContextRepository implements ProfileContextRepository { private static final Logger logger = Logger.getLogger(DefaultProfileContextFactory.class.getName()); private static final String PROFILES_FILE_NAME = "Profiles.xml"; private final EasyPmdXStream xmlStream = new EasyPmdXStream(); private final Path profilesPath; private ProfileContext profileContext; public DefaultProfileContextRepository() {
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextRepository.java import info.gianlucacosta.easypmd.ide.PathService; import info.gianlucacosta.easypmd.util.Throwables; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.nio.file.Files; import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStreamWriter; import java.util.logging.Logger; import java.nio.file.Path; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextRepository. */ @ServiceProvider(service = ProfileContextRepository.class) public class DefaultProfileContextRepository implements ProfileContextRepository { private static final Logger logger = Logger.getLogger(DefaultProfileContextFactory.class.getName()); private static final String PROFILES_FILE_NAME = "Profiles.xml"; private final EasyPmdXStream xmlStream = new EasyPmdXStream(); private final Path profilesPath; private ProfileContext profileContext; public DefaultProfileContextRepository() {
PathService pathService = Injector.lookup(PathService.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextRepository.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // }
import info.gianlucacosta.easypmd.ide.PathService; import info.gianlucacosta.easypmd.util.Throwables; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.nio.file.Files; import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStreamWriter; import java.util.logging.Logger; import java.nio.file.Path;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextRepository. */ @ServiceProvider(service = ProfileContextRepository.class) public class DefaultProfileContextRepository implements ProfileContextRepository { private static final Logger logger = Logger.getLogger(DefaultProfileContextFactory.class.getName()); private static final String PROFILES_FILE_NAME = "Profiles.xml"; private final EasyPmdXStream xmlStream = new EasyPmdXStream(); private final Path profilesPath; private ProfileContext profileContext; public DefaultProfileContextRepository() { PathService pathService = Injector.lookup(PathService.class); profilesPath = pathService.getRootPath().resolve(PROFILES_FILE_NAME); try (ObjectInputStream profileContextInputStream = xmlStream.createObjectInputStream( new BufferedInputStream( Files.newInputStream(profilesPath) ) )) { profileContext = (ProfileContext) profileContextInputStream.readObject(); } catch (Exception ex) { logger.warning( () -> String.format( "Exception while loading the profiles: %s",
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/util/Throwables.java // public interface Throwables { // // /** // * Converts the stack trace of a Throwable to a string // * // * @param throwable // * @return the string representation of the stack trace // */ // static String getStackTraceString(Throwable throwable) { // final Writer result = new StringWriter(); // final PrintWriter printWriter = new PrintWriter(result); // // throwable.printStackTrace(printWriter); // // return result.toString(); // } // // /** // * Returns the throwable message, or the message of its cause, recursively, // * or a simple message if no message was found in the chain // * // * @param throwable The subject throwable // * @return a non-empty string // */ // static String getNonEmptyMessage(Throwable throwable) { // String message = throwable.getMessage(); // // if (message == null || message.isEmpty()) { // Throwable cause = throwable.getCause(); // // if (cause != null) { // return getNonEmptyMessage(cause); // } else { // return "(no message)"; // } // } else { // return message; // } // } // // /** // * Returns a string showing a Throwable (type and message) and the related // * stack trace // * // * @param throwable // * @return // */ // static String toStringWithStackTrace(Throwable throwable) { // return String.format( // "%s (%s)\n%s", // throwable.getClass().getName(), // throwable.getMessage(), // getStackTraceString(throwable) // ); // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextRepository.java import info.gianlucacosta.easypmd.ide.PathService; import info.gianlucacosta.easypmd.util.Throwables; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.nio.file.Files; import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStreamWriter; import java.util.logging.Logger; import java.nio.file.Path; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextRepository. */ @ServiceProvider(service = ProfileContextRepository.class) public class DefaultProfileContextRepository implements ProfileContextRepository { private static final Logger logger = Logger.getLogger(DefaultProfileContextFactory.class.getName()); private static final String PROFILES_FILE_NAME = "Profiles.xml"; private final EasyPmdXStream xmlStream = new EasyPmdXStream(); private final Path profilesPath; private ProfileContext profileContext; public DefaultProfileContextRepository() { PathService pathService = Injector.lookup(PathService.class); profilesPath = pathService.getRootPath().resolve(PROFILES_FILE_NAME); try (ObjectInputStream profileContextInputStream = xmlStream.createObjectInputStream( new BufferedInputStream( Files.newInputStream(profilesPath) ) )) { profileContext = (ProfileContext) profileContextInputStream.readObject(); } catch (Exception ex) { logger.warning( () -> String.format( "Exception while loading the profiles: %s",
Throwables.toStringWithStackTrace(ex)
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/DefaultPathService.java
// Path: src/main/java/info/gianlucacosta/easypmd/PropertyPluginInfoService.java // @ServiceProvider(service = ProductInfoService.class) // public class PropertyPluginInfoService extends PropertyProductInfoService { // // public PropertyPluginInfoService() throws IOException { // super(new XmlProperties("/info/gianlucacosta/easypmd/Plugin.properties.xml")); // } // // } // // Path: src/main/java/info/gianlucacosta/easypmd/system/SystemPropertiesService.java // public interface SystemPropertiesService { // // String getJavaVersion(); // // Path getUserHomeDirectory(); // }
import info.gianlucacosta.easypmd.system.SystemPropertiesService; import java.nio.file.Path; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.PropertyPluginInfoService;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide; @ServiceProvider(service = PathService.class) public class DefaultPathService implements PathService {
// Path: src/main/java/info/gianlucacosta/easypmd/PropertyPluginInfoService.java // @ServiceProvider(service = ProductInfoService.class) // public class PropertyPluginInfoService extends PropertyProductInfoService { // // public PropertyPluginInfoService() throws IOException { // super(new XmlProperties("/info/gianlucacosta/easypmd/Plugin.properties.xml")); // } // // } // // Path: src/main/java/info/gianlucacosta/easypmd/system/SystemPropertiesService.java // public interface SystemPropertiesService { // // String getJavaVersion(); // // Path getUserHomeDirectory(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/DefaultPathService.java import info.gianlucacosta.easypmd.system.SystemPropertiesService; import java.nio.file.Path; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.PropertyPluginInfoService; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide; @ServiceProvider(service = PathService.class) public class DefaultPathService implements PathService {
private final SystemPropertiesService systemPropertiesService;
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/DefaultPathService.java
// Path: src/main/java/info/gianlucacosta/easypmd/PropertyPluginInfoService.java // @ServiceProvider(service = ProductInfoService.class) // public class PropertyPluginInfoService extends PropertyProductInfoService { // // public PropertyPluginInfoService() throws IOException { // super(new XmlProperties("/info/gianlucacosta/easypmd/Plugin.properties.xml")); // } // // } // // Path: src/main/java/info/gianlucacosta/easypmd/system/SystemPropertiesService.java // public interface SystemPropertiesService { // // String getJavaVersion(); // // Path getUserHomeDirectory(); // }
import info.gianlucacosta.easypmd.system.SystemPropertiesService; import java.nio.file.Path; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.PropertyPluginInfoService;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide; @ServiceProvider(service = PathService.class) public class DefaultPathService implements PathService { private final SystemPropertiesService systemPropertiesService;
// Path: src/main/java/info/gianlucacosta/easypmd/PropertyPluginInfoService.java // @ServiceProvider(service = ProductInfoService.class) // public class PropertyPluginInfoService extends PropertyProductInfoService { // // public PropertyPluginInfoService() throws IOException { // super(new XmlProperties("/info/gianlucacosta/easypmd/Plugin.properties.xml")); // } // // } // // Path: src/main/java/info/gianlucacosta/easypmd/system/SystemPropertiesService.java // public interface SystemPropertiesService { // // String getJavaVersion(); // // Path getUserHomeDirectory(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/DefaultPathService.java import info.gianlucacosta.easypmd.system.SystemPropertiesService; import java.nio.file.Path; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.PropertyPluginInfoService; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide; @ServiceProvider(service = PathService.class) public class DefaultPathService implements PathService { private final SystemPropertiesService systemPropertiesService;
private final PropertyPluginInfoService pluginInfoService;
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/StandardRuleSetsInputPanel.java
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java // public class RuleSetWrapper { // // private final RuleSet ruleSet; // // public RuleSetWrapper(RuleSet ruleSet) { // this.ruleSet = ruleSet; // } // // public RuleSet getRuleSet() { // return ruleSet; // } // // @Override // public String toString() { // return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName()); // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // }
import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import net.sourceforge.pmd.RuleSet; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import java.awt.BorderLayout; import java.awt.Dimension; import java.util.Collection; import java.util.stream.Stream; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.JLabel;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel showing a list of available standard rule sets and allowing multiple * selection */ public final class StandardRuleSetsInputPanel extends JPanel { private final JList<RuleSetWrapper> inputList;
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/RuleSetWrapper.java // public class RuleSetWrapper { // // private final RuleSet ruleSet; // // public RuleSetWrapper(RuleSet ruleSet) { // this.ruleSet = ruleSet; // } // // public RuleSet getRuleSet() { // return ruleSet; // } // // @Override // public String toString() { // return String.format("%s (%s)", ruleSet.getName(), ruleSet.getFileName()); // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/pmdcatalogs/StandardRuleSetsCatalog.java // public interface StandardRuleSetsCatalog { // // boolean containsFileName(String ruleSetFileName); // // Collection<RuleSetWrapper> getRuleSetWrappers(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/StandardRuleSetsInputPanel.java import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import net.sourceforge.pmd.RuleSet; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.RuleSetWrapper; import info.gianlucacosta.easypmd.pmdscanner.pmdcatalogs.StandardRuleSetsCatalog; import java.awt.BorderLayout; import java.awt.Dimension; import java.util.Collection; import java.util.stream.Stream; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.JLabel; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel showing a list of available standard rule sets and allowing multiple * selection */ public final class StandardRuleSetsInputPanel extends JPanel { private final JList<RuleSetWrapper> inputList;
public StandardRuleSetsInputPanel(StandardRuleSetsCatalog standardRuleSetsCatalog) {
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContext.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // }
import java.io.Serializable; import info.gianlucacosta.easypmd.ide.options.Options;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContext. */ public class DefaultProfileContext implements ProfileContext, Serializable { private final ProfileMap profileMap; private final String activeProfileName; public DefaultProfileContext(ProfileMap profileMap, String activeProfileName) { this.profileMap = profileMap; this.activeProfileName = activeProfileName; } @Override public ProfileMap getProfiles() { return profileMap; } @Override public String getActiveProfileName() { return activeProfileName; } @Override
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContext.java import java.io.Serializable; import info.gianlucacosta.easypmd.ide.options.Options; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContext. */ public class DefaultProfileContext implements ProfileContext, Serializable { private final ProfileMap profileMap; private final String activeProfileName; public DefaultProfileContext(ProfileMap profileMap, String activeProfileName) { this.profileMap = profileMap; this.activeProfileName = activeProfileName; } @Override public ProfileMap getProfiles() { return profileMap; } @Override public String getActiveProfileName() { return activeProfileName; } @Override
public Options getActiveOptions() {
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/regexes/SingleStringParamRegexTemplate.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // }
import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.ide.DialogService;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.regexes; /** * Regex template requiring just a single string parameter */ public abstract class SingleStringParamRegexTemplate extends RegexTemplate { private final DialogService dialogService; public SingleStringParamRegexTemplate() {
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/regexes/SingleStringParamRegexTemplate.java import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.easypmd.ide.DialogService; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.regexes; /** * Regex template requiring just a single string parameter */ public abstract class SingleStringParamRegexTemplate extends RegexTemplate { private final DialogService dialogService; public SingleStringParamRegexTemplate() {
dialogService = Injector.lookup(DialogService.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/DefaultScanMessagesCache.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // }
import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.PathService;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages.cache; /** * Default cache service */ @ServiceProvider(service = ScanMessagesCache.class) public class DefaultScanMessagesCache extends DualLayerCache { public DefaultScanMessagesCache() { super(new HsqlDbStorage(
// Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/DefaultScanMessagesCache.java import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.PathService; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages.cache; /** * Default cache service */ @ServiceProvider(service = ScanMessagesCache.class) public class DefaultScanMessagesCache extends DualLayerCache { public DefaultScanMessagesCache() { super(new HsqlDbStorage(
Injector.lookup(PathService.class).getCachePath()
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/DefaultScanMessagesCache.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // }
import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.PathService;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages.cache; /** * Default cache service */ @ServiceProvider(service = ScanMessagesCache.class) public class DefaultScanMessagesCache extends DualLayerCache { public DefaultScanMessagesCache() { super(new HsqlDbStorage(
// Path: src/main/java/info/gianlucacosta/easypmd/ide/PathService.java // public interface PathService { // // /** // * The root of the plugin directory within the user's home directory // */ // Path getRootPath(); // // /** // * The directory containing cache information // */ // Path getCachePath(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/DefaultScanMessagesCache.java import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.PathService; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages.cache; /** * Default cache service */ @ServiceProvider(service = ScanMessagesCache.class) public class DefaultScanMessagesCache extends DualLayerCache { public DefaultScanMessagesCache() { super(new HsqlDbStorage(
Injector.lookup(PathService.class).getCachePath()
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsService.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java // public interface ProfileContext { // // ProfileMap getProfiles(); // // String getActiveProfileName(); // // Options getActiveOptions(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java // public interface ProfileContextRepository { // // ProfileContext getProfileContext(); // // void saveProfileContext(ProfileContext profileContext); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScanner.java // public class PmdScanner { // // private static final Logger logger = Logger.getLogger(PmdScanner.class.getName()); // // private final PmdScannerStrategy strategy; // // public PmdScanner(Options options) { // if (options.getRuleSets().isEmpty()) { // logger.info(() -> "Setting a NOP scanning strategy"); // strategy = new NoOpPmdScannerStrategy(); // return; // } // // if (options.isUseScanMessagesCache()) { // logger.info(() -> "Setting a cached scanning strategy"); // strategy = new CacheBasedLinkedPmdScanningStrategy(options); // } else { // logger.info(() -> "Setting a non-cached scanning strategy"); // strategy = new LinkedPmdScanningStrategy(options); // } // } // // public Set<ScanMessage> scan(Path path) { // try { // return strategy.scan(path); // } catch (Exception ex) { // ScanError scanError = new ScanError(ex); // // return Collections.singleton( // scanError // ); // } // } // }
import java.util.function.BiConsumer; import java.util.logging.Logger; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository; import info.gianlucacosta.easypmd.pmdscanner.PmdScanner; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsService */ @ServiceProvider(service = OptionsService.class) public class DefaultOptionsService implements OptionsService { private static final Logger logger = Logger.getLogger(DefaultOptionsService.class.getName()); private final List<BiConsumer<Options, OptionsChanges>> optionsSetListeners = new LinkedList<>(); private final Lock readLock; private final Lock writeLock; private Options options; public DefaultOptionsService() { ReadWriteLock optionsLock = new ReentrantReadWriteLock(); readLock = optionsLock.readLock(); writeLock = optionsLock.writeLock();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java // public interface ProfileContext { // // ProfileMap getProfiles(); // // String getActiveProfileName(); // // Options getActiveOptions(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java // public interface ProfileContextRepository { // // ProfileContext getProfileContext(); // // void saveProfileContext(ProfileContext profileContext); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScanner.java // public class PmdScanner { // // private static final Logger logger = Logger.getLogger(PmdScanner.class.getName()); // // private final PmdScannerStrategy strategy; // // public PmdScanner(Options options) { // if (options.getRuleSets().isEmpty()) { // logger.info(() -> "Setting a NOP scanning strategy"); // strategy = new NoOpPmdScannerStrategy(); // return; // } // // if (options.isUseScanMessagesCache()) { // logger.info(() -> "Setting a cached scanning strategy"); // strategy = new CacheBasedLinkedPmdScanningStrategy(options); // } else { // logger.info(() -> "Setting a non-cached scanning strategy"); // strategy = new LinkedPmdScanningStrategy(options); // } // } // // public Set<ScanMessage> scan(Path path) { // try { // return strategy.scan(path); // } catch (Exception ex) { // ScanError scanError = new ScanError(ex); // // return Collections.singleton( // scanError // ); // } // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsService.java import java.util.function.BiConsumer; import java.util.logging.Logger; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository; import info.gianlucacosta.easypmd.pmdscanner.PmdScanner; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsService */ @ServiceProvider(service = OptionsService.class) public class DefaultOptionsService implements OptionsService { private static final Logger logger = Logger.getLogger(DefaultOptionsService.class.getName()); private final List<BiConsumer<Options, OptionsChanges>> optionsSetListeners = new LinkedList<>(); private final Lock readLock; private final Lock writeLock; private Options options; public DefaultOptionsService() { ReadWriteLock optionsLock = new ReentrantReadWriteLock(); readLock = optionsLock.readLock(); writeLock = optionsLock.writeLock();
ProfileContextRepository profileContextRepository = Injector.lookup(ProfileContextRepository.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsService.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java // public interface ProfileContext { // // ProfileMap getProfiles(); // // String getActiveProfileName(); // // Options getActiveOptions(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java // public interface ProfileContextRepository { // // ProfileContext getProfileContext(); // // void saveProfileContext(ProfileContext profileContext); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScanner.java // public class PmdScanner { // // private static final Logger logger = Logger.getLogger(PmdScanner.class.getName()); // // private final PmdScannerStrategy strategy; // // public PmdScanner(Options options) { // if (options.getRuleSets().isEmpty()) { // logger.info(() -> "Setting a NOP scanning strategy"); // strategy = new NoOpPmdScannerStrategy(); // return; // } // // if (options.isUseScanMessagesCache()) { // logger.info(() -> "Setting a cached scanning strategy"); // strategy = new CacheBasedLinkedPmdScanningStrategy(options); // } else { // logger.info(() -> "Setting a non-cached scanning strategy"); // strategy = new LinkedPmdScanningStrategy(options); // } // } // // public Set<ScanMessage> scan(Path path) { // try { // return strategy.scan(path); // } catch (Exception ex) { // ScanError scanError = new ScanError(ex); // // return Collections.singleton( // scanError // ); // } // } // }
import java.util.function.BiConsumer; import java.util.logging.Logger; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository; import info.gianlucacosta.easypmd.pmdscanner.PmdScanner; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsService */ @ServiceProvider(service = OptionsService.class) public class DefaultOptionsService implements OptionsService { private static final Logger logger = Logger.getLogger(DefaultOptionsService.class.getName()); private final List<BiConsumer<Options, OptionsChanges>> optionsSetListeners = new LinkedList<>(); private final Lock readLock; private final Lock writeLock; private Options options; public DefaultOptionsService() { ReadWriteLock optionsLock = new ReentrantReadWriteLock(); readLock = optionsLock.readLock(); writeLock = optionsLock.writeLock();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java // public interface ProfileContext { // // ProfileMap getProfiles(); // // String getActiveProfileName(); // // Options getActiveOptions(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java // public interface ProfileContextRepository { // // ProfileContext getProfileContext(); // // void saveProfileContext(ProfileContext profileContext); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScanner.java // public class PmdScanner { // // private static final Logger logger = Logger.getLogger(PmdScanner.class.getName()); // // private final PmdScannerStrategy strategy; // // public PmdScanner(Options options) { // if (options.getRuleSets().isEmpty()) { // logger.info(() -> "Setting a NOP scanning strategy"); // strategy = new NoOpPmdScannerStrategy(); // return; // } // // if (options.isUseScanMessagesCache()) { // logger.info(() -> "Setting a cached scanning strategy"); // strategy = new CacheBasedLinkedPmdScanningStrategy(options); // } else { // logger.info(() -> "Setting a non-cached scanning strategy"); // strategy = new LinkedPmdScanningStrategy(options); // } // } // // public Set<ScanMessage> scan(Path path) { // try { // return strategy.scan(path); // } catch (Exception ex) { // ScanError scanError = new ScanError(ex); // // return Collections.singleton( // scanError // ); // } // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsService.java import java.util.function.BiConsumer; import java.util.logging.Logger; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository; import info.gianlucacosta.easypmd.pmdscanner.PmdScanner; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsService */ @ServiceProvider(service = OptionsService.class) public class DefaultOptionsService implements OptionsService { private static final Logger logger = Logger.getLogger(DefaultOptionsService.class.getName()); private final List<BiConsumer<Options, OptionsChanges>> optionsSetListeners = new LinkedList<>(); private final Lock readLock; private final Lock writeLock; private Options options; public DefaultOptionsService() { ReadWriteLock optionsLock = new ReentrantReadWriteLock(); readLock = optionsLock.readLock(); writeLock = optionsLock.writeLock();
ProfileContextRepository profileContextRepository = Injector.lookup(ProfileContextRepository.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsService.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java // public interface ProfileContext { // // ProfileMap getProfiles(); // // String getActiveProfileName(); // // Options getActiveOptions(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java // public interface ProfileContextRepository { // // ProfileContext getProfileContext(); // // void saveProfileContext(ProfileContext profileContext); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScanner.java // public class PmdScanner { // // private static final Logger logger = Logger.getLogger(PmdScanner.class.getName()); // // private final PmdScannerStrategy strategy; // // public PmdScanner(Options options) { // if (options.getRuleSets().isEmpty()) { // logger.info(() -> "Setting a NOP scanning strategy"); // strategy = new NoOpPmdScannerStrategy(); // return; // } // // if (options.isUseScanMessagesCache()) { // logger.info(() -> "Setting a cached scanning strategy"); // strategy = new CacheBasedLinkedPmdScanningStrategy(options); // } else { // logger.info(() -> "Setting a non-cached scanning strategy"); // strategy = new LinkedPmdScanningStrategy(options); // } // } // // public Set<ScanMessage> scan(Path path) { // try { // return strategy.scan(path); // } catch (Exception ex) { // ScanError scanError = new ScanError(ex); // // return Collections.singleton( // scanError // ); // } // } // }
import java.util.function.BiConsumer; import java.util.logging.Logger; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository; import info.gianlucacosta.easypmd.pmdscanner.PmdScanner; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsService */ @ServiceProvider(service = OptionsService.class) public class DefaultOptionsService implements OptionsService { private static final Logger logger = Logger.getLogger(DefaultOptionsService.class.getName()); private final List<BiConsumer<Options, OptionsChanges>> optionsSetListeners = new LinkedList<>(); private final Lock readLock; private final Lock writeLock; private Options options; public DefaultOptionsService() { ReadWriteLock optionsLock = new ReentrantReadWriteLock(); readLock = optionsLock.readLock(); writeLock = optionsLock.writeLock(); ProfileContextRepository profileContextRepository = Injector.lookup(ProfileContextRepository.class);
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java // public interface ProfileContext { // // ProfileMap getProfiles(); // // String getActiveProfileName(); // // Options getActiveOptions(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java // public interface ProfileContextRepository { // // ProfileContext getProfileContext(); // // void saveProfileContext(ProfileContext profileContext); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScanner.java // public class PmdScanner { // // private static final Logger logger = Logger.getLogger(PmdScanner.class.getName()); // // private final PmdScannerStrategy strategy; // // public PmdScanner(Options options) { // if (options.getRuleSets().isEmpty()) { // logger.info(() -> "Setting a NOP scanning strategy"); // strategy = new NoOpPmdScannerStrategy(); // return; // } // // if (options.isUseScanMessagesCache()) { // logger.info(() -> "Setting a cached scanning strategy"); // strategy = new CacheBasedLinkedPmdScanningStrategy(options); // } else { // logger.info(() -> "Setting a non-cached scanning strategy"); // strategy = new LinkedPmdScanningStrategy(options); // } // } // // public Set<ScanMessage> scan(Path path) { // try { // return strategy.scan(path); // } catch (Exception ex) { // ScanError scanError = new ScanError(ex); // // return Collections.singleton( // scanError // ); // } // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsService.java import java.util.function.BiConsumer; import java.util.logging.Logger; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository; import info.gianlucacosta.easypmd.pmdscanner.PmdScanner; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Default implementation of OptionsService */ @ServiceProvider(service = OptionsService.class) public class DefaultOptionsService implements OptionsService { private static final Logger logger = Logger.getLogger(DefaultOptionsService.class.getName()); private final List<BiConsumer<Options, OptionsChanges>> optionsSetListeners = new LinkedList<>(); private final Lock readLock; private final Lock writeLock; private Options options; public DefaultOptionsService() { ReadWriteLock optionsLock = new ReentrantReadWriteLock(); readLock = optionsLock.readLock(); writeLock = optionsLock.writeLock(); ProfileContextRepository profileContextRepository = Injector.lookup(ProfileContextRepository.class);
ProfileContext profileContext = profileContextRepository.getProfileContext();
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsService.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java // public interface ProfileContext { // // ProfileMap getProfiles(); // // String getActiveProfileName(); // // Options getActiveOptions(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java // public interface ProfileContextRepository { // // ProfileContext getProfileContext(); // // void saveProfileContext(ProfileContext profileContext); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScanner.java // public class PmdScanner { // // private static final Logger logger = Logger.getLogger(PmdScanner.class.getName()); // // private final PmdScannerStrategy strategy; // // public PmdScanner(Options options) { // if (options.getRuleSets().isEmpty()) { // logger.info(() -> "Setting a NOP scanning strategy"); // strategy = new NoOpPmdScannerStrategy(); // return; // } // // if (options.isUseScanMessagesCache()) { // logger.info(() -> "Setting a cached scanning strategy"); // strategy = new CacheBasedLinkedPmdScanningStrategy(options); // } else { // logger.info(() -> "Setting a non-cached scanning strategy"); // strategy = new LinkedPmdScanningStrategy(options); // } // } // // public Set<ScanMessage> scan(Path path) { // try { // return strategy.scan(path); // } catch (Exception ex) { // ScanError scanError = new ScanError(ex); // // return Collections.singleton( // scanError // ); // } // } // }
import java.util.function.BiConsumer; import java.util.logging.Logger; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository; import info.gianlucacosta.easypmd.pmdscanner.PmdScanner; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
return options; } finally { readLock.unlock(); } } @Override public void setOptions(Options options) { writeLock.lock(); try { Options oldOptions = this.options; this.options = options; logger.info(() -> "Options set!"); OptionsChanges optionsChanges = Options.computeChanges(oldOptions, options); optionsSetListeners .stream() .forEach(listener -> listener.accept(options, optionsChanges)); } finally { writeLock.unlock(); } } @Override public void validateOptions(Options options) throws InvalidOptionsException { readLock.lock(); try {
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContext.java // public interface ProfileContext { // // ProfileMap getProfiles(); // // String getActiveProfileName(); // // Options getActiveOptions(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/ProfileContextRepository.java // public interface ProfileContextRepository { // // ProfileContext getProfileContext(); // // void saveProfileContext(ProfileContext profileContext); // } // // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/PmdScanner.java // public class PmdScanner { // // private static final Logger logger = Logger.getLogger(PmdScanner.class.getName()); // // private final PmdScannerStrategy strategy; // // public PmdScanner(Options options) { // if (options.getRuleSets().isEmpty()) { // logger.info(() -> "Setting a NOP scanning strategy"); // strategy = new NoOpPmdScannerStrategy(); // return; // } // // if (options.isUseScanMessagesCache()) { // logger.info(() -> "Setting a cached scanning strategy"); // strategy = new CacheBasedLinkedPmdScanningStrategy(options); // } else { // logger.info(() -> "Setting a non-cached scanning strategy"); // strategy = new LinkedPmdScanningStrategy(options); // } // } // // public Set<ScanMessage> scan(Path path) { // try { // return strategy.scan(path); // } catch (Exception ex) { // ScanError scanError = new ScanError(ex); // // return Collections.singleton( // scanError // ); // } // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/DefaultOptionsService.java import java.util.function.BiConsumer; import java.util.logging.Logger; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContext; import info.gianlucacosta.easypmd.ide.options.profiles.ProfileContextRepository; import info.gianlucacosta.easypmd.pmdscanner.PmdScanner; import info.gianlucacosta.easypmd.ide.Injector; import org.openide.util.lookup.ServiceProvider; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; return options; } finally { readLock.unlock(); } } @Override public void setOptions(Options options) { writeLock.lock(); try { Options oldOptions = this.options; this.options = options; logger.info(() -> "Options set!"); OptionsChanges optionsChanges = Options.computeChanges(oldOptions, options); optionsSetListeners .stream() .forEach(listener -> listener.accept(options, optionsChanges)); } finally { writeLock.unlock(); } } @Override public void validateOptions(Options options) throws InvalidOptionsException { readLock.lock(); try {
new PmdScanner(options);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextFactory.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/OptionsFactory.java // public interface OptionsFactory { // // Options createDefaultOptions(); // }
import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.ide.options.OptionsFactory; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.Injector;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextFactory. */ @ServiceProvider(service = ProfileContextFactory.class) public class DefaultProfileContextFactory implements ProfileContextFactory { private static final String defaultProfileName = "Default profile";
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/OptionsFactory.java // public interface OptionsFactory { // // Options createDefaultOptions(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextFactory.java import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.ide.options.OptionsFactory; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.Injector; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextFactory. */ @ServiceProvider(service = ProfileContextFactory.class) public class DefaultProfileContextFactory implements ProfileContextFactory { private static final String defaultProfileName = "Default profile";
private final OptionsFactory optionsFactory;
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextFactory.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/OptionsFactory.java // public interface OptionsFactory { // // Options createDefaultOptions(); // }
import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.ide.options.OptionsFactory; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.Injector;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextFactory. */ @ServiceProvider(service = ProfileContextFactory.class) public class DefaultProfileContextFactory implements ProfileContextFactory { private static final String defaultProfileName = "Default profile"; private final OptionsFactory optionsFactory; public DefaultProfileContextFactory() {
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/OptionsFactory.java // public interface OptionsFactory { // // Options createDefaultOptions(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextFactory.java import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.ide.options.OptionsFactory; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.Injector; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextFactory. */ @ServiceProvider(service = ProfileContextFactory.class) public class DefaultProfileContextFactory implements ProfileContextFactory { private static final String defaultProfileName = "Default profile"; private final OptionsFactory optionsFactory; public DefaultProfileContextFactory() {
this.optionsFactory = Injector.lookup(OptionsFactory.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextFactory.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/OptionsFactory.java // public interface OptionsFactory { // // Options createDefaultOptions(); // }
import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.ide.options.OptionsFactory; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.Injector;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextFactory. */ @ServiceProvider(service = ProfileContextFactory.class) public class DefaultProfileContextFactory implements ProfileContextFactory { private static final String defaultProfileName = "Default profile"; private final OptionsFactory optionsFactory; public DefaultProfileContextFactory() { this.optionsFactory = Injector.lookup(OptionsFactory.class); } @Override public ProfileContext createDefaultProfileContext() {
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/OptionsFactory.java // public interface OptionsFactory { // // Options createDefaultOptions(); // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/profiles/DefaultProfileContextFactory.java import info.gianlucacosta.easypmd.ide.options.Options; import info.gianlucacosta.easypmd.ide.options.OptionsFactory; import org.openide.util.lookup.ServiceProvider; import info.gianlucacosta.easypmd.ide.Injector; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.profiles; /** * Default implementation of ProfileContextFactory. */ @ServiceProvider(service = ProfileContextFactory.class) public class DefaultProfileContextFactory implements ProfileContextFactory { private static final String defaultProfileName = "Default profile"; private final OptionsFactory optionsFactory; public DefaultProfileContextFactory() { this.optionsFactory = Injector.lookup(OptionsFactory.class); } @Override public ProfileContext createDefaultProfileContext() {
Options defaultOptions = optionsFactory.createDefaultOptions();
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/AdditionalClasspathPanel.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // }
import java.net.URL; import java.util.Collection; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.swing.dialogs.JarFileChooser; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import org.openide.util.Utilities; import javax.swing.*; import java.io.File; import java.net.MalformedURLException;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel for managing the "Additional classpath" option */ public class AdditionalClasspathPanel extends JPanel { private static final JarFileChooser pathChooser = new JarFileChooser("Select path..."); private final AdvancedSelectionListModel<URL> additionalClasspathModel = new AdvancedSelectionListModel<>();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/AdditionalClasspathPanel.java import java.net.URL; import java.util.Collection; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.swing.dialogs.JarFileChooser; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import org.openide.util.Utilities; import javax.swing.*; import java.io.File; import java.net.MalformedURLException; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel for managing the "Additional classpath" option */ public class AdditionalClasspathPanel extends JPanel { private static final JarFileChooser pathChooser = new JarFileChooser("Select path..."); private final AdvancedSelectionListModel<URL> additionalClasspathModel = new AdvancedSelectionListModel<>();
private final DialogService dialogService;
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/AdditionalClasspathPanel.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // }
import java.net.URL; import java.util.Collection; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.swing.dialogs.JarFileChooser; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import org.openide.util.Utilities; import javax.swing.*; import java.io.File; import java.net.MalformedURLException;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel for managing the "Additional classpath" option */ public class AdditionalClasspathPanel extends JPanel { private static final JarFileChooser pathChooser = new JarFileChooser("Select path..."); private final AdvancedSelectionListModel<URL> additionalClasspathModel = new AdvancedSelectionListModel<>(); private final DialogService dialogService; public AdditionalClasspathPanel() { initComponents();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/DialogService.java // public interface DialogService { // // void showInfo(String message); // // void showWarning(String message); // // void showError(String message); // // String askForString(String message); // // String askForString(String message, String defaultValue); // // CommonQuestionOutcome askYesNoQuestion(String message); // } // // Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/AdditionalClasspathPanel.java import java.net.URL; import java.util.Collection; import info.gianlucacosta.easypmd.ide.DialogService; import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.swing.dialogs.JarFileChooser; import info.gianlucacosta.helios.swing.jlist.AdvancedSelectionListModel; import org.openide.util.Utilities; import javax.swing.*; import java.io.File; import java.net.MalformedURLException; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options; /** * Panel for managing the "Additional classpath" option */ public class AdditionalClasspathPanel extends JPanel { private static final JarFileChooser pathChooser = new JarFileChooser("Select path..."); private final AdvancedSelectionListModel<URL> additionalClasspathModel = new AdvancedSelectionListModel<>(); private final DialogService dialogService; public AdditionalClasspathPanel() { initComponents();
dialogService = Injector.lookup(DialogService.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/ide/options/regexes/DefaultRegexTemplateSelectionDialog.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // }
import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.product.ProductInfoService; import org.openide.util.lookup.ServiceProvider; import javax.swing.*; import java.util.Collection;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.regexes; /** * Default implementation of RegexTemplateSelectionDialog */ @ServiceProvider(service = RegexTemplateSelectionDialog.class) public class DefaultRegexTemplateSelectionDialog implements RegexTemplateSelectionDialog { private static final RegexTemplate[] regexTemplates; static {
// Path: src/main/java/info/gianlucacosta/easypmd/ide/Injector.java // public class Injector { // // @ServiceProvider(service = TestService.class) // public static class TestService { // } // // private static final Lookup lookup = Lookup.getDefault(); // // private static Lookup getLookup() { // return lookup; // } // // public static <T> T lookup(Class<T> serviceClass) { // T result = getLookup().lookup(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // public static <T> Collection<? extends T> lookupAll(Class<T> serviceClass) { // Collection<? extends T> result = getLookup().lookupAll(serviceClass); // // validateLookupResult(serviceClass, result); // // return result; // } // // private static void validateLookupResult(Class<?> serviceClass, Object lookupResult) { // if (lookupResult == null) { // if (shouldThrowLookupExceptions(serviceClass)) { // throw new IllegalArgumentException(String.format("Service '%s' not registered!", serviceClass.getSimpleName())); // } // } // } // // //This code prevents exceptions in the visual form editors within NetBeans // private static boolean shouldThrowLookupExceptions(Class<?> serviceClass) { // if (serviceClass != TestService.class) { // TestService testService = lookup.lookup(TestService.class); // if (testService == null) { // return false; // } // } // // return true; // } // // private Injector() { // } // } // Path: src/main/java/info/gianlucacosta/easypmd/ide/options/regexes/DefaultRegexTemplateSelectionDialog.java import info.gianlucacosta.easypmd.ide.Injector; import info.gianlucacosta.helios.product.ProductInfoService; import org.openide.util.lookup.ServiceProvider; import javax.swing.*; import java.util.Collection; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.ide.options.regexes; /** * Default implementation of RegexTemplateSelectionDialog */ @ServiceProvider(service = RegexTemplateSelectionDialog.class) public class DefaultRegexTemplateSelectionDialog implements RegexTemplateSelectionDialog { private static final RegexTemplate[] regexTemplates; static {
Collection<? extends RegexTemplate> foundRegexTemplates = Injector.lookupAll(RegexTemplate.class);
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/DualLayerCache.java
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // }
import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import java.util.Collections; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages.cache; /** * Dual-layered (in-memory and in-storage) cache */ public class DualLayerCache implements ScanMessagesCache { private static final Logger logger = Logger.getLogger(DualLayerCache.class.getName()); private final Map<String, CacheEntry> inMemoryEntries = new ConcurrentHashMap<>(); private final CacheStorage storage; public DualLayerCache(CacheStorage storage) { this.storage = storage; } @Override
// Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java // public interface ScanMessage extends Serializable { // // boolean isShowableInGuardedSections(); // // int getLineNumber(); // // Task createTask(Options options, FileObject fileObject); // // Annotation createAnnotation(Options options); // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/messages/cache/DualLayerCache.java import info.gianlucacosta.easypmd.pmdscanner.ScanMessage; import java.util.Collections; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner.messages.cache; /** * Dual-layered (in-memory and in-storage) cache */ public class DualLayerCache implements ScanMessagesCache { private static final Logger logger = Logger.getLogger(DualLayerCache.class.getName()); private final Map<String, CacheEntry> inMemoryEntries = new ConcurrentHashMap<>(); private final CacheStorage storage; public DualLayerCache(CacheStorage storage) { this.storage = storage; } @Override
public Optional<Set<ScanMessage>> getScanMessagesFor(String pathString, long pathLastModificationMillis) {
giancosta86/EasyPmd
src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // }
import info.gianlucacosta.easypmd.ide.options.Options; import java.io.Serializable; import org.netbeans.spi.tasklist.Task; import org.openide.filesystems.FileObject; import org.openide.text.Annotation;
/* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner; /** * One of the messages emitted as a result of a PMD scan */ public interface ScanMessage extends Serializable { boolean isShowableInGuardedSections(); int getLineNumber();
// Path: src/main/java/info/gianlucacosta/easypmd/ide/options/Options.java // public interface Options { // // static OptionsChanges computeChanges(Options oldOptions, Options newOptions) { // if (oldOptions == null) { // return OptionsChanges.ENGINE; // } // // boolean noEngineChanges // = Objects.equals(oldOptions.getTargetJavaVersion(), newOptions.getTargetJavaVersion()) // && Objects.equals(oldOptions.getSourceFileEncoding(), newOptions.getSourceFileEncoding()) // && Objects.equals(oldOptions.getSuppressMarker(), newOptions.getSuppressMarker()) // && CollectionItems.equals(oldOptions.getAdditionalClassPathUrls(), newOptions.getAdditionalClassPathUrls()) // && CollectionItems.equals(oldOptions.getRuleSets(), newOptions.getRuleSets()) // && (oldOptions.isShowAllMessagesInGuardedSections() == newOptions.isShowAllMessagesInGuardedSections()) // && Objects.equals(oldOptions.getPathFilteringOptions(), newOptions.getPathFilteringOptions()) // && (oldOptions.getMinimumPriority() == newOptions.getMinimumPriority()) // && Objects.equals(oldOptions.getAuxiliaryClassPath(), newOptions.getAuxiliaryClassPath()) // && (oldOptions.isUseScanMessagesCache() == newOptions.isUseScanMessagesCache()); // // if (noEngineChanges) { // boolean noChanges // = (oldOptions.isShowRulePriorityInTasks() == newOptions.isShowRulePriorityInTasks()) // && (oldOptions.isShowDescriptionInTasks() == newOptions.isShowDescriptionInTasks()) // && (oldOptions.isShowRuleInTasks() == newOptions.isShowRuleInTasks()) // && (oldOptions.isShowRuleSetInTasks() == newOptions.isShowRuleSetInTasks()) // && (oldOptions.isShowAnnotationsInEditor() == newOptions.isShowAnnotationsInEditor()); // // if (noChanges) { // return OptionsChanges.NONE; // } else { // return OptionsChanges.VIEW_ONLY; // } // } else { // return OptionsChanges.ENGINE; // } // } // // String getTargetJavaVersion(); // // String getSourceFileEncoding(); // // String getSuppressMarker(); // // Collection<URL> getAdditionalClassPathUrls(); // // Collection<String> getRuleSets(); // // boolean isUseScanMessagesCache(); // // boolean isShowRulePriorityInTasks(); // // boolean isShowDescriptionInTasks(); // // boolean isShowRuleInTasks(); // // boolean isShowRuleSetInTasks(); // // boolean isShowAnnotationsInEditor(); // // boolean isShowAllMessagesInGuardedSections(); // // PathFilteringOptions getPathFilteringOptions(); // // RulePriority getMinimumPriority(); // // String getAuxiliaryClassPath(); // // Options clone(); // } // Path: src/main/java/info/gianlucacosta/easypmd/pmdscanner/ScanMessage.java import info.gianlucacosta.easypmd.ide.options.Options; import java.io.Serializable; import org.netbeans.spi.tasklist.Task; import org.openide.filesystems.FileObject; import org.openide.text.Annotation; /* * ==========================================================================%%# * EasyPmd * ===========================================================================%% * Copyright (C) 2009 - 2017 Gianluca Costa * ===========================================================================%% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * ==========================================================================%## */ package info.gianlucacosta.easypmd.pmdscanner; /** * One of the messages emitted as a result of a PMD scan */ public interface ScanMessage extends Serializable { boolean isShowableInGuardedSections(); int getLineNumber();
Task createTask(Options options, FileObject fileObject);
Piasy/Graduate
src/GpsEvaluate/Android-client/Gps-Demo/app/src/main/java/com/example/piasy/startup/location/PaintBoardFragment.java
// Path: src/GpsEvaluate/Android-client/Gps-Demo/app/src/main/java/com/example/piasy/startup/Controller.java // public interface Controller { // void start(); // void stop(); // }
import com.example.piasy.startup.Controller; import com.example.piasy.startup.R; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.location.Location; import android.os.Bundle; import android.os.Environment; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintWriter; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnClick;
package com.example.piasy.startup.location; /** * Created by piasy on 15/3/5. */ public class PaintBoardFragment extends Fragment { private final static String START = "Start"; private final static String STOP = "Stop"; @InjectView(R.id.bt_start) Button mBtStart; @InjectView(R.id.paintBoard) PaintBoard mPaintBoard; private boolean started = false;
// Path: src/GpsEvaluate/Android-client/Gps-Demo/app/src/main/java/com/example/piasy/startup/Controller.java // public interface Controller { // void start(); // void stop(); // } // Path: src/GpsEvaluate/Android-client/Gps-Demo/app/src/main/java/com/example/piasy/startup/location/PaintBoardFragment.java import com.example.piasy.startup.Controller; import com.example.piasy.startup.R; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.location.Location; import android.os.Bundle; import android.os.Environment; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintWriter; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnClick; package com.example.piasy.startup.location; /** * Created by piasy on 15/3/5. */ public class PaintBoardFragment extends Fragment { private final static String START = "Start"; private final static String STOP = "Stop"; @InjectView(R.id.bt_start) Button mBtStart; @InjectView(R.id.paintBoard) PaintBoard mPaintBoard; private boolean started = false;
private Controller mController;
Piasy/Graduate
src/GpsEvaluate/Android-client/Gps-Demo/app/src/main/java/com/example/piasy/startup/sensors/LogBoardFragment.java
// Path: src/GpsEvaluate/Android-client/Gps-Demo/app/src/main/java/com/example/piasy/startup/Controller.java // public interface Controller { // void start(); // void stop(); // }
import com.example.piasy.startup.Controller; import com.example.piasy.startup.R; import android.app.Activity; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.text.TextUtils; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnClick;
package com.example.piasy.startup.sensors; /** * Created by piasy on 15/3/5. */ public class LogBoardFragment extends Fragment implements Logger { private final static String START = "Start"; private final static String STOP = "Stop"; @InjectView(R.id.bt_start) Button mBtStart; @InjectView(R.id.tv_board) TextView mTvBoard; private boolean started = false;
// Path: src/GpsEvaluate/Android-client/Gps-Demo/app/src/main/java/com/example/piasy/startup/Controller.java // public interface Controller { // void start(); // void stop(); // } // Path: src/GpsEvaluate/Android-client/Gps-Demo/app/src/main/java/com/example/piasy/startup/sensors/LogBoardFragment.java import com.example.piasy.startup.Controller; import com.example.piasy.startup.R; import android.app.Activity; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.text.TextUtils; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; import butterknife.OnClick; package com.example.piasy.startup.sensors; /** * Created by piasy on 15/3/5. */ public class LogBoardFragment extends Fragment implements Logger { private final static String START = "Start"; private final static String STOP = "Stop"; @InjectView(R.id.bt_start) Button mBtStart; @InjectView(R.id.tv_board) TextView mTvBoard; private boolean started = false;
private Controller mController;
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/easing/types/Cubic.java
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // }
import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType;
package mnm.mods.itemdash.easing.types; public class Cubic implements EasingType { @Override
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // Path: src/main/java/mnm/mods/itemdash/easing/types/Cubic.java import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType; package mnm.mods.itemdash.easing.types; public class Cubic implements EasingType { @Override
public Easing in() {
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/setting/StringSetting.java
// Path: src/main/java/mnm/mods/itemdash/gui/dash/DashSettings.java // public class DashSettings extends Dash { // // private final LiteModItemDash litemod = LiteModItemDash.getInstance(); // private List<Supplier<Boolean>> focused = Lists.newArrayList(); // // private List<Setting<?>> settings = Lists.newArrayList(); // // public DashSettings(ItemDash itemdash) { // super(itemdash); // this.settings.add(new BoolSetting("Legacy IDs", litemod::setNumIds, litemod.isNumIds())); // this.settings.add(new BoolSetting("Survival Pick block", litemod::setSurvivalPick, litemod.isSurvivalPick())); // this.settings.add(new StringSetting(this, "Give Command", litemod::setGiveCommand, litemod.getGiveCommand()) // .preset("Vanilla", "/give {0} {1} {2} {3}") // .preset("Essentials", "/i {1}:{3} {2}")); // this.settings.add(new OptionSetting<>("Sorting", litemod::setSort, litemod.getSort()) // .option(ItemSorter.DEFAULT, "Default") // .option(ItemSorter.BY_ID, "By ID") // .option(ItemSorter.BY_NAME, "By Name")); // } // // @Override // public void preRender(int mousex, int mousey) { // // int xPos = itemdash.xPos; // int yPos = itemdash.yPos; // // int lastHeight = 0; // int pos = yPos; // for (Setting<?> it : settings) { // it.setPos(xPos + 4, pos += lastHeight + 6); // lastHeight = it.height; // } // // this.settings.forEach(it -> it.draw(mousex, mousey)); // } // // @Override // public void mouseClicked(int x, int y, int button) { // this.settings.forEach(it -> it.mouseClick(x, y, button)); // } // // @Override // public void keyTyped(char key, int code) { // this.settings.forEach(it -> it.keyPush(key, code)); // } // // @Override // public void onClose() { // LiteLoader.getInstance().writeConfig(litemod); // this.itemdash.dirty = true; // } // // @Override // public boolean isFocused() { // return this.focused.stream().anyMatch(Supplier::get); // } // // public void addFocus(Supplier<Boolean> focus) { // this.focused.add(focus); // } // // }
import java.util.function.Consumer; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.mumfrey.liteloader.client.gui.GuiCheckbox; import mnm.mods.itemdash.gui.dash.DashSettings; import net.minecraft.client.gui.GuiTextField;
package mnm.mods.itemdash.setting; public class StringSetting extends Setting<String> { private static final int W = 120; private static final int H = 15; private GuiTextField textBox; private BiMap<String, GuiCheckbox> presets = HashBiMap.create();
// Path: src/main/java/mnm/mods/itemdash/gui/dash/DashSettings.java // public class DashSettings extends Dash { // // private final LiteModItemDash litemod = LiteModItemDash.getInstance(); // private List<Supplier<Boolean>> focused = Lists.newArrayList(); // // private List<Setting<?>> settings = Lists.newArrayList(); // // public DashSettings(ItemDash itemdash) { // super(itemdash); // this.settings.add(new BoolSetting("Legacy IDs", litemod::setNumIds, litemod.isNumIds())); // this.settings.add(new BoolSetting("Survival Pick block", litemod::setSurvivalPick, litemod.isSurvivalPick())); // this.settings.add(new StringSetting(this, "Give Command", litemod::setGiveCommand, litemod.getGiveCommand()) // .preset("Vanilla", "/give {0} {1} {2} {3}") // .preset("Essentials", "/i {1}:{3} {2}")); // this.settings.add(new OptionSetting<>("Sorting", litemod::setSort, litemod.getSort()) // .option(ItemSorter.DEFAULT, "Default") // .option(ItemSorter.BY_ID, "By ID") // .option(ItemSorter.BY_NAME, "By Name")); // } // // @Override // public void preRender(int mousex, int mousey) { // // int xPos = itemdash.xPos; // int yPos = itemdash.yPos; // // int lastHeight = 0; // int pos = yPos; // for (Setting<?> it : settings) { // it.setPos(xPos + 4, pos += lastHeight + 6); // lastHeight = it.height; // } // // this.settings.forEach(it -> it.draw(mousex, mousey)); // } // // @Override // public void mouseClicked(int x, int y, int button) { // this.settings.forEach(it -> it.mouseClick(x, y, button)); // } // // @Override // public void keyTyped(char key, int code) { // this.settings.forEach(it -> it.keyPush(key, code)); // } // // @Override // public void onClose() { // LiteLoader.getInstance().writeConfig(litemod); // this.itemdash.dirty = true; // } // // @Override // public boolean isFocused() { // return this.focused.stream().anyMatch(Supplier::get); // } // // public void addFocus(Supplier<Boolean> focus) { // this.focused.add(focus); // } // // } // Path: src/main/java/mnm/mods/itemdash/setting/StringSetting.java import java.util.function.Consumer; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.mumfrey.liteloader.client.gui.GuiCheckbox; import mnm.mods.itemdash.gui.dash.DashSettings; import net.minecraft.client.gui.GuiTextField; package mnm.mods.itemdash.setting; public class StringSetting extends Setting<String> { private static final int W = 120; private static final int H = 15; private GuiTextField textBox; private BiMap<String, GuiCheckbox> presets = HashBiMap.create();
public StringSetting(DashSettings settings, String name, Consumer<String> apply, String current) {
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/easing/types/Circular.java
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // }
import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType;
package mnm.mods.itemdash.easing.types; public class Circular implements EasingType { @Override
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // Path: src/main/java/mnm/mods/itemdash/easing/types/Circular.java import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType; package mnm.mods.itemdash.easing.types; public class Circular implements EasingType { @Override
public Easing in() {
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/easing/types/Quintic.java
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // }
import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType;
package mnm.mods.itemdash.easing.types; public class Quintic implements EasingType { @Override
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // Path: src/main/java/mnm/mods/itemdash/easing/types/Quintic.java import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType; package mnm.mods.itemdash.easing.types; public class Quintic implements EasingType { @Override
public Easing in() {
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/easing/types/Quadratic.java
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // }
import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType;
package mnm.mods.itemdash.easing.types; public class Quadratic implements EasingType { @Override
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // Path: src/main/java/mnm/mods/itemdash/easing/types/Quadratic.java import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType; package mnm.mods.itemdash.easing.types; public class Quadratic implements EasingType { @Override
public Easing in() {
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/gui/Rainblower.java
// Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/Easings.java // public interface Easings { // // EasingType linear(); // // EasingType quadratic(); // // EasingType cubic(); // // EasingType quartic(); // // EasingType quintic(); // // EasingType sinusoidal(); // // EasingType circular(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingsFactory.java // public class EasingsFactory implements Easings { // // public static Easings getInstance() { // return new EasingsFactory(); // } // // private EasingsFactory() {} // // @Override // public EasingType linear() { // return new Linear(); // } // // @Override // public EasingType quadratic() { // return new Quadratic(); // } // // @Override // public EasingType cubic() { // return new Cubic(); // } // // @Override // public EasingType quartic() { // return new Quartic(); // } // // @Override // public EasingType quintic() { // return new Quintic(); // } // // @Override // public EasingType sinusoidal() { // return new Sinusoidal(); // } // // @Override // public EasingType circular() { // return new Circular(); // } // }
import mnm.mods.itemdash.easing.EasingType; import mnm.mods.itemdash.easing.Easings; import mnm.mods.itemdash.easing.EasingsFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation;
package mnm.mods.itemdash.gui; public class Rainblower extends Gui implements Runnable { static final Object YES_THIS_IS_AN_EASTER_EGG = null; private static final ResourceLocation DASHIE = new ResourceLocation("itemdash", "textures/gui/rainbow.png"); private Minecraft mc = Minecraft.getMinecraft(); private boolean activated; private int timer; @Override public void run() { this.activated = true; this.timer = mc.ingameGUI.getUpdateCounter(); } public void draw() { if (activated) { final int TIME = 60; int currTime = mc.ingameGUI.getUpdateCounter() - timer; if (currTime < TIME) {
// Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/Easings.java // public interface Easings { // // EasingType linear(); // // EasingType quadratic(); // // EasingType cubic(); // // EasingType quartic(); // // EasingType quintic(); // // EasingType sinusoidal(); // // EasingType circular(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingsFactory.java // public class EasingsFactory implements Easings { // // public static Easings getInstance() { // return new EasingsFactory(); // } // // private EasingsFactory() {} // // @Override // public EasingType linear() { // return new Linear(); // } // // @Override // public EasingType quadratic() { // return new Quadratic(); // } // // @Override // public EasingType cubic() { // return new Cubic(); // } // // @Override // public EasingType quartic() { // return new Quartic(); // } // // @Override // public EasingType quintic() { // return new Quintic(); // } // // @Override // public EasingType sinusoidal() { // return new Sinusoidal(); // } // // @Override // public EasingType circular() { // return new Circular(); // } // } // Path: src/main/java/mnm/mods/itemdash/gui/Rainblower.java import mnm.mods.itemdash.easing.EasingType; import mnm.mods.itemdash.easing.Easings; import mnm.mods.itemdash.easing.EasingsFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; package mnm.mods.itemdash.gui; public class Rainblower extends Gui implements Runnable { static final Object YES_THIS_IS_AN_EASTER_EGG = null; private static final ResourceLocation DASHIE = new ResourceLocation("itemdash", "textures/gui/rainbow.png"); private Minecraft mc = Minecraft.getMinecraft(); private boolean activated; private int timer; @Override public void run() { this.activated = true; this.timer = mc.ingameGUI.getUpdateCounter(); } public void draw() { if (activated) { final int TIME = 60; int currTime = mc.ingameGUI.getUpdateCounter() - timer; if (currTime < TIME) {
Easings factory = EasingsFactory.getInstance();
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/gui/Rainblower.java
// Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/Easings.java // public interface Easings { // // EasingType linear(); // // EasingType quadratic(); // // EasingType cubic(); // // EasingType quartic(); // // EasingType quintic(); // // EasingType sinusoidal(); // // EasingType circular(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingsFactory.java // public class EasingsFactory implements Easings { // // public static Easings getInstance() { // return new EasingsFactory(); // } // // private EasingsFactory() {} // // @Override // public EasingType linear() { // return new Linear(); // } // // @Override // public EasingType quadratic() { // return new Quadratic(); // } // // @Override // public EasingType cubic() { // return new Cubic(); // } // // @Override // public EasingType quartic() { // return new Quartic(); // } // // @Override // public EasingType quintic() { // return new Quintic(); // } // // @Override // public EasingType sinusoidal() { // return new Sinusoidal(); // } // // @Override // public EasingType circular() { // return new Circular(); // } // }
import mnm.mods.itemdash.easing.EasingType; import mnm.mods.itemdash.easing.Easings; import mnm.mods.itemdash.easing.EasingsFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation;
package mnm.mods.itemdash.gui; public class Rainblower extends Gui implements Runnable { static final Object YES_THIS_IS_AN_EASTER_EGG = null; private static final ResourceLocation DASHIE = new ResourceLocation("itemdash", "textures/gui/rainbow.png"); private Minecraft mc = Minecraft.getMinecraft(); private boolean activated; private int timer; @Override public void run() { this.activated = true; this.timer = mc.ingameGUI.getUpdateCounter(); } public void draw() { if (activated) { final int TIME = 60; int currTime = mc.ingameGUI.getUpdateCounter() - timer; if (currTime < TIME) {
// Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/Easings.java // public interface Easings { // // EasingType linear(); // // EasingType quadratic(); // // EasingType cubic(); // // EasingType quartic(); // // EasingType quintic(); // // EasingType sinusoidal(); // // EasingType circular(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingsFactory.java // public class EasingsFactory implements Easings { // // public static Easings getInstance() { // return new EasingsFactory(); // } // // private EasingsFactory() {} // // @Override // public EasingType linear() { // return new Linear(); // } // // @Override // public EasingType quadratic() { // return new Quadratic(); // } // // @Override // public EasingType cubic() { // return new Cubic(); // } // // @Override // public EasingType quartic() { // return new Quartic(); // } // // @Override // public EasingType quintic() { // return new Quintic(); // } // // @Override // public EasingType sinusoidal() { // return new Sinusoidal(); // } // // @Override // public EasingType circular() { // return new Circular(); // } // } // Path: src/main/java/mnm/mods/itemdash/gui/Rainblower.java import mnm.mods.itemdash.easing.EasingType; import mnm.mods.itemdash.easing.Easings; import mnm.mods.itemdash.easing.EasingsFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; package mnm.mods.itemdash.gui; public class Rainblower extends Gui implements Runnable { static final Object YES_THIS_IS_AN_EASTER_EGG = null; private static final ResourceLocation DASHIE = new ResourceLocation("itemdash", "textures/gui/rainbow.png"); private Minecraft mc = Minecraft.getMinecraft(); private boolean activated; private int timer; @Override public void run() { this.activated = true; this.timer = mc.ingameGUI.getUpdateCounter(); } public void draw() { if (activated) { final int TIME = 60; int currTime = mc.ingameGUI.getUpdateCounter() - timer; if (currTime < TIME) {
Easings factory = EasingsFactory.getInstance();
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/gui/Rainblower.java
// Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/Easings.java // public interface Easings { // // EasingType linear(); // // EasingType quadratic(); // // EasingType cubic(); // // EasingType quartic(); // // EasingType quintic(); // // EasingType sinusoidal(); // // EasingType circular(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingsFactory.java // public class EasingsFactory implements Easings { // // public static Easings getInstance() { // return new EasingsFactory(); // } // // private EasingsFactory() {} // // @Override // public EasingType linear() { // return new Linear(); // } // // @Override // public EasingType quadratic() { // return new Quadratic(); // } // // @Override // public EasingType cubic() { // return new Cubic(); // } // // @Override // public EasingType quartic() { // return new Quartic(); // } // // @Override // public EasingType quintic() { // return new Quintic(); // } // // @Override // public EasingType sinusoidal() { // return new Sinusoidal(); // } // // @Override // public EasingType circular() { // return new Circular(); // } // }
import mnm.mods.itemdash.easing.EasingType; import mnm.mods.itemdash.easing.Easings; import mnm.mods.itemdash.easing.EasingsFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation;
package mnm.mods.itemdash.gui; public class Rainblower extends Gui implements Runnable { static final Object YES_THIS_IS_AN_EASTER_EGG = null; private static final ResourceLocation DASHIE = new ResourceLocation("itemdash", "textures/gui/rainbow.png"); private Minecraft mc = Minecraft.getMinecraft(); private boolean activated; private int timer; @Override public void run() { this.activated = true; this.timer = mc.ingameGUI.getUpdateCounter(); } public void draw() { if (activated) { final int TIME = 60; int currTime = mc.ingameGUI.getUpdateCounter() - timer; if (currTime < TIME) { Easings factory = EasingsFactory.getInstance();
// Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/Easings.java // public interface Easings { // // EasingType linear(); // // EasingType quadratic(); // // EasingType cubic(); // // EasingType quartic(); // // EasingType quintic(); // // EasingType sinusoidal(); // // EasingType circular(); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingsFactory.java // public class EasingsFactory implements Easings { // // public static Easings getInstance() { // return new EasingsFactory(); // } // // private EasingsFactory() {} // // @Override // public EasingType linear() { // return new Linear(); // } // // @Override // public EasingType quadratic() { // return new Quadratic(); // } // // @Override // public EasingType cubic() { // return new Cubic(); // } // // @Override // public EasingType quartic() { // return new Quartic(); // } // // @Override // public EasingType quintic() { // return new Quintic(); // } // // @Override // public EasingType sinusoidal() { // return new Sinusoidal(); // } // // @Override // public EasingType circular() { // return new Circular(); // } // } // Path: src/main/java/mnm/mods/itemdash/gui/Rainblower.java import mnm.mods.itemdash.easing.EasingType; import mnm.mods.itemdash.easing.Easings; import mnm.mods.itemdash.easing.EasingsFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; package mnm.mods.itemdash.gui; public class Rainblower extends Gui implements Runnable { static final Object YES_THIS_IS_AN_EASTER_EGG = null; private static final ResourceLocation DASHIE = new ResourceLocation("itemdash", "textures/gui/rainbow.png"); private Minecraft mc = Minecraft.getMinecraft(); private boolean activated; private int timer; @Override public void run() { this.activated = true; this.timer = mc.ingameGUI.getUpdateCounter(); } public void draw() { if (activated) { final int TIME = 60; int currTime = mc.ingameGUI.getUpdateCounter() - timer; if (currTime < TIME) { Easings factory = EasingsFactory.getInstance();
EasingType linear = factory.sinusoidal();
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/easing/types/Exponential.java
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // }
import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType;
package mnm.mods.itemdash.easing.types; public class Exponential implements EasingType { @Override
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // Path: src/main/java/mnm/mods/itemdash/easing/types/Exponential.java import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType; package mnm.mods.itemdash.easing.types; public class Exponential implements EasingType { @Override
public Easing in() {
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/easing/types/Sinusoidal.java
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // }
import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType;
package mnm.mods.itemdash.easing.types; public class Sinusoidal implements EasingType { @Override
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // Path: src/main/java/mnm/mods/itemdash/easing/types/Sinusoidal.java import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType; package mnm.mods.itemdash.easing.types; public class Sinusoidal implements EasingType { @Override
public Easing in() {
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/easing/types/Linear.java
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // }
import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType;
package mnm.mods.itemdash.easing.types; public class Linear implements EasingType { @Override
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // Path: src/main/java/mnm/mods/itemdash/easing/types/Linear.java import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType; package mnm.mods.itemdash.easing.types; public class Linear implements EasingType { @Override
public Easing in() {
MineLittlePony/ItemDash
src/main/java/mnm/mods/itemdash/easing/types/Quartic.java
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // }
import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType;
package mnm.mods.itemdash.easing.types; public class Quartic implements EasingType { @Override
// Path: src/main/java/mnm/mods/itemdash/easing/Easing.java // @FunctionalInterface // public interface Easing { // // /** // * Eases to a position based on the time. // * // * @param time The current time relative to the animation start // * @param base The original position before move // * @param change The amount to be moved // * @param duration The total time the animation should take // * @return The position for the animation // */ // double ease(double time, double base, double change, double duration); // } // // Path: src/main/java/mnm/mods/itemdash/easing/EasingType.java // public interface EasingType { // // Easing in(); // // Easing out(); // // Easing inOut(); // } // Path: src/main/java/mnm/mods/itemdash/easing/types/Quartic.java import mnm.mods.itemdash.easing.Easing; import mnm.mods.itemdash.easing.EasingType; package mnm.mods.itemdash.easing.types; public class Quartic implements EasingType { @Override
public Easing in() {
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/payment/support/PaymentInstrumentRoot.java
// Path: common/src/main/java/cz/gopay/api/v3/model/common/CheckoutGroup.java // @XmlType // @XmlEnum(String.class) // public enum CheckoutGroup { // // @XmlEnumValue("card-payment") // CARD_PAYMENT("card-payment", EnumSet.of(PaymentInstrument.PAYMENT_CARD)), // // @XmlEnumValue("bank-transfer") // BANK_TRANSFER("bank-transfer", EnumSet.of(PaymentInstrument.BANK_ACCOUNT)), // // @XmlEnumValue("wallet") // WALLET("wallet", EnumSet.of( // PaymentInstrument.GOPAY, // PaymentInstrument.BITCOIN, // PaymentInstrument.PAYPAL)), // // @XmlEnumValue("others") // OTHERS("others", EnumSet.of( // PaymentInstrument.PRSMS, // PaymentInstrument.MPAYMENT, // PaymentInstrument.PAYSAFECARD, // PaymentInstrument.MASTERPASS)) // ; // // private final String name; // private final Set<PaymentInstrument> paymentInstruments; // // private CheckoutGroup(String name, Set<PaymentInstrument> paymentInstruments) { // this.name = name; // this.paymentInstruments = paymentInstruments; // } // // public String getName() { // return name; // } // // public Set<PaymentInstrument> getPaymentInstruments() { // return paymentInstruments; // } // // @Override // public String toString() { // return name; // } // // public static CheckoutGroup findByInstrument(PaymentInstrument instrument) { // // for (CheckoutGroup group : CheckoutGroup.values()) { // // if (group.getPaymentInstruments().contains(instrument)) { // return group; // } // } // return null; // } // // public static CheckoutGroup getByStringName(String stringName) { // CheckoutGroup result = null; // for (CheckoutGroup item : EnumSet.allOf(CheckoutGroup.class)) { // if (String.valueOf(item).equals(stringName)) { // result = item; // break; // } // } // return result; // } // // }
import cz.gopay.api.v3.model.common.CheckoutGroup; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
package cz.gopay.api.v3.model.payment.support; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class PaymentInstrumentRoot { @XmlElement(name = "groups")
// Path: common/src/main/java/cz/gopay/api/v3/model/common/CheckoutGroup.java // @XmlType // @XmlEnum(String.class) // public enum CheckoutGroup { // // @XmlEnumValue("card-payment") // CARD_PAYMENT("card-payment", EnumSet.of(PaymentInstrument.PAYMENT_CARD)), // // @XmlEnumValue("bank-transfer") // BANK_TRANSFER("bank-transfer", EnumSet.of(PaymentInstrument.BANK_ACCOUNT)), // // @XmlEnumValue("wallet") // WALLET("wallet", EnumSet.of( // PaymentInstrument.GOPAY, // PaymentInstrument.BITCOIN, // PaymentInstrument.PAYPAL)), // // @XmlEnumValue("others") // OTHERS("others", EnumSet.of( // PaymentInstrument.PRSMS, // PaymentInstrument.MPAYMENT, // PaymentInstrument.PAYSAFECARD, // PaymentInstrument.MASTERPASS)) // ; // // private final String name; // private final Set<PaymentInstrument> paymentInstruments; // // private CheckoutGroup(String name, Set<PaymentInstrument> paymentInstruments) { // this.name = name; // this.paymentInstruments = paymentInstruments; // } // // public String getName() { // return name; // } // // public Set<PaymentInstrument> getPaymentInstruments() { // return paymentInstruments; // } // // @Override // public String toString() { // return name; // } // // public static CheckoutGroup findByInstrument(PaymentInstrument instrument) { // // for (CheckoutGroup group : CheckoutGroup.values()) { // // if (group.getPaymentInstruments().contains(instrument)) { // return group; // } // } // return null; // } // // public static CheckoutGroup getByStringName(String stringName) { // CheckoutGroup result = null; // for (CheckoutGroup item : EnumSet.allOf(CheckoutGroup.class)) { // if (String.valueOf(item).equals(stringName)) { // result = item; // break; // } // } // return result; // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/payment/support/PaymentInstrumentRoot.java import cz.gopay.api.v3.model.common.CheckoutGroup; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; package cz.gopay.api.v3.model.payment.support; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class PaymentInstrumentRoot { @XmlElement(name = "groups")
private Map<CheckoutGroup, Group> groups;
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/eet/EETReceiptFilter.java
// Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // }
import cz.gopay.api.v3.util.GPDateAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
package cz.gopay.api.v3.model.eet; /** * Created by František Sichinger on 23.2.17. */ @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class EETReceiptFilter { @XmlElement(name = "date_from")
// Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/eet/EETReceiptFilter.java import cz.gopay.api.v3.util.GPDateAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; package cz.gopay.api.v3.model.eet; /** * Created by František Sichinger on 23.2.17. */ @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class EETReceiptFilter { @XmlElement(name = "date_from")
@XmlJavaTypeAdapter(GPDateAdapter.class)
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/GPExceptionHandler.java
// Path: common/src/main/java/cz/gopay/api/v3/model/APIError.java // @XmlRootElement(name = "error") // public class APIError { // // @XmlElement(name = "date_issued") // @XmlJavaTypeAdapter(GPTimestampAdapter.class) // private Date dateIssued; // // @XmlElement(name = "errors",required = true) // private List<ErrorElement> errorMessages; // // public APIError() { // } // // public APIError(Date dateIssued) { // this.dateIssued = dateIssued; // } // // public static APIError create() { // return new APIError(new Date()); // } // // public APIError addError(String errorName, int errorCode, String message, // String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, message, description)); // // return this; // } // // public APIError addError(String errorName, int errorCode, String field, // String message, String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, field, message, description)); // return this; // } // // public Date getDateIssued() { // return dateIssued; // } // // public void setDateIssued(Date dateOccured) { // this.dateIssued = dateOccured; // } // // public List<ErrorElement> getErrorMessages() { // return errorMessages; // } // // public void setErrorMessages(List<ErrorElement> errors) { // this.errorMessages = errors; // } // // }
import javax.ws.rs.ClientErrorException; import javax.ws.rs.ProcessingException; import javax.ws.rs.WebApplicationException; import cz.gopay.api.v3.model.APIError;
package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public class GPExceptionHandler { public static void handleException(WebApplicationException ex) throws GPClientException, ClientErrorException { if (!ex.getResponse().hasEntity()) { throw ex; } try {
// Path: common/src/main/java/cz/gopay/api/v3/model/APIError.java // @XmlRootElement(name = "error") // public class APIError { // // @XmlElement(name = "date_issued") // @XmlJavaTypeAdapter(GPTimestampAdapter.class) // private Date dateIssued; // // @XmlElement(name = "errors",required = true) // private List<ErrorElement> errorMessages; // // public APIError() { // } // // public APIError(Date dateIssued) { // this.dateIssued = dateIssued; // } // // public static APIError create() { // return new APIError(new Date()); // } // // public APIError addError(String errorName, int errorCode, String message, // String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, message, description)); // // return this; // } // // public APIError addError(String errorName, int errorCode, String field, // String message, String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, field, message, description)); // return this; // } // // public Date getDateIssued() { // return dateIssued; // } // // public void setDateIssued(Date dateOccured) { // this.dateIssued = dateOccured; // } // // public List<ErrorElement> getErrorMessages() { // return errorMessages; // } // // public void setErrorMessages(List<ErrorElement> errors) { // this.errorMessages = errors; // } // // } // Path: common/src/main/java/cz/gopay/api/v3/GPExceptionHandler.java import javax.ws.rs.ClientErrorException; import javax.ws.rs.ProcessingException; import javax.ws.rs.WebApplicationException; import cz.gopay.api.v3.model.APIError; package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public class GPExceptionHandler { public static void handleException(WebApplicationException ex) throws GPClientException, ClientErrorException { if (!ex.getResponse().hasEntity()) { throw ex; } try {
APIError error = ex.getResponse().readEntity(APIError.class);
gopaycommunity/gopay-java-api
apache-cxf/src/test/java/cz/gopay/cfx/CXFLoginTest.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-cxf/src/main/java-templates/cz/gopay/api/v3/impl/cxf/CXFGPConnector.java // public class CXFGPConnector extends AbstractGPConnector { // // private CXFGPConnector(String api) { // super(api); // } // // private CXFGPConnector(String api, AccessToken token) { // super(api, token); // } // // public static CXFGPConnector build(String api) { // return new CXFGPConnector(api); // } // // public static CXFGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new CXFGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // List providers = new ArrayList(); // ObjectMapper mapper = new ObjectMapper(); // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // JacksonJaxbJsonProvider jsonProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // providers.add(jsonProvider); // T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true); // Client client = (Client) t; // client.header("User-Agent", getImplementationName() + "=" + getVersion()); // return t; // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.cxf.CXFGPConnector; import test.utils.LoginTests; import test.utils.TestUtils;
package cz.gopay.cfx; public class CXFLoginTest extends LoginTests { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-cxf/src/main/java-templates/cz/gopay/api/v3/impl/cxf/CXFGPConnector.java // public class CXFGPConnector extends AbstractGPConnector { // // private CXFGPConnector(String api) { // super(api); // } // // private CXFGPConnector(String api, AccessToken token) { // super(api, token); // } // // public static CXFGPConnector build(String api) { // return new CXFGPConnector(api); // } // // public static CXFGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new CXFGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // List providers = new ArrayList(); // ObjectMapper mapper = new ObjectMapper(); // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // JacksonJaxbJsonProvider jsonProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // providers.add(jsonProvider); // T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true); // Client client = (Client) t; // client.header("User-Agent", getImplementationName() + "=" + getVersion()); // return t; // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: apache-cxf/src/test/java/cz/gopay/cfx/CXFLoginTest.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.cxf.CXFGPConnector; import test.utils.LoginTests; import test.utils.TestUtils; package cz.gopay.cfx; public class CXFLoginTest extends LoginTests { public IGPConnector getConnector() {
return CXFGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
apache-cxf/src/test/java/cz/gopay/cfx/CXFLoginTest.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-cxf/src/main/java-templates/cz/gopay/api/v3/impl/cxf/CXFGPConnector.java // public class CXFGPConnector extends AbstractGPConnector { // // private CXFGPConnector(String api) { // super(api); // } // // private CXFGPConnector(String api, AccessToken token) { // super(api, token); // } // // public static CXFGPConnector build(String api) { // return new CXFGPConnector(api); // } // // public static CXFGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new CXFGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // List providers = new ArrayList(); // ObjectMapper mapper = new ObjectMapper(); // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // JacksonJaxbJsonProvider jsonProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // providers.add(jsonProvider); // T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true); // Client client = (Client) t; // client.header("User-Agent", getImplementationName() + "=" + getVersion()); // return t; // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.cxf.CXFGPConnector; import test.utils.LoginTests; import test.utils.TestUtils;
package cz.gopay.cfx; public class CXFLoginTest extends LoginTests { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-cxf/src/main/java-templates/cz/gopay/api/v3/impl/cxf/CXFGPConnector.java // public class CXFGPConnector extends AbstractGPConnector { // // private CXFGPConnector(String api) { // super(api); // } // // private CXFGPConnector(String api, AccessToken token) { // super(api, token); // } // // public static CXFGPConnector build(String api) { // return new CXFGPConnector(api); // } // // public static CXFGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new CXFGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // List providers = new ArrayList(); // ObjectMapper mapper = new ObjectMapper(); // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // JacksonJaxbJsonProvider jsonProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // providers.add(jsonProvider); // T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true); // Client client = (Client) t; // client.header("User-Agent", getImplementationName() + "=" + getVersion()); // return t; // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: apache-cxf/src/test/java/cz/gopay/cfx/CXFLoginTest.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.cxf.CXFGPConnector; import test.utils.LoginTests; import test.utils.TestUtils; package cz.gopay.cfx; public class CXFLoginTest extends LoginTests { public IGPConnector getConnector() {
return CXFGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
apache-http-client/src/test/java/cz/gopay/cfx/ApacheHttpClientLoginTest.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-http-client/src/main/java-templates/cz/gopay/api/v3/impl/apacheclient/HttpClientGPConnector.java // public class HttpClientGPConnector extends AbstractGPConnector { // // public static HttpClientGPConnector build(String apiUrl) { // return new HttpClientGPConnector(apiUrl); // } // // private HttpClientGPConnector(String apiUrl) { // super(apiUrl); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // if (proxy == AuthClient.class) { // return (T) new HttpClientAuthClientImpl(apiUrl); // } else if (proxy == PaymentClient.class) { // return (T) new HttpClientPaymentClientImpl(apiUrl); // } // throw new IllegalArgumentException("Unknown interface"); // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.apacheclient.HttpClientGPConnector; import test.utils.LoginTests; import test.utils.TestUtils;
package cz.gopay.cfx; public class ApacheHttpClientLoginTest extends LoginTests { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-http-client/src/main/java-templates/cz/gopay/api/v3/impl/apacheclient/HttpClientGPConnector.java // public class HttpClientGPConnector extends AbstractGPConnector { // // public static HttpClientGPConnector build(String apiUrl) { // return new HttpClientGPConnector(apiUrl); // } // // private HttpClientGPConnector(String apiUrl) { // super(apiUrl); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // if (proxy == AuthClient.class) { // return (T) new HttpClientAuthClientImpl(apiUrl); // } else if (proxy == PaymentClient.class) { // return (T) new HttpClientPaymentClientImpl(apiUrl); // } // throw new IllegalArgumentException("Unknown interface"); // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: apache-http-client/src/test/java/cz/gopay/cfx/ApacheHttpClientLoginTest.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.apacheclient.HttpClientGPConnector; import test.utils.LoginTests; import test.utils.TestUtils; package cz.gopay.cfx; public class ApacheHttpClientLoginTest extends LoginTests { public IGPConnector getConnector() {
return HttpClientGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
apache-http-client/src/test/java/cz/gopay/cfx/ApacheHttpClientLoginTest.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-http-client/src/main/java-templates/cz/gopay/api/v3/impl/apacheclient/HttpClientGPConnector.java // public class HttpClientGPConnector extends AbstractGPConnector { // // public static HttpClientGPConnector build(String apiUrl) { // return new HttpClientGPConnector(apiUrl); // } // // private HttpClientGPConnector(String apiUrl) { // super(apiUrl); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // if (proxy == AuthClient.class) { // return (T) new HttpClientAuthClientImpl(apiUrl); // } else if (proxy == PaymentClient.class) { // return (T) new HttpClientPaymentClientImpl(apiUrl); // } // throw new IllegalArgumentException("Unknown interface"); // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.apacheclient.HttpClientGPConnector; import test.utils.LoginTests; import test.utils.TestUtils;
package cz.gopay.cfx; public class ApacheHttpClientLoginTest extends LoginTests { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-http-client/src/main/java-templates/cz/gopay/api/v3/impl/apacheclient/HttpClientGPConnector.java // public class HttpClientGPConnector extends AbstractGPConnector { // // public static HttpClientGPConnector build(String apiUrl) { // return new HttpClientGPConnector(apiUrl); // } // // private HttpClientGPConnector(String apiUrl) { // super(apiUrl); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // if (proxy == AuthClient.class) { // return (T) new HttpClientAuthClientImpl(apiUrl); // } else if (proxy == PaymentClient.class) { // return (T) new HttpClientPaymentClientImpl(apiUrl); // } // throw new IllegalArgumentException("Unknown interface"); // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: apache-http-client/src/test/java/cz/gopay/cfx/ApacheHttpClientLoginTest.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.apacheclient.HttpClientGPConnector; import test.utils.LoginTests; import test.utils.TestUtils; package cz.gopay.cfx; public class ApacheHttpClientLoginTest extends LoginTests { public IGPConnector getConnector() {
return HttpClientGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
apache-http-client/src/main/java/cz/gopay/api/v3/impl/apacheclient/AbstractImpl.java
// Path: common/src/main/java/cz/gopay/api/v3/model/APIError.java // @XmlRootElement(name = "error") // public class APIError { // // @XmlElement(name = "date_issued") // @XmlJavaTypeAdapter(GPTimestampAdapter.class) // private Date dateIssued; // // @XmlElement(name = "errors",required = true) // private List<ErrorElement> errorMessages; // // public APIError() { // } // // public APIError(Date dateIssued) { // this.dateIssued = dateIssued; // } // // public static APIError create() { // return new APIError(new Date()); // } // // public APIError addError(String errorName, int errorCode, String message, // String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, message, description)); // // return this; // } // // public APIError addError(String errorName, int errorCode, String field, // String message, String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, field, message, description)); // return this; // } // // public Date getDateIssued() { // return dateIssued; // } // // public void setDateIssued(Date dateOccured) { // this.dateIssued = dateOccured; // } // // public List<ErrorElement> getErrorMessages() { // return errorMessages; // } // // public void setErrorMessages(List<ErrorElement> errors) { // this.errorMessages = errors; // } // // }
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; import cz.gopay.api.v3.model.APIError; import java.io.IOException; import javax.ws.rs.WebApplicationException; import org.apache.http.HttpResponse; import org.apache.http.client.fluent.Response; import org.apache.http.util.EntityUtils; import org.apache.logging.log4j.Logger;
package cz.gopay.api.v3.impl.apacheclient; /** * * @author Frantisek Sichinger */ public class AbstractImpl { protected static final String IMPLEMENTATION_NAME = "${project.artifactId}"; protected static final String VERSION = "${project.artifactId}"; protected static final String AUTHORIZATION = "Authorization"; protected static final String SCOPE = "scope"; protected static final String GRANT_TYPE = "grant_type"; protected static final String CONTENT_TYPE = "Content-Type"; protected static final String ACCEPT = "Accept"; protected static final String USER_AGENT = "User-Agent"; protected String apiUrl; private final ObjectMapper mapper; protected Logger logger; public AbstractImpl(String apiUrl) { this.apiUrl = apiUrl; mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); } protected <T> T unMarshall(Response response, Class<T> entity) { String json = null; try { HttpResponse httpresponse = response.returnResponse(); json = entityToString(httpresponse); JsonNode tree = mapper.readTree(json);
// Path: common/src/main/java/cz/gopay/api/v3/model/APIError.java // @XmlRootElement(name = "error") // public class APIError { // // @XmlElement(name = "date_issued") // @XmlJavaTypeAdapter(GPTimestampAdapter.class) // private Date dateIssued; // // @XmlElement(name = "errors",required = true) // private List<ErrorElement> errorMessages; // // public APIError() { // } // // public APIError(Date dateIssued) { // this.dateIssued = dateIssued; // } // // public static APIError create() { // return new APIError(new Date()); // } // // public APIError addError(String errorName, int errorCode, String message, // String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, message, description)); // // return this; // } // // public APIError addError(String errorName, int errorCode, String field, // String message, String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, field, message, description)); // return this; // } // // public Date getDateIssued() { // return dateIssued; // } // // public void setDateIssued(Date dateOccured) { // this.dateIssued = dateOccured; // } // // public List<ErrorElement> getErrorMessages() { // return errorMessages; // } // // public void setErrorMessages(List<ErrorElement> errors) { // this.errorMessages = errors; // } // // } // Path: apache-http-client/src/main/java/cz/gopay/api/v3/impl/apacheclient/AbstractImpl.java import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; import cz.gopay.api.v3.model.APIError; import java.io.IOException; import javax.ws.rs.WebApplicationException; import org.apache.http.HttpResponse; import org.apache.http.client.fluent.Response; import org.apache.http.util.EntityUtils; import org.apache.logging.log4j.Logger; package cz.gopay.api.v3.impl.apacheclient; /** * * @author Frantisek Sichinger */ public class AbstractImpl { protected static final String IMPLEMENTATION_NAME = "${project.artifactId}"; protected static final String VERSION = "${project.artifactId}"; protected static final String AUTHORIZATION = "Authorization"; protected static final String SCOPE = "scope"; protected static final String GRANT_TYPE = "grant_type"; protected static final String CONTENT_TYPE = "Content-Type"; protected static final String ACCEPT = "Accept"; protected static final String USER_AGENT = "User-Agent"; protected String apiUrl; private final ObjectMapper mapper; protected Logger logger; public AbstractImpl(String apiUrl) { this.apiUrl = apiUrl; mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); } protected <T> T unMarshall(Response response, Class<T> entity) { String json = null; try { HttpResponse httpresponse = response.returnResponse(); json = entityToString(httpresponse); JsonNode tree = mapper.readTree(json);
APIError error = mapper.treeToValue(tree, APIError.class);
gopaycommunity/gopay-java-api
resteasy/src/test/java/cz/gopay/resteasy/ResteasyLoginTests.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: resteasy/src/main/java/cz/gopay/api/v3/impl/resteasy/ResteasyGPConnector.java // public class ResteasyGPConnector extends AbstractGPConnector { // // private ResteasyGPConnector(String api) { // super(api); // } // // private ResteasyGPConnector(String api, AccessToken accessToken) { // super(api, accessToken); // } // // public static ResteasyGPConnector build(String api) { // return new ResteasyGPConnector(api); // } // // public static ResteasyGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new ResteasyGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // URI i = null; // try { // i = new URI(apiUrl); // } catch (URISyntaxException ex) { // throw new RuntimeException(ex); // } // // ResteasyClientBuilder builder = new ResteasyClientBuilderImpl(); // builder.connectTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); // builder.readTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); // // ResteasyProviderFactory.getInstance().register(builder); // // ResteasyClientImpl client = (ResteasyClientImpl) builder.build(); // client.register((ClientRequestFilter) requestContext -> requestContext.getHeaders().add("User-Agent", getImplementationName() + "=" + getVersion())); // // ObjectMapper mapper = new ObjectMapper(); // JacksonJaxbJsonProvider jaxbProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // // builder.register(jaxbProvider); // // ResteasyWebTarget target = client.target(i); // return target.proxy(proxy); // } // // @Override // public String getImplementationName() { // return "${project.artifactId}"; // } // // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.resteasy.ResteasyGPConnector; import test.utils.LoginTests; import test.utils.TestUtils;
package cz.gopay.resteasy; public class ResteasyLoginTests extends LoginTests { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: resteasy/src/main/java/cz/gopay/api/v3/impl/resteasy/ResteasyGPConnector.java // public class ResteasyGPConnector extends AbstractGPConnector { // // private ResteasyGPConnector(String api) { // super(api); // } // // private ResteasyGPConnector(String api, AccessToken accessToken) { // super(api, accessToken); // } // // public static ResteasyGPConnector build(String api) { // return new ResteasyGPConnector(api); // } // // public static ResteasyGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new ResteasyGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // URI i = null; // try { // i = new URI(apiUrl); // } catch (URISyntaxException ex) { // throw new RuntimeException(ex); // } // // ResteasyClientBuilder builder = new ResteasyClientBuilderImpl(); // builder.connectTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); // builder.readTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); // // ResteasyProviderFactory.getInstance().register(builder); // // ResteasyClientImpl client = (ResteasyClientImpl) builder.build(); // client.register((ClientRequestFilter) requestContext -> requestContext.getHeaders().add("User-Agent", getImplementationName() + "=" + getVersion())); // // ObjectMapper mapper = new ObjectMapper(); // JacksonJaxbJsonProvider jaxbProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // // builder.register(jaxbProvider); // // ResteasyWebTarget target = client.target(i); // return target.proxy(proxy); // } // // @Override // public String getImplementationName() { // return "${project.artifactId}"; // } // // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: resteasy/src/test/java/cz/gopay/resteasy/ResteasyLoginTests.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.resteasy.ResteasyGPConnector; import test.utils.LoginTests; import test.utils.TestUtils; package cz.gopay.resteasy; public class ResteasyLoginTests extends LoginTests { public IGPConnector getConnector() {
return ResteasyGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
resteasy/src/test/java/cz/gopay/resteasy/ResteasyLoginTests.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: resteasy/src/main/java/cz/gopay/api/v3/impl/resteasy/ResteasyGPConnector.java // public class ResteasyGPConnector extends AbstractGPConnector { // // private ResteasyGPConnector(String api) { // super(api); // } // // private ResteasyGPConnector(String api, AccessToken accessToken) { // super(api, accessToken); // } // // public static ResteasyGPConnector build(String api) { // return new ResteasyGPConnector(api); // } // // public static ResteasyGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new ResteasyGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // URI i = null; // try { // i = new URI(apiUrl); // } catch (URISyntaxException ex) { // throw new RuntimeException(ex); // } // // ResteasyClientBuilder builder = new ResteasyClientBuilderImpl(); // builder.connectTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); // builder.readTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); // // ResteasyProviderFactory.getInstance().register(builder); // // ResteasyClientImpl client = (ResteasyClientImpl) builder.build(); // client.register((ClientRequestFilter) requestContext -> requestContext.getHeaders().add("User-Agent", getImplementationName() + "=" + getVersion())); // // ObjectMapper mapper = new ObjectMapper(); // JacksonJaxbJsonProvider jaxbProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // // builder.register(jaxbProvider); // // ResteasyWebTarget target = client.target(i); // return target.proxy(proxy); // } // // @Override // public String getImplementationName() { // return "${project.artifactId}"; // } // // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.resteasy.ResteasyGPConnector; import test.utils.LoginTests; import test.utils.TestUtils;
package cz.gopay.resteasy; public class ResteasyLoginTests extends LoginTests { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: resteasy/src/main/java/cz/gopay/api/v3/impl/resteasy/ResteasyGPConnector.java // public class ResteasyGPConnector extends AbstractGPConnector { // // private ResteasyGPConnector(String api) { // super(api); // } // // private ResteasyGPConnector(String api, AccessToken accessToken) { // super(api, accessToken); // } // // public static ResteasyGPConnector build(String api) { // return new ResteasyGPConnector(api); // } // // public static ResteasyGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new ResteasyGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // URI i = null; // try { // i = new URI(apiUrl); // } catch (URISyntaxException ex) { // throw new RuntimeException(ex); // } // // ResteasyClientBuilder builder = new ResteasyClientBuilderImpl(); // builder.connectTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); // builder.readTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); // // ResteasyProviderFactory.getInstance().register(builder); // // ResteasyClientImpl client = (ResteasyClientImpl) builder.build(); // client.register((ClientRequestFilter) requestContext -> requestContext.getHeaders().add("User-Agent", getImplementationName() + "=" + getVersion())); // // ObjectMapper mapper = new ObjectMapper(); // JacksonJaxbJsonProvider jaxbProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // // builder.register(jaxbProvider); // // ResteasyWebTarget target = client.target(i); // return target.proxy(proxy); // } // // @Override // public String getImplementationName() { // return "${project.artifactId}"; // } // // } // // Path: common-tests/src/main/java/test/utils/LoginTests.java // public abstract class LoginTests implements RestClientTest { // // private static final Logger logger = LogManager.getLogger(LoginTests.class); // // @Test // public void testAuthApacheHttpClient() { // try { // IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); // Assertions.assertNotNull(connector.getAccessToken()); // } catch (GPClientException ex) { // TestUtils.handleException(ex, logger); // } // } // // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: resteasy/src/test/java/cz/gopay/resteasy/ResteasyLoginTests.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.resteasy.ResteasyGPConnector; import test.utils.LoginTests; import test.utils.TestUtils; package cz.gopay.resteasy; public class ResteasyLoginTests extends LoginTests { public IGPConnector getConnector() {
return ResteasyGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/payment/support/EnabledPaymentInstrument.java
// Path: common/src/main/java/cz/gopay/api/v3/model/common/CheckoutGroup.java // @XmlType // @XmlEnum(String.class) // public enum CheckoutGroup { // // @XmlEnumValue("card-payment") // CARD_PAYMENT("card-payment", EnumSet.of(PaymentInstrument.PAYMENT_CARD)), // // @XmlEnumValue("bank-transfer") // BANK_TRANSFER("bank-transfer", EnumSet.of(PaymentInstrument.BANK_ACCOUNT)), // // @XmlEnumValue("wallet") // WALLET("wallet", EnumSet.of( // PaymentInstrument.GOPAY, // PaymentInstrument.BITCOIN, // PaymentInstrument.PAYPAL)), // // @XmlEnumValue("others") // OTHERS("others", EnumSet.of( // PaymentInstrument.PRSMS, // PaymentInstrument.MPAYMENT, // PaymentInstrument.PAYSAFECARD, // PaymentInstrument.MASTERPASS)) // ; // // private final String name; // private final Set<PaymentInstrument> paymentInstruments; // // private CheckoutGroup(String name, Set<PaymentInstrument> paymentInstruments) { // this.name = name; // this.paymentInstruments = paymentInstruments; // } // // public String getName() { // return name; // } // // public Set<PaymentInstrument> getPaymentInstruments() { // return paymentInstruments; // } // // @Override // public String toString() { // return name; // } // // public static CheckoutGroup findByInstrument(PaymentInstrument instrument) { // // for (CheckoutGroup group : CheckoutGroup.values()) { // // if (group.getPaymentInstruments().contains(instrument)) { // return group; // } // } // return null; // } // // public static CheckoutGroup getByStringName(String stringName) { // CheckoutGroup result = null; // for (CheckoutGroup item : EnumSet.allOf(CheckoutGroup.class)) { // if (String.valueOf(item).equals(stringName)) { // result = item; // break; // } // } // return result; // } // // }
import cz.gopay.api.v3.model.common.CheckoutGroup; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map;
return paymentInstrument; } public Map<Locale, String> getLabel() { return label; } public EnabledPaymentInstrument addLabel(String label, Locale locale) { if (this.label == null) { this.label = new LinkedHashMap<>(); } this.label.put(locale, label); return this; } public Image getImage() { return image; } public EnabledPaymentInstrument withImage(Image image) { this.image = image; return this; } public String getGroup() { return group; }
// Path: common/src/main/java/cz/gopay/api/v3/model/common/CheckoutGroup.java // @XmlType // @XmlEnum(String.class) // public enum CheckoutGroup { // // @XmlEnumValue("card-payment") // CARD_PAYMENT("card-payment", EnumSet.of(PaymentInstrument.PAYMENT_CARD)), // // @XmlEnumValue("bank-transfer") // BANK_TRANSFER("bank-transfer", EnumSet.of(PaymentInstrument.BANK_ACCOUNT)), // // @XmlEnumValue("wallet") // WALLET("wallet", EnumSet.of( // PaymentInstrument.GOPAY, // PaymentInstrument.BITCOIN, // PaymentInstrument.PAYPAL)), // // @XmlEnumValue("others") // OTHERS("others", EnumSet.of( // PaymentInstrument.PRSMS, // PaymentInstrument.MPAYMENT, // PaymentInstrument.PAYSAFECARD, // PaymentInstrument.MASTERPASS)) // ; // // private final String name; // private final Set<PaymentInstrument> paymentInstruments; // // private CheckoutGroup(String name, Set<PaymentInstrument> paymentInstruments) { // this.name = name; // this.paymentInstruments = paymentInstruments; // } // // public String getName() { // return name; // } // // public Set<PaymentInstrument> getPaymentInstruments() { // return paymentInstruments; // } // // @Override // public String toString() { // return name; // } // // public static CheckoutGroup findByInstrument(PaymentInstrument instrument) { // // for (CheckoutGroup group : CheckoutGroup.values()) { // // if (group.getPaymentInstruments().contains(instrument)) { // return group; // } // } // return null; // } // // public static CheckoutGroup getByStringName(String stringName) { // CheckoutGroup result = null; // for (CheckoutGroup item : EnumSet.allOf(CheckoutGroup.class)) { // if (String.valueOf(item).equals(stringName)) { // result = item; // break; // } // } // return result; // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/payment/support/EnabledPaymentInstrument.java import cz.gopay.api.v3.model.common.CheckoutGroup; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; return paymentInstrument; } public Map<Locale, String> getLabel() { return label; } public EnabledPaymentInstrument addLabel(String label, Locale locale) { if (this.label == null) { this.label = new LinkedHashMap<>(); } this.label.put(locale, label); return this; } public Image getImage() { return image; } public EnabledPaymentInstrument withImage(Image image) { this.image = image; return this; } public String getGroup() { return group; }
public EnabledPaymentInstrument withGroup(CheckoutGroup coGroup) {
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/APIError.java
// Path: common/src/main/java/cz/gopay/api/v3/util/GPTimestampAdapter.java // public class GPTimestampAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // }
import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import cz.gopay.api.v3.util.GPTimestampAdapter;
package cz.gopay.api.v3.model; @XmlRootElement(name = "error") public class APIError { @XmlElement(name = "date_issued")
// Path: common/src/main/java/cz/gopay/api/v3/util/GPTimestampAdapter.java // public class GPTimestampAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/APIError.java import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import cz.gopay.api.v3.util.GPTimestampAdapter; package cz.gopay.api.v3.model; @XmlRootElement(name = "error") public class APIError { @XmlElement(name = "date_issued")
@XmlJavaTypeAdapter(GPTimestampAdapter.class)
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/eet/EETReceipt.java
// Path: common/src/main/java/cz/gopay/api/v3/util/GPTimestampAdapter.java // public class GPTimestampAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // }
import cz.gopay.api.v3.util.GPTimestampAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
package cz.gopay.api.v3.model.eet; @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) public class EETReceipt { public enum REETReceiptState { CREATED, DELIVERY_FAILED, DELIVERED } public enum REETMode { AUTO, EET } @XmlElement(name = "payment_id") private Long paymentId; @XmlElement(name = "state") private REETReceiptState state; @XmlElement(name = "date_last_attempt")
// Path: common/src/main/java/cz/gopay/api/v3/util/GPTimestampAdapter.java // public class GPTimestampAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/eet/EETReceipt.java import cz.gopay.api.v3.util.GPTimestampAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; package cz.gopay.api.v3.model.eet; @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) public class EETReceipt { public enum REETReceiptState { CREATED, DELIVERY_FAILED, DELIVERED } public enum REETMode { AUTO, EET } @XmlElement(name = "payment_id") private Long paymentId; @XmlElement(name = "state") private REETReceiptState state; @XmlElement(name = "date_last_attempt")
@XmlJavaTypeAdapter(GPTimestampAdapter.class)
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/AuthClient.java
// Path: common/src/main/java/cz/gopay/api/v3/model/access/AccessToken.java // @XmlRootElement // @XmlAccessorType(XmlAccessType.FIELD) // public class AccessToken { // // @XmlElement(name = "token_type") // private String tokenType; // // @XmlElement(name = "access_token") // private String accessToken; // // @XmlElement(name = "refresh_token") // private String refreshToken; // // @XmlElement(name = "expires_in") // private long expiresIn; // // public AccessToken() { // } // // public AccessToken(String tokenType, String accessToken, String refreshToken, // long expiresIn) { // this.tokenType = tokenType; // this.accessToken = accessToken; // this.refreshToken = refreshToken; // this.expiresIn = expiresIn; // } // // public String getTokenType() { // return tokenType; // } // // public void setTokenType(String tokenType) { // this.tokenType = tokenType; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public long getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(long expiresIn) { // this.expiresIn = expiresIn; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AuthHeader.java // @XmlAccessorType(XmlAccessType.FIELD) // public class AuthHeader { // // @HeaderParam(value = "Authorization") // private String auhorization; // // public String getAuhorization() { // return auhorization; // } // // public void setAuhorization(String auhorization) { // this.auhorization = auhorization; // } // // @Override // public String toString() { // return "AuthHeader [authorization=" + auhorization + "]"; // } // // public static AuthHeader build(String clientId, String clientSecret) { // try { // AuthHeader result = new AuthHeader(); // // String toEncode = clientId + ":" + clientSecret; // String ulrEncoded = URLEncoder.encode(toEncode, "UTF-8"); // String base64 = "Basic " + Base64.getEncoder().encodeToString(ulrEncoded.getBytes()); // // result.setAuhorization(base64); // // return result; // // } catch (UnsupportedEncodingException e) { // throw new IllegalStateException(e.getMessage()); // } // } // // public static AuthHeader build(String accessToken) { // AuthHeader result = new AuthHeader(); // result.setAuhorization("Bearer " + accessToken); // // return result; // } // // }
import javax.ws.rs.Consumes; import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import cz.gopay.api.v3.model.access.AccessToken; import cz.gopay.api.v3.model.access.AuthHeader; import javax.ws.rs.BeanParam; import javax.ws.rs.core.MediaType;
package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public interface AuthClient { @POST @Path("/oauth2/token") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
// Path: common/src/main/java/cz/gopay/api/v3/model/access/AccessToken.java // @XmlRootElement // @XmlAccessorType(XmlAccessType.FIELD) // public class AccessToken { // // @XmlElement(name = "token_type") // private String tokenType; // // @XmlElement(name = "access_token") // private String accessToken; // // @XmlElement(name = "refresh_token") // private String refreshToken; // // @XmlElement(name = "expires_in") // private long expiresIn; // // public AccessToken() { // } // // public AccessToken(String tokenType, String accessToken, String refreshToken, // long expiresIn) { // this.tokenType = tokenType; // this.accessToken = accessToken; // this.refreshToken = refreshToken; // this.expiresIn = expiresIn; // } // // public String getTokenType() { // return tokenType; // } // // public void setTokenType(String tokenType) { // this.tokenType = tokenType; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public long getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(long expiresIn) { // this.expiresIn = expiresIn; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AuthHeader.java // @XmlAccessorType(XmlAccessType.FIELD) // public class AuthHeader { // // @HeaderParam(value = "Authorization") // private String auhorization; // // public String getAuhorization() { // return auhorization; // } // // public void setAuhorization(String auhorization) { // this.auhorization = auhorization; // } // // @Override // public String toString() { // return "AuthHeader [authorization=" + auhorization + "]"; // } // // public static AuthHeader build(String clientId, String clientSecret) { // try { // AuthHeader result = new AuthHeader(); // // String toEncode = clientId + ":" + clientSecret; // String ulrEncoded = URLEncoder.encode(toEncode, "UTF-8"); // String base64 = "Basic " + Base64.getEncoder().encodeToString(ulrEncoded.getBytes()); // // result.setAuhorization(base64); // // return result; // // } catch (UnsupportedEncodingException e) { // throw new IllegalStateException(e.getMessage()); // } // } // // public static AuthHeader build(String accessToken) { // AuthHeader result = new AuthHeader(); // result.setAuhorization("Bearer " + accessToken); // // return result; // } // // } // Path: common/src/main/java/cz/gopay/api/v3/AuthClient.java import javax.ws.rs.Consumes; import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import cz.gopay.api.v3.model.access.AccessToken; import cz.gopay.api.v3.model.access.AuthHeader; import javax.ws.rs.BeanParam; import javax.ws.rs.core.MediaType; package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public interface AuthClient { @POST @Path("/oauth2/token") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
AccessToken loginApplication(@BeanParam AuthHeader authHeader,
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/AuthClient.java
// Path: common/src/main/java/cz/gopay/api/v3/model/access/AccessToken.java // @XmlRootElement // @XmlAccessorType(XmlAccessType.FIELD) // public class AccessToken { // // @XmlElement(name = "token_type") // private String tokenType; // // @XmlElement(name = "access_token") // private String accessToken; // // @XmlElement(name = "refresh_token") // private String refreshToken; // // @XmlElement(name = "expires_in") // private long expiresIn; // // public AccessToken() { // } // // public AccessToken(String tokenType, String accessToken, String refreshToken, // long expiresIn) { // this.tokenType = tokenType; // this.accessToken = accessToken; // this.refreshToken = refreshToken; // this.expiresIn = expiresIn; // } // // public String getTokenType() { // return tokenType; // } // // public void setTokenType(String tokenType) { // this.tokenType = tokenType; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public long getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(long expiresIn) { // this.expiresIn = expiresIn; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AuthHeader.java // @XmlAccessorType(XmlAccessType.FIELD) // public class AuthHeader { // // @HeaderParam(value = "Authorization") // private String auhorization; // // public String getAuhorization() { // return auhorization; // } // // public void setAuhorization(String auhorization) { // this.auhorization = auhorization; // } // // @Override // public String toString() { // return "AuthHeader [authorization=" + auhorization + "]"; // } // // public static AuthHeader build(String clientId, String clientSecret) { // try { // AuthHeader result = new AuthHeader(); // // String toEncode = clientId + ":" + clientSecret; // String ulrEncoded = URLEncoder.encode(toEncode, "UTF-8"); // String base64 = "Basic " + Base64.getEncoder().encodeToString(ulrEncoded.getBytes()); // // result.setAuhorization(base64); // // return result; // // } catch (UnsupportedEncodingException e) { // throw new IllegalStateException(e.getMessage()); // } // } // // public static AuthHeader build(String accessToken) { // AuthHeader result = new AuthHeader(); // result.setAuhorization("Bearer " + accessToken); // // return result; // } // // }
import javax.ws.rs.Consumes; import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import cz.gopay.api.v3.model.access.AccessToken; import cz.gopay.api.v3.model.access.AuthHeader; import javax.ws.rs.BeanParam; import javax.ws.rs.core.MediaType;
package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public interface AuthClient { @POST @Path("/oauth2/token") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
// Path: common/src/main/java/cz/gopay/api/v3/model/access/AccessToken.java // @XmlRootElement // @XmlAccessorType(XmlAccessType.FIELD) // public class AccessToken { // // @XmlElement(name = "token_type") // private String tokenType; // // @XmlElement(name = "access_token") // private String accessToken; // // @XmlElement(name = "refresh_token") // private String refreshToken; // // @XmlElement(name = "expires_in") // private long expiresIn; // // public AccessToken() { // } // // public AccessToken(String tokenType, String accessToken, String refreshToken, // long expiresIn) { // this.tokenType = tokenType; // this.accessToken = accessToken; // this.refreshToken = refreshToken; // this.expiresIn = expiresIn; // } // // public String getTokenType() { // return tokenType; // } // // public void setTokenType(String tokenType) { // this.tokenType = tokenType; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public long getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(long expiresIn) { // this.expiresIn = expiresIn; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AuthHeader.java // @XmlAccessorType(XmlAccessType.FIELD) // public class AuthHeader { // // @HeaderParam(value = "Authorization") // private String auhorization; // // public String getAuhorization() { // return auhorization; // } // // public void setAuhorization(String auhorization) { // this.auhorization = auhorization; // } // // @Override // public String toString() { // return "AuthHeader [authorization=" + auhorization + "]"; // } // // public static AuthHeader build(String clientId, String clientSecret) { // try { // AuthHeader result = new AuthHeader(); // // String toEncode = clientId + ":" + clientSecret; // String ulrEncoded = URLEncoder.encode(toEncode, "UTF-8"); // String base64 = "Basic " + Base64.getEncoder().encodeToString(ulrEncoded.getBytes()); // // result.setAuhorization(base64); // // return result; // // } catch (UnsupportedEncodingException e) { // throw new IllegalStateException(e.getMessage()); // } // } // // public static AuthHeader build(String accessToken) { // AuthHeader result = new AuthHeader(); // result.setAuhorization("Bearer " + accessToken); // // return result; // } // // } // Path: common/src/main/java/cz/gopay/api/v3/AuthClient.java import javax.ws.rs.Consumes; import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import cz.gopay.api.v3.model.access.AccessToken; import cz.gopay.api.v3.model.access.AuthHeader; import javax.ws.rs.BeanParam; import javax.ws.rs.core.MediaType; package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public interface AuthClient { @POST @Path("/oauth2/token") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
AccessToken loginApplication(@BeanParam AuthHeader authHeader,
gopaycommunity/gopay-java-api
apache-cxf/src/test/java/cz/gopay/cfx/CXFPaymentTest.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-cxf/src/main/java-templates/cz/gopay/api/v3/impl/cxf/CXFGPConnector.java // public class CXFGPConnector extends AbstractGPConnector { // // private CXFGPConnector(String api) { // super(api); // } // // private CXFGPConnector(String api, AccessToken token) { // super(api, token); // } // // public static CXFGPConnector build(String api) { // return new CXFGPConnector(api); // } // // public static CXFGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new CXFGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // List providers = new ArrayList(); // ObjectMapper mapper = new ObjectMapper(); // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // JacksonJaxbJsonProvider jsonProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // providers.add(jsonProvider); // T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true); // Client client = (Client) t; // client.header("User-Agent", getImplementationName() + "=" + getVersion()); // return t; // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/PaymentTest.java // public abstract class PaymentTest extends AbstractPaymentTests { // // @Test // public void testHttpClientCreatePayment() { // testConnectorCreatePayment(getConnector()); // } // // @Test // public void testHttpClientPaymentRecurrency() { // testPaymentRecurrency(getConnector()); // } // // @Test // public void testHttpClientPaymentStataus() { // testPaymentStatus(getConnector()); // } // // @Test // public void testHttpClientPaymentPreAuthorization() { // testPaymentPreAuthorization(getConnector()); // } // // //@Test // public void testHttpClientVoidAuthorization() { // testPaymentVoidAuthorization(getConnector()); // } // // //@Test // public void testPaymentRefund() { // testPaymentRefund(getConnector()); // } // // // // @Test // public void testEETREceiptFindByFilter() { // testEETREceiptFindByFilter(getConnector()); // } // // // @Test // public void testEETReceiptFindByPayment() { // testEETReceiptFindByPayment(getConnector()); // } // // // @Test // public void testPaymentInstrumentRoot(){ // testPaymentInstrumentRoot(getConnector()); // } // // @Test // public void testGenerateStatementHttp() { // testGenerateStatement(getConnector()); // } // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.cxf.CXFGPConnector; import test.utils.PaymentTest; import test.utils.TestUtils;
package cz.gopay.cfx; public class CXFPaymentTest extends PaymentTest { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-cxf/src/main/java-templates/cz/gopay/api/v3/impl/cxf/CXFGPConnector.java // public class CXFGPConnector extends AbstractGPConnector { // // private CXFGPConnector(String api) { // super(api); // } // // private CXFGPConnector(String api, AccessToken token) { // super(api, token); // } // // public static CXFGPConnector build(String api) { // return new CXFGPConnector(api); // } // // public static CXFGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new CXFGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // List providers = new ArrayList(); // ObjectMapper mapper = new ObjectMapper(); // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // JacksonJaxbJsonProvider jsonProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // providers.add(jsonProvider); // T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true); // Client client = (Client) t; // client.header("User-Agent", getImplementationName() + "=" + getVersion()); // return t; // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/PaymentTest.java // public abstract class PaymentTest extends AbstractPaymentTests { // // @Test // public void testHttpClientCreatePayment() { // testConnectorCreatePayment(getConnector()); // } // // @Test // public void testHttpClientPaymentRecurrency() { // testPaymentRecurrency(getConnector()); // } // // @Test // public void testHttpClientPaymentStataus() { // testPaymentStatus(getConnector()); // } // // @Test // public void testHttpClientPaymentPreAuthorization() { // testPaymentPreAuthorization(getConnector()); // } // // //@Test // public void testHttpClientVoidAuthorization() { // testPaymentVoidAuthorization(getConnector()); // } // // //@Test // public void testPaymentRefund() { // testPaymentRefund(getConnector()); // } // // // // @Test // public void testEETREceiptFindByFilter() { // testEETREceiptFindByFilter(getConnector()); // } // // // @Test // public void testEETReceiptFindByPayment() { // testEETReceiptFindByPayment(getConnector()); // } // // // @Test // public void testPaymentInstrumentRoot(){ // testPaymentInstrumentRoot(getConnector()); // } // // @Test // public void testGenerateStatementHttp() { // testGenerateStatement(getConnector()); // } // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: apache-cxf/src/test/java/cz/gopay/cfx/CXFPaymentTest.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.cxf.CXFGPConnector; import test.utils.PaymentTest; import test.utils.TestUtils; package cz.gopay.cfx; public class CXFPaymentTest extends PaymentTest { public IGPConnector getConnector() {
return CXFGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
apache-cxf/src/test/java/cz/gopay/cfx/CXFPaymentTest.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-cxf/src/main/java-templates/cz/gopay/api/v3/impl/cxf/CXFGPConnector.java // public class CXFGPConnector extends AbstractGPConnector { // // private CXFGPConnector(String api) { // super(api); // } // // private CXFGPConnector(String api, AccessToken token) { // super(api, token); // } // // public static CXFGPConnector build(String api) { // return new CXFGPConnector(api); // } // // public static CXFGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new CXFGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // List providers = new ArrayList(); // ObjectMapper mapper = new ObjectMapper(); // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // JacksonJaxbJsonProvider jsonProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // providers.add(jsonProvider); // T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true); // Client client = (Client) t; // client.header("User-Agent", getImplementationName() + "=" + getVersion()); // return t; // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/PaymentTest.java // public abstract class PaymentTest extends AbstractPaymentTests { // // @Test // public void testHttpClientCreatePayment() { // testConnectorCreatePayment(getConnector()); // } // // @Test // public void testHttpClientPaymentRecurrency() { // testPaymentRecurrency(getConnector()); // } // // @Test // public void testHttpClientPaymentStataus() { // testPaymentStatus(getConnector()); // } // // @Test // public void testHttpClientPaymentPreAuthorization() { // testPaymentPreAuthorization(getConnector()); // } // // //@Test // public void testHttpClientVoidAuthorization() { // testPaymentVoidAuthorization(getConnector()); // } // // //@Test // public void testPaymentRefund() { // testPaymentRefund(getConnector()); // } // // // // @Test // public void testEETREceiptFindByFilter() { // testEETREceiptFindByFilter(getConnector()); // } // // // @Test // public void testEETReceiptFindByPayment() { // testEETReceiptFindByPayment(getConnector()); // } // // // @Test // public void testPaymentInstrumentRoot(){ // testPaymentInstrumentRoot(getConnector()); // } // // @Test // public void testGenerateStatementHttp() { // testGenerateStatement(getConnector()); // } // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.cxf.CXFGPConnector; import test.utils.PaymentTest; import test.utils.TestUtils;
package cz.gopay.cfx; public class CXFPaymentTest extends PaymentTest { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-cxf/src/main/java-templates/cz/gopay/api/v3/impl/cxf/CXFGPConnector.java // public class CXFGPConnector extends AbstractGPConnector { // // private CXFGPConnector(String api) { // super(api); // } // // private CXFGPConnector(String api, AccessToken token) { // super(api, token); // } // // public static CXFGPConnector build(String api) { // return new CXFGPConnector(api); // } // // public static CXFGPConnector build(String api, String accessToken, String refreshToken, Date expiresIn) { // return new CXFGPConnector(api, // new AccessToken(OAuth.TOKEN_TYPE_BEARER, accessToken, refreshToken, expiresIn.getTime())); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // List providers = new ArrayList(); // ObjectMapper mapper = new ObjectMapper(); // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); // // JacksonJaxbJsonProvider jsonProvider // = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); // providers.add(jsonProvider); // T t = JAXRSClientFactory.create(apiUrl, proxy, providers, true); // Client client = (Client) t; // client.header("User-Agent", getImplementationName() + "=" + getVersion()); // return t; // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/PaymentTest.java // public abstract class PaymentTest extends AbstractPaymentTests { // // @Test // public void testHttpClientCreatePayment() { // testConnectorCreatePayment(getConnector()); // } // // @Test // public void testHttpClientPaymentRecurrency() { // testPaymentRecurrency(getConnector()); // } // // @Test // public void testHttpClientPaymentStataus() { // testPaymentStatus(getConnector()); // } // // @Test // public void testHttpClientPaymentPreAuthorization() { // testPaymentPreAuthorization(getConnector()); // } // // //@Test // public void testHttpClientVoidAuthorization() { // testPaymentVoidAuthorization(getConnector()); // } // // //@Test // public void testPaymentRefund() { // testPaymentRefund(getConnector()); // } // // // // @Test // public void testEETREceiptFindByFilter() { // testEETREceiptFindByFilter(getConnector()); // } // // // @Test // public void testEETReceiptFindByPayment() { // testEETReceiptFindByPayment(getConnector()); // } // // // @Test // public void testPaymentInstrumentRoot(){ // testPaymentInstrumentRoot(getConnector()); // } // // @Test // public void testGenerateStatementHttp() { // testGenerateStatement(getConnector()); // } // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: apache-cxf/src/test/java/cz/gopay/cfx/CXFPaymentTest.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.cxf.CXFGPConnector; import test.utils.PaymentTest; import test.utils.TestUtils; package cz.gopay.cfx; public class CXFPaymentTest extends PaymentTest { public IGPConnector getConnector() {
return CXFGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/GPClientException.java
// Path: common/src/main/java/cz/gopay/api/v3/model/APIError.java // @XmlRootElement(name = "error") // public class APIError { // // @XmlElement(name = "date_issued") // @XmlJavaTypeAdapter(GPTimestampAdapter.class) // private Date dateIssued; // // @XmlElement(name = "errors",required = true) // private List<ErrorElement> errorMessages; // // public APIError() { // } // // public APIError(Date dateIssued) { // this.dateIssued = dateIssued; // } // // public static APIError create() { // return new APIError(new Date()); // } // // public APIError addError(String errorName, int errorCode, String message, // String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, message, description)); // // return this; // } // // public APIError addError(String errorName, int errorCode, String field, // String message, String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, field, message, description)); // return this; // } // // public Date getDateIssued() { // return dateIssued; // } // // public void setDateIssued(Date dateOccured) { // this.dateIssued = dateOccured; // } // // public List<ErrorElement> getErrorMessages() { // return errorMessages; // } // // public void setErrorMessages(List<ErrorElement> errors) { // this.errorMessages = errors; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/ErrorElement.java // @XmlAccessorType(XmlAccessType.NONE) // public class ErrorElement { // // @XmlElement(name = "scope") // private ErrorScope scope; // // @XmlElement(name = "field") // private String field; // // @XmlElement(name = "error_code") // private int errorCode; // // @XmlElement(name = "error_name") // private String errorName; // // @XmlElement(name = "message") // private String message; // // @XmlElement(name = "description") // private String description; // // public ErrorElement() { // } // // public ErrorElement(String errorName, int errorCode, String message, // String description) { // super(); // this.scope = ErrorScope.G; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorElement(String errorName, int errorCode, String field, // String message, String description) { // super(); // this.scope = ErrorScope.F; // this.field = field; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorScope getScope() { // return scope; // } // // public String getField() { // return field; // } // // public int getErrorCode() { // return errorCode; // } // // public String getErrorName() { // return errorName; // } // // public String getMessage() { // return message; // } // // public String getDescription() { // return description; // } // // }
import java.util.Date; import java.util.List; import cz.gopay.api.v3.model.APIError; import cz.gopay.api.v3.model.ErrorElement; import java.util.Collections;
package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public class GPClientException extends Exception { private final int httpResultCode;
// Path: common/src/main/java/cz/gopay/api/v3/model/APIError.java // @XmlRootElement(name = "error") // public class APIError { // // @XmlElement(name = "date_issued") // @XmlJavaTypeAdapter(GPTimestampAdapter.class) // private Date dateIssued; // // @XmlElement(name = "errors",required = true) // private List<ErrorElement> errorMessages; // // public APIError() { // } // // public APIError(Date dateIssued) { // this.dateIssued = dateIssued; // } // // public static APIError create() { // return new APIError(new Date()); // } // // public APIError addError(String errorName, int errorCode, String message, // String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, message, description)); // // return this; // } // // public APIError addError(String errorName, int errorCode, String field, // String message, String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, field, message, description)); // return this; // } // // public Date getDateIssued() { // return dateIssued; // } // // public void setDateIssued(Date dateOccured) { // this.dateIssued = dateOccured; // } // // public List<ErrorElement> getErrorMessages() { // return errorMessages; // } // // public void setErrorMessages(List<ErrorElement> errors) { // this.errorMessages = errors; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/ErrorElement.java // @XmlAccessorType(XmlAccessType.NONE) // public class ErrorElement { // // @XmlElement(name = "scope") // private ErrorScope scope; // // @XmlElement(name = "field") // private String field; // // @XmlElement(name = "error_code") // private int errorCode; // // @XmlElement(name = "error_name") // private String errorName; // // @XmlElement(name = "message") // private String message; // // @XmlElement(name = "description") // private String description; // // public ErrorElement() { // } // // public ErrorElement(String errorName, int errorCode, String message, // String description) { // super(); // this.scope = ErrorScope.G; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorElement(String errorName, int errorCode, String field, // String message, String description) { // super(); // this.scope = ErrorScope.F; // this.field = field; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorScope getScope() { // return scope; // } // // public String getField() { // return field; // } // // public int getErrorCode() { // return errorCode; // } // // public String getErrorName() { // return errorName; // } // // public String getMessage() { // return message; // } // // public String getDescription() { // return description; // } // // } // Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java import java.util.Date; import java.util.List; import cz.gopay.api.v3.model.APIError; import cz.gopay.api.v3.model.ErrorElement; import java.util.Collections; package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public class GPClientException extends Exception { private final int httpResultCode;
private final APIError error;
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/GPClientException.java
// Path: common/src/main/java/cz/gopay/api/v3/model/APIError.java // @XmlRootElement(name = "error") // public class APIError { // // @XmlElement(name = "date_issued") // @XmlJavaTypeAdapter(GPTimestampAdapter.class) // private Date dateIssued; // // @XmlElement(name = "errors",required = true) // private List<ErrorElement> errorMessages; // // public APIError() { // } // // public APIError(Date dateIssued) { // this.dateIssued = dateIssued; // } // // public static APIError create() { // return new APIError(new Date()); // } // // public APIError addError(String errorName, int errorCode, String message, // String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, message, description)); // // return this; // } // // public APIError addError(String errorName, int errorCode, String field, // String message, String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, field, message, description)); // return this; // } // // public Date getDateIssued() { // return dateIssued; // } // // public void setDateIssued(Date dateOccured) { // this.dateIssued = dateOccured; // } // // public List<ErrorElement> getErrorMessages() { // return errorMessages; // } // // public void setErrorMessages(List<ErrorElement> errors) { // this.errorMessages = errors; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/ErrorElement.java // @XmlAccessorType(XmlAccessType.NONE) // public class ErrorElement { // // @XmlElement(name = "scope") // private ErrorScope scope; // // @XmlElement(name = "field") // private String field; // // @XmlElement(name = "error_code") // private int errorCode; // // @XmlElement(name = "error_name") // private String errorName; // // @XmlElement(name = "message") // private String message; // // @XmlElement(name = "description") // private String description; // // public ErrorElement() { // } // // public ErrorElement(String errorName, int errorCode, String message, // String description) { // super(); // this.scope = ErrorScope.G; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorElement(String errorName, int errorCode, String field, // String message, String description) { // super(); // this.scope = ErrorScope.F; // this.field = field; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorScope getScope() { // return scope; // } // // public String getField() { // return field; // } // // public int getErrorCode() { // return errorCode; // } // // public String getErrorName() { // return errorName; // } // // public String getMessage() { // return message; // } // // public String getDescription() { // return description; // } // // }
import java.util.Date; import java.util.List; import cz.gopay.api.v3.model.APIError; import cz.gopay.api.v3.model.ErrorElement; import java.util.Collections;
package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public class GPClientException extends Exception { private final int httpResultCode; private final APIError error; public GPClientException(int httpResultCode, APIError error) { this.error = error; this.httpResultCode = httpResultCode; } public APIError getError() { return error; } public Date getDateIssued() { return error.getDateIssued(); }
// Path: common/src/main/java/cz/gopay/api/v3/model/APIError.java // @XmlRootElement(name = "error") // public class APIError { // // @XmlElement(name = "date_issued") // @XmlJavaTypeAdapter(GPTimestampAdapter.class) // private Date dateIssued; // // @XmlElement(name = "errors",required = true) // private List<ErrorElement> errorMessages; // // public APIError() { // } // // public APIError(Date dateIssued) { // this.dateIssued = dateIssued; // } // // public static APIError create() { // return new APIError(new Date()); // } // // public APIError addError(String errorName, int errorCode, String message, // String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, message, description)); // // return this; // } // // public APIError addError(String errorName, int errorCode, String field, // String message, String description) { // if (errorMessages == null) { // errorMessages = new ArrayList<>(); // } // // errorMessages.add(new ErrorElement(errorName, errorCode, field, message, description)); // return this; // } // // public Date getDateIssued() { // return dateIssued; // } // // public void setDateIssued(Date dateOccured) { // this.dateIssued = dateOccured; // } // // public List<ErrorElement> getErrorMessages() { // return errorMessages; // } // // public void setErrorMessages(List<ErrorElement> errors) { // this.errorMessages = errors; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/ErrorElement.java // @XmlAccessorType(XmlAccessType.NONE) // public class ErrorElement { // // @XmlElement(name = "scope") // private ErrorScope scope; // // @XmlElement(name = "field") // private String field; // // @XmlElement(name = "error_code") // private int errorCode; // // @XmlElement(name = "error_name") // private String errorName; // // @XmlElement(name = "message") // private String message; // // @XmlElement(name = "description") // private String description; // // public ErrorElement() { // } // // public ErrorElement(String errorName, int errorCode, String message, // String description) { // super(); // this.scope = ErrorScope.G; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorElement(String errorName, int errorCode, String field, // String message, String description) { // super(); // this.scope = ErrorScope.F; // this.field = field; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorScope getScope() { // return scope; // } // // public String getField() { // return field; // } // // public int getErrorCode() { // return errorCode; // } // // public String getErrorName() { // return errorName; // } // // public String getMessage() { // return message; // } // // public String getDescription() { // return description; // } // // } // Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java import java.util.Date; import java.util.List; import cz.gopay.api.v3.model.APIError; import cz.gopay.api.v3.model.ErrorElement; import java.util.Collections; package cz.gopay.api.v3; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ public class GPClientException extends Exception { private final int httpResultCode; private final APIError error; public GPClientException(int httpResultCode, APIError error) { this.error = error; this.httpResultCode = httpResultCode; } public APIError getError() { return error; } public Date getDateIssued() { return error.getDateIssued(); }
public List<ErrorElement> getErrorMessages() {
gopaycommunity/gopay-java-api
common-tests/src/main/java/test/utils/TestUtils.java
// Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java // public class GPClientException extends Exception { // // private final int httpResultCode; // private final APIError error; // // public GPClientException(int httpResultCode, APIError error) { // this.error = error; // this.httpResultCode = httpResultCode; // } // // public APIError getError() { // return error; // } // // public Date getDateIssued() { // return error.getDateIssued(); // } // // public List<ErrorElement> getErrorMessages() { // if (error.getErrorMessages() == null) // return Collections.EMPTY_LIST; // return error.getErrorMessages(); // } // // public String extractMessage() { // StringBuilder sb = new StringBuilder(); // for (ErrorElement msg : getErrorMessages()) { // sb.append("RC[").append(httpResultCode).append("]"); // if (msg.getField() != null) { // sb.append("Field: ").append(msg.getField()); // } // if (msg.getErrorName() != null) { // sb.append(" Name: ").append(msg.getErrorName()).append("[").append(msg.getErrorCode()).append("]"); // } // if (msg.getMessage() != null) { // sb.append(" Msg: ").append(msg.getMessage()); // } // if (msg.getDescription() != null) { // sb.append(" Desc: ").append(msg.getDescription()); // } // } // return sb.toString(); // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/ErrorElement.java // @XmlAccessorType(XmlAccessType.NONE) // public class ErrorElement { // // @XmlElement(name = "scope") // private ErrorScope scope; // // @XmlElement(name = "field") // private String field; // // @XmlElement(name = "error_code") // private int errorCode; // // @XmlElement(name = "error_name") // private String errorName; // // @XmlElement(name = "message") // private String message; // // @XmlElement(name = "description") // private String description; // // public ErrorElement() { // } // // public ErrorElement(String errorName, int errorCode, String message, // String description) { // super(); // this.scope = ErrorScope.G; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorElement(String errorName, int errorCode, String field, // String message, String description) { // super(); // this.scope = ErrorScope.F; // this.field = field; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorScope getScope() { // return scope; // } // // public String getField() { // return field; // } // // public int getErrorCode() { // return errorCode; // } // // public String getErrorName() { // return errorName; // } // // public String getMessage() { // return message; // } // // public String getDescription() { // return description; // } // // }
import cz.gopay.api.v3.GPClientException; import cz.gopay.api.v3.model.ErrorElement; import java.util.List; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package test.utils; /** * * @author František Sichinger */ public class TestUtils { public static final String API_URL = "https://gw.sandbox.gopay.com/api"; public static final String CLIENT_ID = "1744960415"; public static final String CLIENT_SECRET = "h9wyRz2s"; public static final Long GOID = 8339303643L; // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // public static final String CLIENT_ID = "app@musicshop.cz"; // public static final String CLIENT_SECRET = "VpnJVcTn"; // public static final Long GOID = 8761908826L;
// Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java // public class GPClientException extends Exception { // // private final int httpResultCode; // private final APIError error; // // public GPClientException(int httpResultCode, APIError error) { // this.error = error; // this.httpResultCode = httpResultCode; // } // // public APIError getError() { // return error; // } // // public Date getDateIssued() { // return error.getDateIssued(); // } // // public List<ErrorElement> getErrorMessages() { // if (error.getErrorMessages() == null) // return Collections.EMPTY_LIST; // return error.getErrorMessages(); // } // // public String extractMessage() { // StringBuilder sb = new StringBuilder(); // for (ErrorElement msg : getErrorMessages()) { // sb.append("RC[").append(httpResultCode).append("]"); // if (msg.getField() != null) { // sb.append("Field: ").append(msg.getField()); // } // if (msg.getErrorName() != null) { // sb.append(" Name: ").append(msg.getErrorName()).append("[").append(msg.getErrorCode()).append("]"); // } // if (msg.getMessage() != null) { // sb.append(" Msg: ").append(msg.getMessage()); // } // if (msg.getDescription() != null) { // sb.append(" Desc: ").append(msg.getDescription()); // } // } // return sb.toString(); // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/ErrorElement.java // @XmlAccessorType(XmlAccessType.NONE) // public class ErrorElement { // // @XmlElement(name = "scope") // private ErrorScope scope; // // @XmlElement(name = "field") // private String field; // // @XmlElement(name = "error_code") // private int errorCode; // // @XmlElement(name = "error_name") // private String errorName; // // @XmlElement(name = "message") // private String message; // // @XmlElement(name = "description") // private String description; // // public ErrorElement() { // } // // public ErrorElement(String errorName, int errorCode, String message, // String description) { // super(); // this.scope = ErrorScope.G; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorElement(String errorName, int errorCode, String field, // String message, String description) { // super(); // this.scope = ErrorScope.F; // this.field = field; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorScope getScope() { // return scope; // } // // public String getField() { // return field; // } // // public int getErrorCode() { // return errorCode; // } // // public String getErrorName() { // return errorName; // } // // public String getMessage() { // return message; // } // // public String getDescription() { // return description; // } // // } // Path: common-tests/src/main/java/test/utils/TestUtils.java import cz.gopay.api.v3.GPClientException; import cz.gopay.api.v3.model.ErrorElement; import java.util.List; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package test.utils; /** * * @author František Sichinger */ public class TestUtils { public static final String API_URL = "https://gw.sandbox.gopay.com/api"; public static final String CLIENT_ID = "1744960415"; public static final String CLIENT_SECRET = "h9wyRz2s"; public static final Long GOID = 8339303643L; // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // public static final String CLIENT_ID = "app@musicshop.cz"; // public static final String CLIENT_SECRET = "VpnJVcTn"; // public static final Long GOID = 8761908826L;
public static void handleException(GPClientException e, Logger logger) {
gopaycommunity/gopay-java-api
common-tests/src/main/java/test/utils/TestUtils.java
// Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java // public class GPClientException extends Exception { // // private final int httpResultCode; // private final APIError error; // // public GPClientException(int httpResultCode, APIError error) { // this.error = error; // this.httpResultCode = httpResultCode; // } // // public APIError getError() { // return error; // } // // public Date getDateIssued() { // return error.getDateIssued(); // } // // public List<ErrorElement> getErrorMessages() { // if (error.getErrorMessages() == null) // return Collections.EMPTY_LIST; // return error.getErrorMessages(); // } // // public String extractMessage() { // StringBuilder sb = new StringBuilder(); // for (ErrorElement msg : getErrorMessages()) { // sb.append("RC[").append(httpResultCode).append("]"); // if (msg.getField() != null) { // sb.append("Field: ").append(msg.getField()); // } // if (msg.getErrorName() != null) { // sb.append(" Name: ").append(msg.getErrorName()).append("[").append(msg.getErrorCode()).append("]"); // } // if (msg.getMessage() != null) { // sb.append(" Msg: ").append(msg.getMessage()); // } // if (msg.getDescription() != null) { // sb.append(" Desc: ").append(msg.getDescription()); // } // } // return sb.toString(); // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/ErrorElement.java // @XmlAccessorType(XmlAccessType.NONE) // public class ErrorElement { // // @XmlElement(name = "scope") // private ErrorScope scope; // // @XmlElement(name = "field") // private String field; // // @XmlElement(name = "error_code") // private int errorCode; // // @XmlElement(name = "error_name") // private String errorName; // // @XmlElement(name = "message") // private String message; // // @XmlElement(name = "description") // private String description; // // public ErrorElement() { // } // // public ErrorElement(String errorName, int errorCode, String message, // String description) { // super(); // this.scope = ErrorScope.G; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorElement(String errorName, int errorCode, String field, // String message, String description) { // super(); // this.scope = ErrorScope.F; // this.field = field; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorScope getScope() { // return scope; // } // // public String getField() { // return field; // } // // public int getErrorCode() { // return errorCode; // } // // public String getErrorName() { // return errorName; // } // // public String getMessage() { // return message; // } // // public String getDescription() { // return description; // } // // }
import cz.gopay.api.v3.GPClientException; import cz.gopay.api.v3.model.ErrorElement; import java.util.List; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package test.utils; /** * * @author František Sichinger */ public class TestUtils { public static final String API_URL = "https://gw.sandbox.gopay.com/api"; public static final String CLIENT_ID = "1744960415"; public static final String CLIENT_SECRET = "h9wyRz2s"; public static final Long GOID = 8339303643L; // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // public static final String CLIENT_ID = "app@musicshop.cz"; // public static final String CLIENT_SECRET = "VpnJVcTn"; // public static final Long GOID = 8761908826L; public static void handleException(GPClientException e, Logger logger) {
// Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java // public class GPClientException extends Exception { // // private final int httpResultCode; // private final APIError error; // // public GPClientException(int httpResultCode, APIError error) { // this.error = error; // this.httpResultCode = httpResultCode; // } // // public APIError getError() { // return error; // } // // public Date getDateIssued() { // return error.getDateIssued(); // } // // public List<ErrorElement> getErrorMessages() { // if (error.getErrorMessages() == null) // return Collections.EMPTY_LIST; // return error.getErrorMessages(); // } // // public String extractMessage() { // StringBuilder sb = new StringBuilder(); // for (ErrorElement msg : getErrorMessages()) { // sb.append("RC[").append(httpResultCode).append("]"); // if (msg.getField() != null) { // sb.append("Field: ").append(msg.getField()); // } // if (msg.getErrorName() != null) { // sb.append(" Name: ").append(msg.getErrorName()).append("[").append(msg.getErrorCode()).append("]"); // } // if (msg.getMessage() != null) { // sb.append(" Msg: ").append(msg.getMessage()); // } // if (msg.getDescription() != null) { // sb.append(" Desc: ").append(msg.getDescription()); // } // } // return sb.toString(); // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/ErrorElement.java // @XmlAccessorType(XmlAccessType.NONE) // public class ErrorElement { // // @XmlElement(name = "scope") // private ErrorScope scope; // // @XmlElement(name = "field") // private String field; // // @XmlElement(name = "error_code") // private int errorCode; // // @XmlElement(name = "error_name") // private String errorName; // // @XmlElement(name = "message") // private String message; // // @XmlElement(name = "description") // private String description; // // public ErrorElement() { // } // // public ErrorElement(String errorName, int errorCode, String message, // String description) { // super(); // this.scope = ErrorScope.G; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorElement(String errorName, int errorCode, String field, // String message, String description) { // super(); // this.scope = ErrorScope.F; // this.field = field; // this.errorCode = errorCode; // this.errorName = errorName; // this.message = message; // this.description = description; // } // // public ErrorScope getScope() { // return scope; // } // // public String getField() { // return field; // } // // public int getErrorCode() { // return errorCode; // } // // public String getErrorName() { // return errorName; // } // // public String getMessage() { // return message; // } // // public String getDescription() { // return description; // } // // } // Path: common-tests/src/main/java/test/utils/TestUtils.java import cz.gopay.api.v3.GPClientException; import cz.gopay.api.v3.model.ErrorElement; import java.util.List; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package test.utils; /** * * @author František Sichinger */ public class TestUtils { public static final String API_URL = "https://gw.sandbox.gopay.com/api"; public static final String CLIENT_ID = "1744960415"; public static final String CLIENT_SECRET = "h9wyRz2s"; public static final Long GOID = 8339303643L; // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // public static final String CLIENT_ID = "app@musicshop.cz"; // public static final String CLIENT_SECRET = "VpnJVcTn"; // public static final Long GOID = 8761908826L; public static void handleException(GPClientException e, Logger logger) {
List<ErrorElement> errorMessages = e.getErrorMessages();
gopaycommunity/gopay-java-api
common-tests/src/main/java/test/utils/LoginTests.java
// Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java // public class GPClientException extends Exception { // // private final int httpResultCode; // private final APIError error; // // public GPClientException(int httpResultCode, APIError error) { // this.error = error; // this.httpResultCode = httpResultCode; // } // // public APIError getError() { // return error; // } // // public Date getDateIssued() { // return error.getDateIssued(); // } // // public List<ErrorElement> getErrorMessages() { // if (error.getErrorMessages() == null) // return Collections.EMPTY_LIST; // return error.getErrorMessages(); // } // // public String extractMessage() { // StringBuilder sb = new StringBuilder(); // for (ErrorElement msg : getErrorMessages()) { // sb.append("RC[").append(httpResultCode).append("]"); // if (msg.getField() != null) { // sb.append("Field: ").append(msg.getField()); // } // if (msg.getErrorName() != null) { // sb.append(" Name: ").append(msg.getErrorName()).append("[").append(msg.getErrorCode()).append("]"); // } // if (msg.getMessage() != null) { // sb.append(" Msg: ").append(msg.getMessage()); // } // if (msg.getDescription() != null) { // sb.append(" Desc: ").append(msg.getDescription()); // } // } // return sb.toString(); // } // } // // Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // }
import cz.gopay.api.v3.GPClientException; import cz.gopay.api.v3.IGPConnector; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test;
package test.utils; public abstract class LoginTests implements RestClientTest { private static final Logger logger = LogManager.getLogger(LoginTests.class); @Test public void testAuthApacheHttpClient() { try {
// Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java // public class GPClientException extends Exception { // // private final int httpResultCode; // private final APIError error; // // public GPClientException(int httpResultCode, APIError error) { // this.error = error; // this.httpResultCode = httpResultCode; // } // // public APIError getError() { // return error; // } // // public Date getDateIssued() { // return error.getDateIssued(); // } // // public List<ErrorElement> getErrorMessages() { // if (error.getErrorMessages() == null) // return Collections.EMPTY_LIST; // return error.getErrorMessages(); // } // // public String extractMessage() { // StringBuilder sb = new StringBuilder(); // for (ErrorElement msg : getErrorMessages()) { // sb.append("RC[").append(httpResultCode).append("]"); // if (msg.getField() != null) { // sb.append("Field: ").append(msg.getField()); // } // if (msg.getErrorName() != null) { // sb.append(" Name: ").append(msg.getErrorName()).append("[").append(msg.getErrorCode()).append("]"); // } // if (msg.getMessage() != null) { // sb.append(" Msg: ").append(msg.getMessage()); // } // if (msg.getDescription() != null) { // sb.append(" Desc: ").append(msg.getDescription()); // } // } // return sb.toString(); // } // } // // Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // Path: common-tests/src/main/java/test/utils/LoginTests.java import cz.gopay.api.v3.GPClientException; import cz.gopay.api.v3.IGPConnector; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; package test.utils; public abstract class LoginTests implements RestClientTest { private static final Logger logger = LogManager.getLogger(LoginTests.class); @Test public void testAuthApacheHttpClient() { try {
IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET);
gopaycommunity/gopay-java-api
common-tests/src/main/java/test/utils/LoginTests.java
// Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java // public class GPClientException extends Exception { // // private final int httpResultCode; // private final APIError error; // // public GPClientException(int httpResultCode, APIError error) { // this.error = error; // this.httpResultCode = httpResultCode; // } // // public APIError getError() { // return error; // } // // public Date getDateIssued() { // return error.getDateIssued(); // } // // public List<ErrorElement> getErrorMessages() { // if (error.getErrorMessages() == null) // return Collections.EMPTY_LIST; // return error.getErrorMessages(); // } // // public String extractMessage() { // StringBuilder sb = new StringBuilder(); // for (ErrorElement msg : getErrorMessages()) { // sb.append("RC[").append(httpResultCode).append("]"); // if (msg.getField() != null) { // sb.append("Field: ").append(msg.getField()); // } // if (msg.getErrorName() != null) { // sb.append(" Name: ").append(msg.getErrorName()).append("[").append(msg.getErrorCode()).append("]"); // } // if (msg.getMessage() != null) { // sb.append(" Msg: ").append(msg.getMessage()); // } // if (msg.getDescription() != null) { // sb.append(" Desc: ").append(msg.getDescription()); // } // } // return sb.toString(); // } // } // // Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // }
import cz.gopay.api.v3.GPClientException; import cz.gopay.api.v3.IGPConnector; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test;
package test.utils; public abstract class LoginTests implements RestClientTest { private static final Logger logger = LogManager.getLogger(LoginTests.class); @Test public void testAuthApacheHttpClient() { try { IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); Assertions.assertNotNull(connector.getAccessToken());
// Path: common/src/main/java/cz/gopay/api/v3/GPClientException.java // public class GPClientException extends Exception { // // private final int httpResultCode; // private final APIError error; // // public GPClientException(int httpResultCode, APIError error) { // this.error = error; // this.httpResultCode = httpResultCode; // } // // public APIError getError() { // return error; // } // // public Date getDateIssued() { // return error.getDateIssued(); // } // // public List<ErrorElement> getErrorMessages() { // if (error.getErrorMessages() == null) // return Collections.EMPTY_LIST; // return error.getErrorMessages(); // } // // public String extractMessage() { // StringBuilder sb = new StringBuilder(); // for (ErrorElement msg : getErrorMessages()) { // sb.append("RC[").append(httpResultCode).append("]"); // if (msg.getField() != null) { // sb.append("Field: ").append(msg.getField()); // } // if (msg.getErrorName() != null) { // sb.append(" Name: ").append(msg.getErrorName()).append("[").append(msg.getErrorCode()).append("]"); // } // if (msg.getMessage() != null) { // sb.append(" Msg: ").append(msg.getMessage()); // } // if (msg.getDescription() != null) { // sb.append(" Desc: ").append(msg.getDescription()); // } // } // return sb.toString(); // } // } // // Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // Path: common-tests/src/main/java/test/utils/LoginTests.java import cz.gopay.api.v3.GPClientException; import cz.gopay.api.v3.IGPConnector; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; package test.utils; public abstract class LoginTests implements RestClientTest { private static final Logger logger = LogManager.getLogger(LoginTests.class); @Test public void testAuthApacheHttpClient() { try { IGPConnector connector = getConnector().getAppToken(TestUtils.CLIENT_ID, TestUtils.CLIENT_SECRET); Assertions.assertNotNull(connector.getAccessToken());
} catch (GPClientException ex) {
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/common/CheckoutGroup.java
// Path: common/src/main/java/cz/gopay/api/v3/model/payment/support/PaymentInstrument.java // public enum PaymentInstrument { // PAYMENT_CARD, // APPLE_PAY, // BANK_ACCOUNT, // PRSMS, // MPAYMENT, // COUPON, // PAYSAFECARD, // GOPAY, // PAYPAL, // BITCOIN, // MASTERPASS, // GPAY, // ACCOUNT, // CLICK_TO_PAY // }
import cz.gopay.api.v3.model.payment.support.PaymentInstrument; import java.util.EnumSet; import java.util.Set; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType;
package cz.gopay.api.v3.model.common; @XmlType @XmlEnum(String.class) public enum CheckoutGroup { @XmlEnumValue("card-payment")
// Path: common/src/main/java/cz/gopay/api/v3/model/payment/support/PaymentInstrument.java // public enum PaymentInstrument { // PAYMENT_CARD, // APPLE_PAY, // BANK_ACCOUNT, // PRSMS, // MPAYMENT, // COUPON, // PAYSAFECARD, // GOPAY, // PAYPAL, // BITCOIN, // MASTERPASS, // GPAY, // ACCOUNT, // CLICK_TO_PAY // } // Path: common/src/main/java/cz/gopay/api/v3/model/common/CheckoutGroup.java import cz.gopay.api.v3.model.payment.support.PaymentInstrument; import java.util.EnumSet; import java.util.Set; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; package cz.gopay.api.v3.model.common; @XmlType @XmlEnum(String.class) public enum CheckoutGroup { @XmlEnumValue("card-payment")
CARD_PAYMENT("card-payment", EnumSet.of(PaymentInstrument.PAYMENT_CARD)),
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/eet/EET.java
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // }
import cz.gopay.api.v3.model.common.Currency; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement;
private Long dan2; @XmlElement(name = "zakl_dan3") private Long zaklDan3; @XmlElement(name = "dan3") private Long dan3; @XmlElement(name = "cest_sluz") private Long cestSluz; @XmlElement(name = "pouzit_zboz1") private Long pouzitZboz1; @XmlElement(name = "pouzit_zboz2") private Long pouzitZboz2; @XmlElement(name = "pouzit_zboz3") private Long pouzitZboz3; @XmlElement(name = "urceno_cerp_zuct") private Long urcenoCerpZuct; @XmlElement(name = "cerp_zuct") private Long cerpZuct; @XmlElement(name = "dic_poverujiciho") private String dicPoverujiciho; @XmlElement(name = "mena")
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/eet/EET.java import cz.gopay.api.v3.model.common.Currency; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; private Long dan2; @XmlElement(name = "zakl_dan3") private Long zaklDan3; @XmlElement(name = "dan3") private Long dan3; @XmlElement(name = "cest_sluz") private Long cestSluz; @XmlElement(name = "pouzit_zboz1") private Long pouzitZboz1; @XmlElement(name = "pouzit_zboz2") private Long pouzitZboz2; @XmlElement(name = "pouzit_zboz3") private Long pouzitZboz3; @XmlElement(name = "urceno_cerp_zuct") private Long urcenoCerpZuct; @XmlElement(name = "cerp_zuct") private Long cerpZuct; @XmlElement(name = "dic_poverujiciho") private String dicPoverujiciho; @XmlElement(name = "mena")
private Currency mena;
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/payment/Payment.java
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/eet/EETCode.java // @XmlRootElement // public class EETCode { // // @XmlElement(name = "fik") // private String fik; // // @XmlElement(name = "bkp") // private String bkp; // // @XmlElement(name = "pkp") // private String pkp; // // @Override // public String toString() { // return String.format("EETCode [fik=%s, bkp=%s, pkp=%s]", fik, bkp, pkp); // } // // public String getFik() { // return fik; // } // // public void setFik(String fik) { // this.fik = fik; // } // // public String getBkp() { // return bkp; // } // // public void setBkp(String bkp) { // this.bkp = bkp; // } // // public String getPkp() { // return pkp; // } // // public void setPkp(String pkp) { // this.pkp = pkp; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/common/SessionSubState.java // public enum SessionSubState { // _101, // _102, // _3001, // _3002, // _3003, // _5001, // _5002, // _5003, // _5004, // _5005, // _5006, // _5007, // _5008, // _5009, // _5010, // _5011, // _5012, // _5013, // _5014, // _5015, // _5016, // _5017, // _5018, // _5019, // _5020, // _5021, // _5022, // _5023, // _5024, // _5025, // _5026, // _5027, // _5028, // _5029, // _5030, // _5031, // _5033, // _5035, // _5036, // _5037, // _5038, // _5039, // _5040, // _5041, // _5042, // _5043, // _5044, // _5045, // _5046, // _5047, // _5048, // _6001, // _6002, // _6003, // _6004, // _6005, // _6501, // _6502, // _6504 // }
import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import cz.gopay.api.v3.model.common.Currency; import cz.gopay.api.v3.model.eet.EETCode; import cz.gopay.api.v3.model.common.SessionSubState; import cz.gopay.api.v3.model.payment.support.*;
package cz.gopay.api.v3.model.payment; @XmlRootElement public class Payment { public enum SessionState { CREATED, PAYMENT_METHOD_CHOSEN, PAID, AUTHORIZED, CANCELED, TIMEOUTED, REFUNDED, PARTIALLY_REFUNDED } @XmlElement(name = "id") private Long id; @XmlElement(name = "parent_id") private Long parentId; @XmlElement(name = "order_number") private String orderNumber; @XmlElement(name = "state") private SessionState state; @XmlElement(name = "sub_state")
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/eet/EETCode.java // @XmlRootElement // public class EETCode { // // @XmlElement(name = "fik") // private String fik; // // @XmlElement(name = "bkp") // private String bkp; // // @XmlElement(name = "pkp") // private String pkp; // // @Override // public String toString() { // return String.format("EETCode [fik=%s, bkp=%s, pkp=%s]", fik, bkp, pkp); // } // // public String getFik() { // return fik; // } // // public void setFik(String fik) { // this.fik = fik; // } // // public String getBkp() { // return bkp; // } // // public void setBkp(String bkp) { // this.bkp = bkp; // } // // public String getPkp() { // return pkp; // } // // public void setPkp(String pkp) { // this.pkp = pkp; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/common/SessionSubState.java // public enum SessionSubState { // _101, // _102, // _3001, // _3002, // _3003, // _5001, // _5002, // _5003, // _5004, // _5005, // _5006, // _5007, // _5008, // _5009, // _5010, // _5011, // _5012, // _5013, // _5014, // _5015, // _5016, // _5017, // _5018, // _5019, // _5020, // _5021, // _5022, // _5023, // _5024, // _5025, // _5026, // _5027, // _5028, // _5029, // _5030, // _5031, // _5033, // _5035, // _5036, // _5037, // _5038, // _5039, // _5040, // _5041, // _5042, // _5043, // _5044, // _5045, // _5046, // _5047, // _5048, // _6001, // _6002, // _6003, // _6004, // _6005, // _6501, // _6502, // _6504 // } // Path: common/src/main/java/cz/gopay/api/v3/model/payment/Payment.java import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import cz.gopay.api.v3.model.common.Currency; import cz.gopay.api.v3.model.eet.EETCode; import cz.gopay.api.v3.model.common.SessionSubState; import cz.gopay.api.v3.model.payment.support.*; package cz.gopay.api.v3.model.payment; @XmlRootElement public class Payment { public enum SessionState { CREATED, PAYMENT_METHOD_CHOSEN, PAID, AUTHORIZED, CANCELED, TIMEOUTED, REFUNDED, PARTIALLY_REFUNDED } @XmlElement(name = "id") private Long id; @XmlElement(name = "parent_id") private Long parentId; @XmlElement(name = "order_number") private String orderNumber; @XmlElement(name = "state") private SessionState state; @XmlElement(name = "sub_state")
private SessionSubState subState;
gopaycommunity/gopay-java-api
apache-http-client/src/main/java/cz/gopay/api/v3/impl/apacheclient/HttpClientAuthClientImpl.java
// Path: common/src/main/java/cz/gopay/api/v3/AuthClient.java // public interface AuthClient { // // @POST // @Path("/oauth2/token") // @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) // @Consumes(MediaType.APPLICATION_FORM_URLENCODED) // AccessToken loginApplication(@BeanParam AuthHeader authHeader, // @FormParam(value = "grant_type") String grantType, // @FormParam(value = "scope") String scope); // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AccessToken.java // @XmlRootElement // @XmlAccessorType(XmlAccessType.FIELD) // public class AccessToken { // // @XmlElement(name = "token_type") // private String tokenType; // // @XmlElement(name = "access_token") // private String accessToken; // // @XmlElement(name = "refresh_token") // private String refreshToken; // // @XmlElement(name = "expires_in") // private long expiresIn; // // public AccessToken() { // } // // public AccessToken(String tokenType, String accessToken, String refreshToken, // long expiresIn) { // this.tokenType = tokenType; // this.accessToken = accessToken; // this.refreshToken = refreshToken; // this.expiresIn = expiresIn; // } // // public String getTokenType() { // return tokenType; // } // // public void setTokenType(String tokenType) { // this.tokenType = tokenType; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public long getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(long expiresIn) { // this.expiresIn = expiresIn; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AuthHeader.java // @XmlAccessorType(XmlAccessType.FIELD) // public class AuthHeader { // // @HeaderParam(value = "Authorization") // private String auhorization; // // public String getAuhorization() { // return auhorization; // } // // public void setAuhorization(String auhorization) { // this.auhorization = auhorization; // } // // @Override // public String toString() { // return "AuthHeader [authorization=" + auhorization + "]"; // } // // public static AuthHeader build(String clientId, String clientSecret) { // try { // AuthHeader result = new AuthHeader(); // // String toEncode = clientId + ":" + clientSecret; // String ulrEncoded = URLEncoder.encode(toEncode, "UTF-8"); // String base64 = "Basic " + Base64.getEncoder().encodeToString(ulrEncoded.getBytes()); // // result.setAuhorization(base64); // // return result; // // } catch (UnsupportedEncodingException e) { // throw new IllegalStateException(e.getMessage()); // } // } // // public static AuthHeader build(String accessToken) { // AuthHeader result = new AuthHeader(); // result.setAuhorization("Bearer " + accessToken); // // return result; // } // // }
import cz.gopay.api.v3.AuthClient; import cz.gopay.api.v3.model.access.AccessToken; import cz.gopay.api.v3.model.access.AuthHeader; import java.io.IOException; import javax.ws.rs.WebApplicationException; import org.apache.http.client.fluent.Form; import org.apache.http.client.fluent.Request; import org.apache.http.client.fluent.Response; import org.apache.http.entity.ContentType; import org.apache.logging.log4j.LogManager;
/* * To change this license header, choose License Headers in Project Properties. To change this * template file, choose Tools | Templates and open the template in the editor. */ package cz.gopay.api.v3.impl.apacheclient; public class HttpClientAuthClientImpl extends AbstractImpl implements AuthClient { protected HttpClientAuthClientImpl(String apiUrl) { super(apiUrl); super.logger = LogManager.getLogger(HttpClientAuthClientImpl.class); } @Override
// Path: common/src/main/java/cz/gopay/api/v3/AuthClient.java // public interface AuthClient { // // @POST // @Path("/oauth2/token") // @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) // @Consumes(MediaType.APPLICATION_FORM_URLENCODED) // AccessToken loginApplication(@BeanParam AuthHeader authHeader, // @FormParam(value = "grant_type") String grantType, // @FormParam(value = "scope") String scope); // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AccessToken.java // @XmlRootElement // @XmlAccessorType(XmlAccessType.FIELD) // public class AccessToken { // // @XmlElement(name = "token_type") // private String tokenType; // // @XmlElement(name = "access_token") // private String accessToken; // // @XmlElement(name = "refresh_token") // private String refreshToken; // // @XmlElement(name = "expires_in") // private long expiresIn; // // public AccessToken() { // } // // public AccessToken(String tokenType, String accessToken, String refreshToken, // long expiresIn) { // this.tokenType = tokenType; // this.accessToken = accessToken; // this.refreshToken = refreshToken; // this.expiresIn = expiresIn; // } // // public String getTokenType() { // return tokenType; // } // // public void setTokenType(String tokenType) { // this.tokenType = tokenType; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public long getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(long expiresIn) { // this.expiresIn = expiresIn; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AuthHeader.java // @XmlAccessorType(XmlAccessType.FIELD) // public class AuthHeader { // // @HeaderParam(value = "Authorization") // private String auhorization; // // public String getAuhorization() { // return auhorization; // } // // public void setAuhorization(String auhorization) { // this.auhorization = auhorization; // } // // @Override // public String toString() { // return "AuthHeader [authorization=" + auhorization + "]"; // } // // public static AuthHeader build(String clientId, String clientSecret) { // try { // AuthHeader result = new AuthHeader(); // // String toEncode = clientId + ":" + clientSecret; // String ulrEncoded = URLEncoder.encode(toEncode, "UTF-8"); // String base64 = "Basic " + Base64.getEncoder().encodeToString(ulrEncoded.getBytes()); // // result.setAuhorization(base64); // // return result; // // } catch (UnsupportedEncodingException e) { // throw new IllegalStateException(e.getMessage()); // } // } // // public static AuthHeader build(String accessToken) { // AuthHeader result = new AuthHeader(); // result.setAuhorization("Bearer " + accessToken); // // return result; // } // // } // Path: apache-http-client/src/main/java/cz/gopay/api/v3/impl/apacheclient/HttpClientAuthClientImpl.java import cz.gopay.api.v3.AuthClient; import cz.gopay.api.v3.model.access.AccessToken; import cz.gopay.api.v3.model.access.AuthHeader; import java.io.IOException; import javax.ws.rs.WebApplicationException; import org.apache.http.client.fluent.Form; import org.apache.http.client.fluent.Request; import org.apache.http.client.fluent.Response; import org.apache.http.entity.ContentType; import org.apache.logging.log4j.LogManager; /* * To change this license header, choose License Headers in Project Properties. To change this * template file, choose Tools | Templates and open the template in the editor. */ package cz.gopay.api.v3.impl.apacheclient; public class HttpClientAuthClientImpl extends AbstractImpl implements AuthClient { protected HttpClientAuthClientImpl(String apiUrl) { super(apiUrl); super.logger = LogManager.getLogger(HttpClientAuthClientImpl.class); } @Override
public AccessToken loginApplication(AuthHeader authHeader, String grantType, String scope) {
gopaycommunity/gopay-java-api
apache-http-client/src/main/java/cz/gopay/api/v3/impl/apacheclient/HttpClientAuthClientImpl.java
// Path: common/src/main/java/cz/gopay/api/v3/AuthClient.java // public interface AuthClient { // // @POST // @Path("/oauth2/token") // @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) // @Consumes(MediaType.APPLICATION_FORM_URLENCODED) // AccessToken loginApplication(@BeanParam AuthHeader authHeader, // @FormParam(value = "grant_type") String grantType, // @FormParam(value = "scope") String scope); // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AccessToken.java // @XmlRootElement // @XmlAccessorType(XmlAccessType.FIELD) // public class AccessToken { // // @XmlElement(name = "token_type") // private String tokenType; // // @XmlElement(name = "access_token") // private String accessToken; // // @XmlElement(name = "refresh_token") // private String refreshToken; // // @XmlElement(name = "expires_in") // private long expiresIn; // // public AccessToken() { // } // // public AccessToken(String tokenType, String accessToken, String refreshToken, // long expiresIn) { // this.tokenType = tokenType; // this.accessToken = accessToken; // this.refreshToken = refreshToken; // this.expiresIn = expiresIn; // } // // public String getTokenType() { // return tokenType; // } // // public void setTokenType(String tokenType) { // this.tokenType = tokenType; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public long getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(long expiresIn) { // this.expiresIn = expiresIn; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AuthHeader.java // @XmlAccessorType(XmlAccessType.FIELD) // public class AuthHeader { // // @HeaderParam(value = "Authorization") // private String auhorization; // // public String getAuhorization() { // return auhorization; // } // // public void setAuhorization(String auhorization) { // this.auhorization = auhorization; // } // // @Override // public String toString() { // return "AuthHeader [authorization=" + auhorization + "]"; // } // // public static AuthHeader build(String clientId, String clientSecret) { // try { // AuthHeader result = new AuthHeader(); // // String toEncode = clientId + ":" + clientSecret; // String ulrEncoded = URLEncoder.encode(toEncode, "UTF-8"); // String base64 = "Basic " + Base64.getEncoder().encodeToString(ulrEncoded.getBytes()); // // result.setAuhorization(base64); // // return result; // // } catch (UnsupportedEncodingException e) { // throw new IllegalStateException(e.getMessage()); // } // } // // public static AuthHeader build(String accessToken) { // AuthHeader result = new AuthHeader(); // result.setAuhorization("Bearer " + accessToken); // // return result; // } // // }
import cz.gopay.api.v3.AuthClient; import cz.gopay.api.v3.model.access.AccessToken; import cz.gopay.api.v3.model.access.AuthHeader; import java.io.IOException; import javax.ws.rs.WebApplicationException; import org.apache.http.client.fluent.Form; import org.apache.http.client.fluent.Request; import org.apache.http.client.fluent.Response; import org.apache.http.entity.ContentType; import org.apache.logging.log4j.LogManager;
/* * To change this license header, choose License Headers in Project Properties. To change this * template file, choose Tools | Templates and open the template in the editor. */ package cz.gopay.api.v3.impl.apacheclient; public class HttpClientAuthClientImpl extends AbstractImpl implements AuthClient { protected HttpClientAuthClientImpl(String apiUrl) { super(apiUrl); super.logger = LogManager.getLogger(HttpClientAuthClientImpl.class); } @Override
// Path: common/src/main/java/cz/gopay/api/v3/AuthClient.java // public interface AuthClient { // // @POST // @Path("/oauth2/token") // @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) // @Consumes(MediaType.APPLICATION_FORM_URLENCODED) // AccessToken loginApplication(@BeanParam AuthHeader authHeader, // @FormParam(value = "grant_type") String grantType, // @FormParam(value = "scope") String scope); // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AccessToken.java // @XmlRootElement // @XmlAccessorType(XmlAccessType.FIELD) // public class AccessToken { // // @XmlElement(name = "token_type") // private String tokenType; // // @XmlElement(name = "access_token") // private String accessToken; // // @XmlElement(name = "refresh_token") // private String refreshToken; // // @XmlElement(name = "expires_in") // private long expiresIn; // // public AccessToken() { // } // // public AccessToken(String tokenType, String accessToken, String refreshToken, // long expiresIn) { // this.tokenType = tokenType; // this.accessToken = accessToken; // this.refreshToken = refreshToken; // this.expiresIn = expiresIn; // } // // public String getTokenType() { // return tokenType; // } // // public void setTokenType(String tokenType) { // this.tokenType = tokenType; // } // // public String getAccessToken() { // return accessToken; // } // // public void setAccessToken(String accessToken) { // this.accessToken = accessToken; // } // // public String getRefreshToken() { // return refreshToken; // } // // public void setRefreshToken(String refreshToken) { // this.refreshToken = refreshToken; // } // // public long getExpiresIn() { // return expiresIn; // } // // public void setExpiresIn(long expiresIn) { // this.expiresIn = expiresIn; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/model/access/AuthHeader.java // @XmlAccessorType(XmlAccessType.FIELD) // public class AuthHeader { // // @HeaderParam(value = "Authorization") // private String auhorization; // // public String getAuhorization() { // return auhorization; // } // // public void setAuhorization(String auhorization) { // this.auhorization = auhorization; // } // // @Override // public String toString() { // return "AuthHeader [authorization=" + auhorization + "]"; // } // // public static AuthHeader build(String clientId, String clientSecret) { // try { // AuthHeader result = new AuthHeader(); // // String toEncode = clientId + ":" + clientSecret; // String ulrEncoded = URLEncoder.encode(toEncode, "UTF-8"); // String base64 = "Basic " + Base64.getEncoder().encodeToString(ulrEncoded.getBytes()); // // result.setAuhorization(base64); // // return result; // // } catch (UnsupportedEncodingException e) { // throw new IllegalStateException(e.getMessage()); // } // } // // public static AuthHeader build(String accessToken) { // AuthHeader result = new AuthHeader(); // result.setAuhorization("Bearer " + accessToken); // // return result; // } // // } // Path: apache-http-client/src/main/java/cz/gopay/api/v3/impl/apacheclient/HttpClientAuthClientImpl.java import cz.gopay.api.v3.AuthClient; import cz.gopay.api.v3.model.access.AccessToken; import cz.gopay.api.v3.model.access.AuthHeader; import java.io.IOException; import javax.ws.rs.WebApplicationException; import org.apache.http.client.fluent.Form; import org.apache.http.client.fluent.Request; import org.apache.http.client.fluent.Response; import org.apache.http.entity.ContentType; import org.apache.logging.log4j.LogManager; /* * To change this license header, choose License Headers in Project Properties. To change this * template file, choose Tools | Templates and open the template in the editor. */ package cz.gopay.api.v3.impl.apacheclient; public class HttpClientAuthClientImpl extends AbstractImpl implements AuthClient { protected HttpClientAuthClientImpl(String apiUrl) { super(apiUrl); super.logger = LogManager.getLogger(HttpClientAuthClientImpl.class); } @Override
public AccessToken loginApplication(AuthHeader authHeader, String grantType, String scope) {
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/payment/support/AccountStatement.java
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/common/StatementGeneratingFormat.java // public enum StatementGeneratingFormat { // XLS_A(ContentType.TYPE_XLS), // XLS_B(ContentType.TYPE_XLS), // XLS_C(ContentType.TYPE_XLS), // CSV_A(ContentType.TYPE_CSV), // CSV_B(ContentType.TYPE_CSV), // CSV_C(ContentType.TYPE_CSV), // CSV_D(ContentType.TYPE_CSV), // ABO_A(ContentType.TYPE_ABO); // // private final String contentType; // // private StatementGeneratingFormat(String contentType) { // this.contentType = contentType; // } // // public String getContentType() { // return contentType; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // }
import cz.gopay.api.v3.model.common.Currency; import cz.gopay.api.v3.model.common.StatementGeneratingFormat; import cz.gopay.api.v3.util.GPDateAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
package cz.gopay.api.v3.model.payment.support; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class AccountStatement { @XmlElement(name="date_from")
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/common/StatementGeneratingFormat.java // public enum StatementGeneratingFormat { // XLS_A(ContentType.TYPE_XLS), // XLS_B(ContentType.TYPE_XLS), // XLS_C(ContentType.TYPE_XLS), // CSV_A(ContentType.TYPE_CSV), // CSV_B(ContentType.TYPE_CSV), // CSV_C(ContentType.TYPE_CSV), // CSV_D(ContentType.TYPE_CSV), // ABO_A(ContentType.TYPE_ABO); // // private final String contentType; // // private StatementGeneratingFormat(String contentType) { // this.contentType = contentType; // } // // public String getContentType() { // return contentType; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/payment/support/AccountStatement.java import cz.gopay.api.v3.model.common.Currency; import cz.gopay.api.v3.model.common.StatementGeneratingFormat; import cz.gopay.api.v3.util.GPDateAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; package cz.gopay.api.v3.model.payment.support; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class AccountStatement { @XmlElement(name="date_from")
@XmlJavaTypeAdapter(GPDateAdapter.class)
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/payment/support/AccountStatement.java
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/common/StatementGeneratingFormat.java // public enum StatementGeneratingFormat { // XLS_A(ContentType.TYPE_XLS), // XLS_B(ContentType.TYPE_XLS), // XLS_C(ContentType.TYPE_XLS), // CSV_A(ContentType.TYPE_CSV), // CSV_B(ContentType.TYPE_CSV), // CSV_C(ContentType.TYPE_CSV), // CSV_D(ContentType.TYPE_CSV), // ABO_A(ContentType.TYPE_ABO); // // private final String contentType; // // private StatementGeneratingFormat(String contentType) { // this.contentType = contentType; // } // // public String getContentType() { // return contentType; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // }
import cz.gopay.api.v3.model.common.Currency; import cz.gopay.api.v3.model.common.StatementGeneratingFormat; import cz.gopay.api.v3.util.GPDateAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
package cz.gopay.api.v3.model.payment.support; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class AccountStatement { @XmlElement(name="date_from") @XmlJavaTypeAdapter(GPDateAdapter.class) private Date dateFrom; @XmlElement(name="date_to") @XmlJavaTypeAdapter(GPDateAdapter.class) private Date dateTo; @XmlElement(name="goid") private Long goID; @XmlElement(name="currency")
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/common/StatementGeneratingFormat.java // public enum StatementGeneratingFormat { // XLS_A(ContentType.TYPE_XLS), // XLS_B(ContentType.TYPE_XLS), // XLS_C(ContentType.TYPE_XLS), // CSV_A(ContentType.TYPE_CSV), // CSV_B(ContentType.TYPE_CSV), // CSV_C(ContentType.TYPE_CSV), // CSV_D(ContentType.TYPE_CSV), // ABO_A(ContentType.TYPE_ABO); // // private final String contentType; // // private StatementGeneratingFormat(String contentType) { // this.contentType = contentType; // } // // public String getContentType() { // return contentType; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/payment/support/AccountStatement.java import cz.gopay.api.v3.model.common.Currency; import cz.gopay.api.v3.model.common.StatementGeneratingFormat; import cz.gopay.api.v3.util.GPDateAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; package cz.gopay.api.v3.model.payment.support; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class AccountStatement { @XmlElement(name="date_from") @XmlJavaTypeAdapter(GPDateAdapter.class) private Date dateFrom; @XmlElement(name="date_to") @XmlJavaTypeAdapter(GPDateAdapter.class) private Date dateTo; @XmlElement(name="goid") private Long goID; @XmlElement(name="currency")
private Currency currency;
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/payment/support/AccountStatement.java
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/common/StatementGeneratingFormat.java // public enum StatementGeneratingFormat { // XLS_A(ContentType.TYPE_XLS), // XLS_B(ContentType.TYPE_XLS), // XLS_C(ContentType.TYPE_XLS), // CSV_A(ContentType.TYPE_CSV), // CSV_B(ContentType.TYPE_CSV), // CSV_C(ContentType.TYPE_CSV), // CSV_D(ContentType.TYPE_CSV), // ABO_A(ContentType.TYPE_ABO); // // private final String contentType; // // private StatementGeneratingFormat(String contentType) { // this.contentType = contentType; // } // // public String getContentType() { // return contentType; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // }
import cz.gopay.api.v3.model.common.Currency; import cz.gopay.api.v3.model.common.StatementGeneratingFormat; import cz.gopay.api.v3.util.GPDateAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
package cz.gopay.api.v3.model.payment.support; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class AccountStatement { @XmlElement(name="date_from") @XmlJavaTypeAdapter(GPDateAdapter.class) private Date dateFrom; @XmlElement(name="date_to") @XmlJavaTypeAdapter(GPDateAdapter.class) private Date dateTo; @XmlElement(name="goid") private Long goID; @XmlElement(name="currency") private Currency currency;
// Path: common/src/main/java/cz/gopay/api/v3/model/common/Currency.java // public enum Currency { // CZK(203), // EUR(978), // PLN(985), // HUF(348), // USD(840), // GBP(826), // BGN(975), // HRK(191), // RON(946); // // public static final String CODE_CZK = String.valueOf(CZK); // public static final String CODE_EUR = String.valueOf(EUR); // public static final String CODE_PLN = String.valueOf(PLN); // public static final String CODE_HUF = String.valueOf(HUF); // public static final String CODE_USD = String.valueOf(USD); // public static final String CODE_GBP = String.valueOf(GBP); // public static final String CODE_BGN = String.valueOf(BGN); // public static final String CODE_HRK = String.valueOf(HRK); // public static final String CODE_RON = String.valueOf(RON); // // private Integer numericalCode; // // private Currency(Integer numericalCode) { // this.numericalCode = numericalCode; // } // // public Integer getNumericalCode() { // return numericalCode; // } // // public String getCode() { // return String.valueOf(this); // } // // public void setNumericalCode(int numericalCode) { // this.numericalCode = numericalCode; // } // // public static Currency getByCode(String code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (String.valueOf(item).equals(code)) { // result = item; // break; // } // } // return result; // } // // public static Currency getByNumericalCode(Integer code) { // Currency result = null; // for (Currency item : EnumSet.allOf(Currency.class)) { // if (item.getNumericalCode().equals(code)) { // result = item; // break; // } // } // // return result; // } // // } // // Path: common/src/main/java/cz/gopay/api/v3/model/common/StatementGeneratingFormat.java // public enum StatementGeneratingFormat { // XLS_A(ContentType.TYPE_XLS), // XLS_B(ContentType.TYPE_XLS), // XLS_C(ContentType.TYPE_XLS), // CSV_A(ContentType.TYPE_CSV), // CSV_B(ContentType.TYPE_CSV), // CSV_C(ContentType.TYPE_CSV), // CSV_D(ContentType.TYPE_CSV), // ABO_A(ContentType.TYPE_ABO); // // private final String contentType; // // private StatementGeneratingFormat(String contentType) { // this.contentType = contentType; // } // // public String getContentType() { // return contentType; // } // } // // Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/payment/support/AccountStatement.java import cz.gopay.api.v3.model.common.Currency; import cz.gopay.api.v3.model.common.StatementGeneratingFormat; import cz.gopay.api.v3.util.GPDateAdapter; import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; package cz.gopay.api.v3.model.payment.support; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class AccountStatement { @XmlElement(name="date_from") @XmlJavaTypeAdapter(GPDateAdapter.class) private Date dateFrom; @XmlElement(name="date_to") @XmlJavaTypeAdapter(GPDateAdapter.class) private Date dateTo; @XmlElement(name="goid") private Long goID; @XmlElement(name="currency") private Currency currency;
private StatementGeneratingFormat format;
gopaycommunity/gopay-java-api
apache-http-client/src/test/java/cz/gopay/cfx/ApacheHttpClientPaymentTest.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-http-client/src/main/java-templates/cz/gopay/api/v3/impl/apacheclient/HttpClientGPConnector.java // public class HttpClientGPConnector extends AbstractGPConnector { // // public static HttpClientGPConnector build(String apiUrl) { // return new HttpClientGPConnector(apiUrl); // } // // private HttpClientGPConnector(String apiUrl) { // super(apiUrl); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // if (proxy == AuthClient.class) { // return (T) new HttpClientAuthClientImpl(apiUrl); // } else if (proxy == PaymentClient.class) { // return (T) new HttpClientPaymentClientImpl(apiUrl); // } // throw new IllegalArgumentException("Unknown interface"); // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/PaymentTest.java // public abstract class PaymentTest extends AbstractPaymentTests { // // @Test // public void testHttpClientCreatePayment() { // testConnectorCreatePayment(getConnector()); // } // // @Test // public void testHttpClientPaymentRecurrency() { // testPaymentRecurrency(getConnector()); // } // // @Test // public void testHttpClientPaymentStataus() { // testPaymentStatus(getConnector()); // } // // @Test // public void testHttpClientPaymentPreAuthorization() { // testPaymentPreAuthorization(getConnector()); // } // // //@Test // public void testHttpClientVoidAuthorization() { // testPaymentVoidAuthorization(getConnector()); // } // // //@Test // public void testPaymentRefund() { // testPaymentRefund(getConnector()); // } // // // // @Test // public void testEETREceiptFindByFilter() { // testEETREceiptFindByFilter(getConnector()); // } // // // @Test // public void testEETReceiptFindByPayment() { // testEETReceiptFindByPayment(getConnector()); // } // // // @Test // public void testPaymentInstrumentRoot(){ // testPaymentInstrumentRoot(getConnector()); // } // // @Test // public void testGenerateStatementHttp() { // testGenerateStatement(getConnector()); // } // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.apacheclient.HttpClientGPConnector; import test.utils.PaymentTest; import test.utils.TestUtils;
package cz.gopay.cfx; public class ApacheHttpClientPaymentTest extends PaymentTest { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-http-client/src/main/java-templates/cz/gopay/api/v3/impl/apacheclient/HttpClientGPConnector.java // public class HttpClientGPConnector extends AbstractGPConnector { // // public static HttpClientGPConnector build(String apiUrl) { // return new HttpClientGPConnector(apiUrl); // } // // private HttpClientGPConnector(String apiUrl) { // super(apiUrl); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // if (proxy == AuthClient.class) { // return (T) new HttpClientAuthClientImpl(apiUrl); // } else if (proxy == PaymentClient.class) { // return (T) new HttpClientPaymentClientImpl(apiUrl); // } // throw new IllegalArgumentException("Unknown interface"); // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/PaymentTest.java // public abstract class PaymentTest extends AbstractPaymentTests { // // @Test // public void testHttpClientCreatePayment() { // testConnectorCreatePayment(getConnector()); // } // // @Test // public void testHttpClientPaymentRecurrency() { // testPaymentRecurrency(getConnector()); // } // // @Test // public void testHttpClientPaymentStataus() { // testPaymentStatus(getConnector()); // } // // @Test // public void testHttpClientPaymentPreAuthorization() { // testPaymentPreAuthorization(getConnector()); // } // // //@Test // public void testHttpClientVoidAuthorization() { // testPaymentVoidAuthorization(getConnector()); // } // // //@Test // public void testPaymentRefund() { // testPaymentRefund(getConnector()); // } // // // // @Test // public void testEETREceiptFindByFilter() { // testEETREceiptFindByFilter(getConnector()); // } // // // @Test // public void testEETReceiptFindByPayment() { // testEETReceiptFindByPayment(getConnector()); // } // // // @Test // public void testPaymentInstrumentRoot(){ // testPaymentInstrumentRoot(getConnector()); // } // // @Test // public void testGenerateStatementHttp() { // testGenerateStatement(getConnector()); // } // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: apache-http-client/src/test/java/cz/gopay/cfx/ApacheHttpClientPaymentTest.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.apacheclient.HttpClientGPConnector; import test.utils.PaymentTest; import test.utils.TestUtils; package cz.gopay.cfx; public class ApacheHttpClientPaymentTest extends PaymentTest { public IGPConnector getConnector() {
return HttpClientGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
apache-http-client/src/test/java/cz/gopay/cfx/ApacheHttpClientPaymentTest.java
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-http-client/src/main/java-templates/cz/gopay/api/v3/impl/apacheclient/HttpClientGPConnector.java // public class HttpClientGPConnector extends AbstractGPConnector { // // public static HttpClientGPConnector build(String apiUrl) { // return new HttpClientGPConnector(apiUrl); // } // // private HttpClientGPConnector(String apiUrl) { // super(apiUrl); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // if (proxy == AuthClient.class) { // return (T) new HttpClientAuthClientImpl(apiUrl); // } else if (proxy == PaymentClient.class) { // return (T) new HttpClientPaymentClientImpl(apiUrl); // } // throw new IllegalArgumentException("Unknown interface"); // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/PaymentTest.java // public abstract class PaymentTest extends AbstractPaymentTests { // // @Test // public void testHttpClientCreatePayment() { // testConnectorCreatePayment(getConnector()); // } // // @Test // public void testHttpClientPaymentRecurrency() { // testPaymentRecurrency(getConnector()); // } // // @Test // public void testHttpClientPaymentStataus() { // testPaymentStatus(getConnector()); // } // // @Test // public void testHttpClientPaymentPreAuthorization() { // testPaymentPreAuthorization(getConnector()); // } // // //@Test // public void testHttpClientVoidAuthorization() { // testPaymentVoidAuthorization(getConnector()); // } // // //@Test // public void testPaymentRefund() { // testPaymentRefund(getConnector()); // } // // // // @Test // public void testEETREceiptFindByFilter() { // testEETREceiptFindByFilter(getConnector()); // } // // // @Test // public void testEETReceiptFindByPayment() { // testEETReceiptFindByPayment(getConnector()); // } // // // @Test // public void testPaymentInstrumentRoot(){ // testPaymentInstrumentRoot(getConnector()); // } // // @Test // public void testGenerateStatementHttp() { // testGenerateStatement(getConnector()); // } // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // }
import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.apacheclient.HttpClientGPConnector; import test.utils.PaymentTest; import test.utils.TestUtils;
package cz.gopay.cfx; public class ApacheHttpClientPaymentTest extends PaymentTest { public IGPConnector getConnector() {
// Path: common/src/main/java/cz/gopay/api/v3/IGPConnector.java // public interface IGPConnector { // // IGPConnector getAppToken(String clientId, String clientCredentials) throws GPClientException; // // IGPConnector getAppToken(String clientId, String clientCredentials, // String scope) throws GPClientException; // // Payment createPayment(BasePayment payment) throws GPClientException; // // PaymentResult refundPayment(Long id, Long amount) throws GPClientException; // // Payment createRecurrentPayment(Long id, NextPayment nextPayment) throws GPClientException; // // PaymentResult voidRecurrency(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id) throws GPClientException; // // PaymentResult capturePayment(Long id, CapturePayment capturePayment) throws GPClientException; // // PaymentResult voidAuthorization(Long id) throws GPClientException; // // Payment paymentStatus(Long id) throws GPClientException; // // PaymentResult refundPayment(Long id, RefundPayment refundPayment) throws GPClientException; // // List<EETReceipt> findEETREceiptsByFilter(EETReceiptFilter filter) throws GPClientException; // // PaymentInstrumentRoot generatePaymentInstruments(Long goId, Currency currency) throws GPClientException; // // List<EETReceipt> getEETReceiptByPaymentId(Long id) throws GPClientException; // // byte[] generateStatement(AccountStatement accountStatement) throws GPClientException; // // String getApiUrl(); // // AccessToken getAccessToken(); // // void setAccessToken(AccessToken accessToken); // } // // Path: apache-http-client/src/main/java-templates/cz/gopay/api/v3/impl/apacheclient/HttpClientGPConnector.java // public class HttpClientGPConnector extends AbstractGPConnector { // // public static HttpClientGPConnector build(String apiUrl) { // return new HttpClientGPConnector(apiUrl); // } // // private HttpClientGPConnector(String apiUrl) { // super(apiUrl); // } // // @Override // protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { // if (proxy == AuthClient.class) { // return (T) new HttpClientAuthClientImpl(apiUrl); // } else if (proxy == PaymentClient.class) { // return (T) new HttpClientPaymentClientImpl(apiUrl); // } // throw new IllegalArgumentException("Unknown interface"); // } // // @Override // protected String getImplementationName() { // return "${project.artifactId}"; // } // } // // Path: common-tests/src/main/java/test/utils/PaymentTest.java // public abstract class PaymentTest extends AbstractPaymentTests { // // @Test // public void testHttpClientCreatePayment() { // testConnectorCreatePayment(getConnector()); // } // // @Test // public void testHttpClientPaymentRecurrency() { // testPaymentRecurrency(getConnector()); // } // // @Test // public void testHttpClientPaymentStataus() { // testPaymentStatus(getConnector()); // } // // @Test // public void testHttpClientPaymentPreAuthorization() { // testPaymentPreAuthorization(getConnector()); // } // // //@Test // public void testHttpClientVoidAuthorization() { // testPaymentVoidAuthorization(getConnector()); // } // // //@Test // public void testPaymentRefund() { // testPaymentRefund(getConnector()); // } // // // // @Test // public void testEETREceiptFindByFilter() { // testEETREceiptFindByFilter(getConnector()); // } // // // @Test // public void testEETReceiptFindByPayment() { // testEETReceiptFindByPayment(getConnector()); // } // // // @Test // public void testPaymentInstrumentRoot(){ // testPaymentInstrumentRoot(getConnector()); // } // // @Test // public void testGenerateStatementHttp() { // testGenerateStatement(getConnector()); // } // // } // // Path: common-tests/src/main/java/test/utils/TestUtils.java // public class TestUtils { // // public static final String API_URL = "https://gw.sandbox.gopay.com/api"; // public static final String CLIENT_ID = "1744960415"; // public static final String CLIENT_SECRET = "h9wyRz2s"; // public static final Long GOID = 8339303643L; // // public static final String API_URL = "http://gopay-gw:8180/gp/api"; // // public static final String CLIENT_ID = "app@musicshop.cz"; // // public static final String CLIENT_SECRET = "VpnJVcTn"; // // public static final Long GOID = 8761908826L; // // public static void handleException(GPClientException e, Logger logger) { // List<ErrorElement> errorMessages = e.getErrorMessages(); // StringBuilder builder = new StringBuilder(); // builder.append("E: "); // for (ErrorElement element : errorMessages) { // builder.append(element.getErrorName()).append(", "); // } // logger.fatal(builder.toString()); // Assertions.fail(builder.toString()); // } // } // Path: apache-http-client/src/test/java/cz/gopay/cfx/ApacheHttpClientPaymentTest.java import cz.gopay.api.v3.IGPConnector; import cz.gopay.api.v3.impl.apacheclient.HttpClientGPConnector; import test.utils.PaymentTest; import test.utils.TestUtils; package cz.gopay.cfx; public class ApacheHttpClientPaymentTest extends PaymentTest { public IGPConnector getConnector() {
return HttpClientGPConnector.build(TestUtils.API_URL);
gopaycommunity/gopay-java-api
common/src/main/java/cz/gopay/api/v3/model/payment/support/Recurrence.java
// Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // }
import java.util.Date; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import cz.gopay.api.v3.util.GPDateAdapter;
package cz.gopay.api.v3.model.payment.support; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ @XmlRootElement public class Recurrence { public enum RecurrenceState { REQUESTED, STARTED, STOPPED } @XmlElement(name = "recurrence_cycle") private RecurrenceCycle recurrenceCycle; @XmlElement(name = "recurrence_period") private Integer recurrencePeriod; @XmlElement(name = "recurrence_date_to")
// Path: common/src/main/java/cz/gopay/api/v3/util/GPDateAdapter.java // public class GPDateAdapter extends XmlAdapter<String, Date> { // // private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // // @Override // public String marshal(Date v) throws Exception { // return dateFormat.format(v); // } // // @Override // public Date unmarshal(String v) throws Exception { // return dateFormat.parse(v); // } // // } // Path: common/src/main/java/cz/gopay/api/v3/model/payment/support/Recurrence.java import java.util.Date; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import cz.gopay.api.v3.util.GPDateAdapter; package cz.gopay.api.v3.model.payment.support; /** * * @author Zbynek Novak novak.zbynek@gmail.com * */ @XmlRootElement public class Recurrence { public enum RecurrenceState { REQUESTED, STARTED, STOPPED } @XmlElement(name = "recurrence_cycle") private RecurrenceCycle recurrenceCycle; @XmlElement(name = "recurrence_period") private Integer recurrencePeriod; @XmlElement(name = "recurrence_date_to")
@XmlJavaTypeAdapter(GPDateAdapter.class)
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/ui/fragment/ImageFragment.java
// Path: app/src/main/java/com/github/cchao/touchnews/ui/adapter/ImageFragmentsPagerAdapter.java // public class ImageFragmentsPagerAdapter extends FragmentPagerAdapter { // private List<Fragment> mListFragments = null; // private String[] mTitles = null; // // public ImageFragmentsPagerAdapter(FragmentManager fm, String[] titles, List fragments) { // super(fm); // mListFragments = fragments; // mTitles = titles; // // } // // @Override // public int getCount() { // if (mListFragments != null) { // return mListFragments.size(); // } else { // return 0; // } // } // // @Override // public Fragment getItem(int position) { // if (mListFragments != null && position >= 0 && position < mListFragments.size()) { // return mListFragments.get(position); // } else { // return null; // } // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles[position]; // } // }
import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.ui.adapter.ImageFragmentsPagerAdapter; import java.util.ArrayList; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife;
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_image, null); ButterKnife.bind(this, view); return view; } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setTableLayout(); } private void initData() { mTitles = getResources().getStringArray(R.array.news_titles); mFragments = new ArrayList<>(); for (int i = 0; i < mTitles.length; i++) { Bundle mBundle = new Bundle(); mBundle.putInt("flag", i); // Fragment fragment = new NewsListFragments ( ); // fragment.setArguments ( mBundle ); // mFragments.add ( i, fragment ); } } private void setTableLayout() {
// Path: app/src/main/java/com/github/cchao/touchnews/ui/adapter/ImageFragmentsPagerAdapter.java // public class ImageFragmentsPagerAdapter extends FragmentPagerAdapter { // private List<Fragment> mListFragments = null; // private String[] mTitles = null; // // public ImageFragmentsPagerAdapter(FragmentManager fm, String[] titles, List fragments) { // super(fm); // mListFragments = fragments; // mTitles = titles; // // } // // @Override // public int getCount() { // if (mListFragments != null) { // return mListFragments.size(); // } else { // return 0; // } // } // // @Override // public Fragment getItem(int position) { // if (mListFragments != null && position >= 0 && position < mListFragments.size()) { // return mListFragments.get(position); // } else { // return null; // } // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles[position]; // } // } // Path: app/src/main/java/com/github/cchao/touchnews/ui/fragment/ImageFragment.java import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.ui.adapter.ImageFragmentsPagerAdapter; import java.util.ArrayList; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_image, null); ButterKnife.bind(this, view); return view; } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setTableLayout(); } private void initData() { mTitles = getResources().getStringArray(R.array.news_titles); mFragments = new ArrayList<>(); for (int i = 0; i < mTitles.length; i++) { Bundle mBundle = new Bundle(); mBundle.putInt("flag", i); // Fragment fragment = new NewsListFragments ( ); // fragment.setArguments ( mBundle ); // mFragments.add ( i, fragment ); } } private void setTableLayout() {
mFragmentsPagerAdapter = new ImageFragmentsPagerAdapter(getActivity().getSupportFragmentManager(), mTitles, mFragments);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/contract/NewListDataContract.java
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/news/Contentlist.java // public class Contentlist implements Serializable { // private static final long serialVersionUID = -7060210544600464481L; // private String channelId; // // private String channelName; // // private String desc; // // private List<Imageurls> imageurls; // // private String link; // // private String nid; // // private String pubDate; // // private String source; // // private String title; // // public void setChannelId(String channelId) { // this.channelId = channelId; // } // // public String getChannelId() { // return this.channelId; // } // // public void setChannelName(String channelName) { // this.channelName = channelName; // } // // public String getChannelName() { // return this.channelName; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public String getDesc() { // return this.desc; // } // // public void setImageurls(List<Imageurls> imageurls) { // this.imageurls = imageurls; // } // // public List<Imageurls> getImageurls() { // return this.imageurls; // } // // public void setLink(String link) { // this.link = link; // } // // public String getLink() { // return this.link; // } // // public void setNid(String nid) { // this.nid = nid; // } // // public String getNid() { // return this.nid; // } // // public void setPubDate(String pubDate) { // this.pubDate = pubDate; // } // // public String getPubDate() { // return this.pubDate; // } // // public void setSource(String source) { // this.source = source; // } // // public String getSource() { // return this.source; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // }
import com.github.cchao.touchnews.javaBean.news.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List;
/* * Copyright 2016, The Android Open Source Project * * 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 * * 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. */ package com.github.cchao.touchnews.contract; /** * 绑定News List数据的 view、presenter */ public interface NewListDataContract { interface View { /** * 获取数据 * * @param newsList newsList */
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/news/Contentlist.java // public class Contentlist implements Serializable { // private static final long serialVersionUID = -7060210544600464481L; // private String channelId; // // private String channelName; // // private String desc; // // private List<Imageurls> imageurls; // // private String link; // // private String nid; // // private String pubDate; // // private String source; // // private String title; // // public void setChannelId(String channelId) { // this.channelId = channelId; // } // // public String getChannelId() { // return this.channelId; // } // // public void setChannelName(String channelName) { // this.channelName = channelName; // } // // public String getChannelName() { // return this.channelName; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public String getDesc() { // return this.desc; // } // // public void setImageurls(List<Imageurls> imageurls) { // this.imageurls = imageurls; // } // // public List<Imageurls> getImageurls() { // return this.imageurls; // } // // public void setLink(String link) { // this.link = link; // } // // public String getLink() { // return this.link; // } // // public void setNid(String nid) { // this.nid = nid; // } // // public String getNid() { // return this.nid; // } // // public void setPubDate(String pubDate) { // this.pubDate = pubDate; // } // // public String getPubDate() { // return this.pubDate; // } // // public void setSource(String source) { // this.source = source; // } // // public String getSource() { // return this.source; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // } // Path: app/src/main/java/com/github/cchao/touchnews/contract/NewListDataContract.java import com.github.cchao.touchnews.javaBean.news.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List; /* * Copyright 2016, The Android Open Source Project * * 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 * * 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. */ package com.github.cchao.touchnews.contract; /** * 绑定News List数据的 view、presenter */ public interface NewListDataContract { interface View { /** * 获取数据 * * @param newsList newsList */
void onRefreshData(List<Contentlist> newsList);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/contract/NewListDataContract.java
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/news/Contentlist.java // public class Contentlist implements Serializable { // private static final long serialVersionUID = -7060210544600464481L; // private String channelId; // // private String channelName; // // private String desc; // // private List<Imageurls> imageurls; // // private String link; // // private String nid; // // private String pubDate; // // private String source; // // private String title; // // public void setChannelId(String channelId) { // this.channelId = channelId; // } // // public String getChannelId() { // return this.channelId; // } // // public void setChannelName(String channelName) { // this.channelName = channelName; // } // // public String getChannelName() { // return this.channelName; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public String getDesc() { // return this.desc; // } // // public void setImageurls(List<Imageurls> imageurls) { // this.imageurls = imageurls; // } // // public List<Imageurls> getImageurls() { // return this.imageurls; // } // // public void setLink(String link) { // this.link = link; // } // // public String getLink() { // return this.link; // } // // public void setNid(String nid) { // this.nid = nid; // } // // public String getNid() { // return this.nid; // } // // public void setPubDate(String pubDate) { // this.pubDate = pubDate; // } // // public String getPubDate() { // return this.pubDate; // } // // public void setSource(String source) { // this.source = source; // } // // public String getSource() { // return this.source; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // }
import com.github.cchao.touchnews.javaBean.news.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List;
/* * Copyright 2016, The Android Open Source Project * * 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 * * 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. */ package com.github.cchao.touchnews.contract; /** * 绑定News List数据的 view、presenter */ public interface NewListDataContract { interface View { /** * 获取数据 * * @param newsList newsList */ void onRefreshData(List<Contentlist> newsList); /** * 添加数据 * * @param newsList add newsList */ void onReceiveMoreListData(List<Contentlist> newsList); /** * 显示信息 e.g. 没有网络、正在加载、异常 * * @param INFOType 枚举值 * @param infoText 提示的文本内容 * @see Constant.INFO_TYPE */
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/news/Contentlist.java // public class Contentlist implements Serializable { // private static final long serialVersionUID = -7060210544600464481L; // private String channelId; // // private String channelName; // // private String desc; // // private List<Imageurls> imageurls; // // private String link; // // private String nid; // // private String pubDate; // // private String source; // // private String title; // // public void setChannelId(String channelId) { // this.channelId = channelId; // } // // public String getChannelId() { // return this.channelId; // } // // public void setChannelName(String channelName) { // this.channelName = channelName; // } // // public String getChannelName() { // return this.channelName; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public String getDesc() { // return this.desc; // } // // public void setImageurls(List<Imageurls> imageurls) { // this.imageurls = imageurls; // } // // public List<Imageurls> getImageurls() { // return this.imageurls; // } // // public void setLink(String link) { // this.link = link; // } // // public String getLink() { // return this.link; // } // // public void setNid(String nid) { // this.nid = nid; // } // // public String getNid() { // return this.nid; // } // // public void setPubDate(String pubDate) { // this.pubDate = pubDate; // } // // public String getPubDate() { // return this.pubDate; // } // // public void setSource(String source) { // this.source = source; // } // // public String getSource() { // return this.source; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // } // Path: app/src/main/java/com/github/cchao/touchnews/contract/NewListDataContract.java import com.github.cchao.touchnews.javaBean.news.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List; /* * Copyright 2016, The Android Open Source Project * * 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 * * 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. */ package com.github.cchao.touchnews.contract; /** * 绑定News List数据的 view、presenter */ public interface NewListDataContract { interface View { /** * 获取数据 * * @param newsList newsList */ void onRefreshData(List<Contentlist> newsList); /** * 添加数据 * * @param newsList add newsList */ void onReceiveMoreListData(List<Contentlist> newsList); /** * 显示信息 e.g. 没有网络、正在加载、异常 * * @param INFOType 枚举值 * @param infoText 提示的文本内容 * @see Constant.INFO_TYPE */
void showInfo(Constant.INFO_TYPE INFOType, String infoText);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/ui/fragment/ImageContainerFragment.java
// Path: app/src/main/java/com/github/cchao/touchnews/ui/adapter/ImageFragmentsPagerAdapter.java // public class ImageFragmentsPagerAdapter extends FragmentPagerAdapter { // private List<Fragment> mListFragments = null; // private String[] mTitles = null; // // public ImageFragmentsPagerAdapter(FragmentManager fm, String[] titles, List fragments) { // super(fm); // mListFragments = fragments; // mTitles = titles; // // } // // @Override // public int getCount() { // if (mListFragments != null) { // return mListFragments.size(); // } else { // return 0; // } // } // // @Override // public Fragment getItem(int position) { // if (mListFragments != null && position >= 0 && position < mListFragments.size()) { // return mListFragments.get(position); // } else { // return null; // } // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles[position]; // } // }
import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.ui.adapter.ImageFragmentsPagerAdapter; import java.util.ArrayList; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife;
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_image, null); ButterKnife.bind(this, view); return view; } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setTableLayout(); } private void initData() { mTitles = getResources().getStringArray(R.array.news_titles); mFragments = new ArrayList<>(); for (int i = 0; i < mTitles.length; i++) { Bundle mBundle = new Bundle(); mBundle.putInt("flag", i); // Fragment fragment = new NewsListFragments ( ); // fragment.setArguments ( mBundle ); // mFragments.add ( i, fragment ); } } private void setTableLayout() {
// Path: app/src/main/java/com/github/cchao/touchnews/ui/adapter/ImageFragmentsPagerAdapter.java // public class ImageFragmentsPagerAdapter extends FragmentPagerAdapter { // private List<Fragment> mListFragments = null; // private String[] mTitles = null; // // public ImageFragmentsPagerAdapter(FragmentManager fm, String[] titles, List fragments) { // super(fm); // mListFragments = fragments; // mTitles = titles; // // } // // @Override // public int getCount() { // if (mListFragments != null) { // return mListFragments.size(); // } else { // return 0; // } // } // // @Override // public Fragment getItem(int position) { // if (mListFragments != null && position >= 0 && position < mListFragments.size()) { // return mListFragments.get(position); // } else { // return null; // } // } // // @Override // public CharSequence getPageTitle(int position) { // return mTitles[position]; // } // } // Path: app/src/main/java/com/github/cchao/touchnews/ui/fragment/ImageContainerFragment.java import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.ui.adapter.ImageFragmentsPagerAdapter; import java.util.ArrayList; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.fragment_image, null); ButterKnife.bind(this, view); return view; } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setTableLayout(); } private void initData() { mTitles = getResources().getStringArray(R.array.news_titles); mFragments = new ArrayList<>(); for (int i = 0; i < mTitles.length; i++) { Bundle mBundle = new Bundle(); mBundle.putInt("flag", i); // Fragment fragment = new NewsListFragments ( ); // fragment.setArguments ( mBundle ); // mFragments.add ( i, fragment ); } } private void setTableLayout() {
mFragmentsPagerAdapter = new ImageFragmentsPagerAdapter(getActivity().getSupportFragmentManager(), mTitles, mFragments);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/di/component/AppComponent.java
// Path: app/src/main/java/com/github/cchao/touchnews/di/module/ApiModule.java // @Module // public class ApiModule { // /** // * @param baseUrl baseUrl // * @return Retrofit 对象 // */ // private Retrofit getApiService(@NonNull String baseUrl) { // return new Retrofit.Builder() // .addConverterFactory(GsonConverterFactory.create()) // .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) // .baseUrl(baseUrl) // .build(); // } // // /** // * @return 百度的api接口 // */ // @Singleton // @Provides // protected BaiDuApiService provideBaiDuApiService() { // return getApiService(UrlUtil.API_BAI_DU).create(BaiDuApiService.class); // } // } // // Path: app/src/main/java/com/github/cchao/touchnews/di/module/AppModule.java // @Module // public final class AppModule { // // private Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // public Application provideApplication() { // return application; // } // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/BaiDuApiService.java // public interface BaiDuApiService { // //新闻api // @GET("showapi_open_bus/channel_news/search_news") // Observable<NewsItemRoot> getNews(@Header("apikey") String apikey, @Query("channelId") String channelID, @Query("page") String // page); // // //笑话集 // @GET("showapi_open_bus/showapi_joke/joke_text") // Observable<JokeTextRoot> getJokeText(@Header("apikey") String apikey, @Query("page") String page); // // //笑话集 // @GET("showapi_open_bus/showapi_joke/joke_pic") // Observable<JokeImageRoot> getJokeImage(@Header("apikey") String apikey, @Query("page") String page); // // //响应根据关键字获取的歌曲列表 // @GET("geekery/music/query") // Observable<MusicInfoRoot> getMusicList(@Header("apikey") String apikey, @Query("s") String s); // // //获取Music播放地址 // @GET("geekery/music/playinfo") // Observable<MusicPathRoot> getMusicPath(@Header("apikey") String apikey, @Query("hash") String hash); // // //歌手信息 // @GET("geekery/music/singer") // Observable<MusicSingerRoot> getSinger(@Header("apikey") String apikey, @Query("name") String name); // // // }
import com.github.cchao.touchnews.di.module.ApiModule; import com.github.cchao.touchnews.di.module.AppModule; import com.github.cchao.touchnews.util.BaiDuApiService; import javax.inject.Singleton; import dagger.Component;
package com.github.cchao.touchnews.di.component; /** * Created by cchao on 2016/8/23. * E-mail: cchao1024@163.com * Description: application */ @Singleton @Component(modules = {AppModule.class, ApiModule.class}) public interface AppComponent {
// Path: app/src/main/java/com/github/cchao/touchnews/di/module/ApiModule.java // @Module // public class ApiModule { // /** // * @param baseUrl baseUrl // * @return Retrofit 对象 // */ // private Retrofit getApiService(@NonNull String baseUrl) { // return new Retrofit.Builder() // .addConverterFactory(GsonConverterFactory.create()) // .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) // .baseUrl(baseUrl) // .build(); // } // // /** // * @return 百度的api接口 // */ // @Singleton // @Provides // protected BaiDuApiService provideBaiDuApiService() { // return getApiService(UrlUtil.API_BAI_DU).create(BaiDuApiService.class); // } // } // // Path: app/src/main/java/com/github/cchao/touchnews/di/module/AppModule.java // @Module // public final class AppModule { // // private Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // public Application provideApplication() { // return application; // } // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/BaiDuApiService.java // public interface BaiDuApiService { // //新闻api // @GET("showapi_open_bus/channel_news/search_news") // Observable<NewsItemRoot> getNews(@Header("apikey") String apikey, @Query("channelId") String channelID, @Query("page") String // page); // // //笑话集 // @GET("showapi_open_bus/showapi_joke/joke_text") // Observable<JokeTextRoot> getJokeText(@Header("apikey") String apikey, @Query("page") String page); // // //笑话集 // @GET("showapi_open_bus/showapi_joke/joke_pic") // Observable<JokeImageRoot> getJokeImage(@Header("apikey") String apikey, @Query("page") String page); // // //响应根据关键字获取的歌曲列表 // @GET("geekery/music/query") // Observable<MusicInfoRoot> getMusicList(@Header("apikey") String apikey, @Query("s") String s); // // //获取Music播放地址 // @GET("geekery/music/playinfo") // Observable<MusicPathRoot> getMusicPath(@Header("apikey") String apikey, @Query("hash") String hash); // // //歌手信息 // @GET("geekery/music/singer") // Observable<MusicSingerRoot> getSinger(@Header("apikey") String apikey, @Query("name") String name); // // // } // Path: app/src/main/java/com/github/cchao/touchnews/di/component/AppComponent.java import com.github.cchao.touchnews.di.module.ApiModule; import com.github.cchao.touchnews.di.module.AppModule; import com.github.cchao.touchnews.util.BaiDuApiService; import javax.inject.Singleton; import dagger.Component; package com.github.cchao.touchnews.di.component; /** * Created by cchao on 2016/8/23. * E-mail: cchao1024@163.com * Description: application */ @Singleton @Component(modules = {AppModule.class, ApiModule.class}) public interface AppComponent {
BaiDuApiService getBaiDuApiService();
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/util/NetRequestUtil.java
// Path: app/src/main/java/com/github/cchao/touchnews/BaseApplication.java // public class BaseApplication extends Application { // public static BaiDuApiService mBaiDuApiService; // public static AppComponent mAppComponent; // private static Application mApplication; // // public static AppComponent getAppComponent() { // mBaiDuApiService = mAppComponent.getBaiDuApiService(); // return mAppComponent; // } // // public static Context getContext() { // return mApplication; // } // // @Override // public void onCreate() { // super.onCreate(); // setupLogUtils(); // setupComponent(); // mApplication = this; // MobclickAgent.startWithConfigure(new MobclickAgent.UMAnalyticsConfig(this, "5739942de0f55a0b3c001aab", "APP0")); // } // // /** // * 设置LogUtil // */ // private void setupLogUtils() { // LogUtils.getLogConfig() // .configAllowLog(true) // .configTagPrefix("TouchNews") // .configShowBorders(true) // .configLevel(LogLevel.TYPE_VERBOSE); // } // // /** // * 设置AppComponent // */ // private void setupComponent() { // mAppComponent = DaggerAppComponent.builder() // .appModule(new AppModule(this)) // .apiModule(new ApiModule()) // .build(); // mBaiDuApiService = mAppComponent.getBaiDuApiService(); // // } // // @Override // public void onLowMemory() { // super.onLowMemory(); // } // // @Override // public void onConfigurationChanged(Configuration newConfig) { // super.onConfigurationChanged(newConfig); // } // }
import android.content.Context; import android.util.Log; import com.android.volley.AuthFailureError; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.github.cchao.touchnews.BaseApplication; import org.json.JSONObject; import java.util.Map;
package com.github.cchao.touchnews.util; /** * Created by cchao on 2016/4/5. * E-mail: cchao1024@163.com * Description: Volley 网络请求util */ public class NetRequestUtil { public final String TAG = this.getClass().getSimpleName();
// Path: app/src/main/java/com/github/cchao/touchnews/BaseApplication.java // public class BaseApplication extends Application { // public static BaiDuApiService mBaiDuApiService; // public static AppComponent mAppComponent; // private static Application mApplication; // // public static AppComponent getAppComponent() { // mBaiDuApiService = mAppComponent.getBaiDuApiService(); // return mAppComponent; // } // // public static Context getContext() { // return mApplication; // } // // @Override // public void onCreate() { // super.onCreate(); // setupLogUtils(); // setupComponent(); // mApplication = this; // MobclickAgent.startWithConfigure(new MobclickAgent.UMAnalyticsConfig(this, "5739942de0f55a0b3c001aab", "APP0")); // } // // /** // * 设置LogUtil // */ // private void setupLogUtils() { // LogUtils.getLogConfig() // .configAllowLog(true) // .configTagPrefix("TouchNews") // .configShowBorders(true) // .configLevel(LogLevel.TYPE_VERBOSE); // } // // /** // * 设置AppComponent // */ // private void setupComponent() { // mAppComponent = DaggerAppComponent.builder() // .appModule(new AppModule(this)) // .apiModule(new ApiModule()) // .build(); // mBaiDuApiService = mAppComponent.getBaiDuApiService(); // // } // // @Override // public void onLowMemory() { // super.onLowMemory(); // } // // @Override // public void onConfigurationChanged(Configuration newConfig) { // super.onConfigurationChanged(newConfig); // } // } // Path: app/src/main/java/com/github/cchao/touchnews/util/NetRequestUtil.java import android.content.Context; import android.util.Log; import com.android.volley.AuthFailureError; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley; import com.github.cchao.touchnews.BaseApplication; import org.json.JSONObject; import java.util.Map; package com.github.cchao.touchnews.util; /** * Created by cchao on 2016/4/5. * E-mail: cchao1024@163.com * Description: Volley 网络请求util */ public class NetRequestUtil { public final String TAG = this.getClass().getSimpleName();
Context mContext = BaseApplication.getContext();
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/contract/FragmentContainerContract.java
// Path: app/src/main/java/com/github/cchao/touchnews/ui/fragment/base/BaseFragment.java // public abstract class BaseFragment extends BaseLazyFragment { // protected Toolbar mToolbar; // protected View mRootView; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // mRootView = inflater.inflate(getLayoutId(), null); // ButterKnife.bind(this, mRootView); // mToolbar = ButterKnife.findById(mRootView, R.id.toolbar); // return mRootView; // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // initialize(); // } // // protected void initialize() { // } // // @Override // public void onFirstUserVisible() { // super.onFirstUserVisible(); // setSupportActionBar(); // } // // //布局ID // protected abstract // @LayoutRes // int getLayoutId(); // // @Override // public void onUserVisible() { // super.onUserVisible(); // setSupportActionBar(); // } // // /** // * 设置toolbar // */ // private void setSupportActionBar() { // ((AppCompatActivity) getActivity()).setSupportActionBar(mToolbar); // ((HomeActivity) getActivity()).addDrawerListener(mToolbar); // } // }
import com.github.cchao.touchnews.ui.fragment.base.BaseFragment; import java.util.List;
/* * Copyright 2016, The Android Open Source Project * * 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 * * 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. */ package com.github.cchao.touchnews.contract; /** * 绑定fragment块容器 view、presenter */ public interface FragmentContainerContract { interface View {
// Path: app/src/main/java/com/github/cchao/touchnews/ui/fragment/base/BaseFragment.java // public abstract class BaseFragment extends BaseLazyFragment { // protected Toolbar mToolbar; // protected View mRootView; // // @Nullable // @Override // public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // mRootView = inflater.inflate(getLayoutId(), null); // ButterKnife.bind(this, mRootView); // mToolbar = ButterKnife.findById(mRootView, R.id.toolbar); // return mRootView; // } // // @Override // public void onViewCreated(View view, Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // initialize(); // } // // protected void initialize() { // } // // @Override // public void onFirstUserVisible() { // super.onFirstUserVisible(); // setSupportActionBar(); // } // // //布局ID // protected abstract // @LayoutRes // int getLayoutId(); // // @Override // public void onUserVisible() { // super.onUserVisible(); // setSupportActionBar(); // } // // /** // * 设置toolbar // */ // private void setSupportActionBar() { // ((AppCompatActivity) getActivity()).setSupportActionBar(mToolbar); // ((HomeActivity) getActivity()).addDrawerListener(mToolbar); // } // } // Path: app/src/main/java/com/github/cchao/touchnews/contract/FragmentContainerContract.java import com.github.cchao.touchnews.ui.fragment.base.BaseFragment; import java.util.List; /* * Copyright 2016, The Android Open Source Project * * 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 * * 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. */ package com.github.cchao.touchnews.contract; /** * 绑定fragment块容器 view、presenter */ public interface FragmentContainerContract { interface View {
void setFragment(List<BaseFragment> fragments, String[] titles);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/contract/MusicContract.java
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/MusicEntity.java // public class MusicEntity { // private Data mMusicInfo; // private MusicPathRoot.Data mMusicPath; // private MusicSingerRoot.Data mMusicSinger; // // public MusicEntity(Data data) { // mMusicInfo = data; // } // // public MusicPathRoot.Data getMusicPath() { // return mMusicPath; // } // // public void setMusicPath(MusicPathRoot.Data musicPath) { // mMusicPath = musicPath; // } // // public MusicSingerRoot.Data getMusicSinger() { // return mMusicSinger; // } // // public void setMusicSinger(MusicSingerRoot.Data musicSinger) { // mMusicSinger = musicSinger; // } // // public Data getMusicInfo() { // // return mMusicInfo; // } // // public void setMusicInfo(Data musicInfo) { // mMusicInfo = musicInfo; // } // }
import com.github.cchao.touchnews.javaBean.MusicEntity; import java.util.List;
package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/9/26. * E-mail: cchao1024@163.com * Description: */ public interface MusicContract { interface View { void onMusicPlay(); void onMusicPause(); void onResumePlay();
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/MusicEntity.java // public class MusicEntity { // private Data mMusicInfo; // private MusicPathRoot.Data mMusicPath; // private MusicSingerRoot.Data mMusicSinger; // // public MusicEntity(Data data) { // mMusicInfo = data; // } // // public MusicPathRoot.Data getMusicPath() { // return mMusicPath; // } // // public void setMusicPath(MusicPathRoot.Data musicPath) { // mMusicPath = musicPath; // } // // public MusicSingerRoot.Data getMusicSinger() { // return mMusicSinger; // } // // public void setMusicSinger(MusicSingerRoot.Data musicSinger) { // mMusicSinger = musicSinger; // } // // public Data getMusicInfo() { // // return mMusicInfo; // } // // public void setMusicInfo(Data musicInfo) { // mMusicInfo = musicInfo; // } // } // Path: app/src/main/java/com/github/cchao/touchnews/contract/MusicContract.java import com.github.cchao.touchnews.javaBean.MusicEntity; import java.util.List; package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/9/26. * E-mail: cchao1024@163.com * Description: */ public interface MusicContract { interface View { void onMusicPlay(); void onMusicPause(); void onResumePlay();
void onMusicPrepare(MusicEntity curMusic);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/util/NetUtil.java
// Path: app/src/main/java/com/github/cchao/touchnews/BaseApplication.java // public class BaseApplication extends Application { // public static BaiDuApiService mBaiDuApiService; // public static AppComponent mAppComponent; // private static Application mApplication; // // public static AppComponent getAppComponent() { // mBaiDuApiService = mAppComponent.getBaiDuApiService(); // return mAppComponent; // } // // public static Context getContext() { // return mApplication; // } // // @Override // public void onCreate() { // super.onCreate(); // setupLogUtils(); // setupComponent(); // mApplication = this; // MobclickAgent.startWithConfigure(new MobclickAgent.UMAnalyticsConfig(this, "5739942de0f55a0b3c001aab", "APP0")); // } // // /** // * 设置LogUtil // */ // private void setupLogUtils() { // LogUtils.getLogConfig() // .configAllowLog(true) // .configTagPrefix("TouchNews") // .configShowBorders(true) // .configLevel(LogLevel.TYPE_VERBOSE); // } // // /** // * 设置AppComponent // */ // private void setupComponent() { // mAppComponent = DaggerAppComponent.builder() // .appModule(new AppModule(this)) // .apiModule(new ApiModule()) // .build(); // mBaiDuApiService = mAppComponent.getBaiDuApiService(); // // } // // @Override // public void onLowMemory() { // super.onLowMemory(); // } // // @Override // public void onConfigurationChanged(Configuration newConfig) { // super.onConfigurationChanged(newConfig); // } // }
import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import com.github.cchao.touchnews.BaseApplication;
package com.github.cchao.touchnews.util; /** * Created by cchao on 2016/4/7. * E-mail: cchao1024@163.com * Description:网络相关的工具类 */ public class NetUtil { private NetUtil() { /* cannot be instantiated */ throw new UnsupportedOperationException("cannot be instantiated"); } /** * 判断网络是否连接 * * @return s */ public static boolean isConnected() {
// Path: app/src/main/java/com/github/cchao/touchnews/BaseApplication.java // public class BaseApplication extends Application { // public static BaiDuApiService mBaiDuApiService; // public static AppComponent mAppComponent; // private static Application mApplication; // // public static AppComponent getAppComponent() { // mBaiDuApiService = mAppComponent.getBaiDuApiService(); // return mAppComponent; // } // // public static Context getContext() { // return mApplication; // } // // @Override // public void onCreate() { // super.onCreate(); // setupLogUtils(); // setupComponent(); // mApplication = this; // MobclickAgent.startWithConfigure(new MobclickAgent.UMAnalyticsConfig(this, "5739942de0f55a0b3c001aab", "APP0")); // } // // /** // * 设置LogUtil // */ // private void setupLogUtils() { // LogUtils.getLogConfig() // .configAllowLog(true) // .configTagPrefix("TouchNews") // .configShowBorders(true) // .configLevel(LogLevel.TYPE_VERBOSE); // } // // /** // * 设置AppComponent // */ // private void setupComponent() { // mAppComponent = DaggerAppComponent.builder() // .appModule(new AppModule(this)) // .apiModule(new ApiModule()) // .build(); // mBaiDuApiService = mAppComponent.getBaiDuApiService(); // // } // // @Override // public void onLowMemory() { // super.onLowMemory(); // } // // @Override // public void onConfigurationChanged(Configuration newConfig) { // super.onConfigurationChanged(newConfig); // } // } // Path: app/src/main/java/com/github/cchao/touchnews/util/NetUtil.java import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import com.github.cchao.touchnews.BaseApplication; package com.github.cchao.touchnews.util; /** * Created by cchao on 2016/4/7. * E-mail: cchao1024@163.com * Description:网络相关的工具类 */ public class NetUtil { private NetUtil() { /* cannot be instantiated */ throw new UnsupportedOperationException("cannot be instantiated"); } /** * 判断网络是否连接 * * @return s */ public static boolean isConnected() {
ConnectivityManager connectivity = (ConnectivityManager) BaseApplication.getContext()
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/contract/JokeImageListContract.java
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/joke/JokeImageRoot.java // public static class Contentlist { // private String ct; // // private String img; // // private String title; // // private int type; // // public void setCt(String ct) { // this.ct = ct; // } // // public String getCt() { // return this.ct; // } // // public void setImg(String img) { // this.img = img; // } // // public String getImg() { // return this.img; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // public void setType(int type) { // this.type = type; // } // // public int getType() { // return this.type; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // }
import com.github.cchao.touchnews.javaBean.joke.JokeImageRoot.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List;
package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/8/26. * E-mail: cchao1024@163.com * Description: 笑话集 */ public interface JokeImageListContract { interface View { /** * 获取数据 * * @param newsList newsList */
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/joke/JokeImageRoot.java // public static class Contentlist { // private String ct; // // private String img; // // private String title; // // private int type; // // public void setCt(String ct) { // this.ct = ct; // } // // public String getCt() { // return this.ct; // } // // public void setImg(String img) { // this.img = img; // } // // public String getImg() { // return this.img; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // public void setType(int type) { // this.type = type; // } // // public int getType() { // return this.type; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // } // Path: app/src/main/java/com/github/cchao/touchnews/contract/JokeImageListContract.java import com.github.cchao.touchnews.javaBean.joke.JokeImageRoot.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List; package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/8/26. * E-mail: cchao1024@163.com * Description: 笑话集 */ public interface JokeImageListContract { interface View { /** * 获取数据 * * @param newsList newsList */
void onRefreshData(List<Contentlist> newsList);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/contract/JokeImageListContract.java
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/joke/JokeImageRoot.java // public static class Contentlist { // private String ct; // // private String img; // // private String title; // // private int type; // // public void setCt(String ct) { // this.ct = ct; // } // // public String getCt() { // return this.ct; // } // // public void setImg(String img) { // this.img = img; // } // // public String getImg() { // return this.img; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // public void setType(int type) { // this.type = type; // } // // public int getType() { // return this.type; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // }
import com.github.cchao.touchnews.javaBean.joke.JokeImageRoot.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List;
package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/8/26. * E-mail: cchao1024@163.com * Description: 笑话集 */ public interface JokeImageListContract { interface View { /** * 获取数据 * * @param newsList newsList */ void onRefreshData(List<Contentlist> newsList); /** * 添加数据 * * @param newsList add newsList */ void onReceiveMoreListData(List<Contentlist> newsList); /** * 显示信息 e.g. 没有网络、正在加载、异常 * * @param INFOType 枚举值 * @param infoText 提示的文本内容 * @see Constant.INFO_TYPE */
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/joke/JokeImageRoot.java // public static class Contentlist { // private String ct; // // private String img; // // private String title; // // private int type; // // public void setCt(String ct) { // this.ct = ct; // } // // public String getCt() { // return this.ct; // } // // public void setImg(String img) { // this.img = img; // } // // public String getImg() { // return this.img; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // public void setType(int type) { // this.type = type; // } // // public int getType() { // return this.type; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // } // Path: app/src/main/java/com/github/cchao/touchnews/contract/JokeImageListContract.java import com.github.cchao.touchnews.javaBean.joke.JokeImageRoot.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List; package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/8/26. * E-mail: cchao1024@163.com * Description: 笑话集 */ public interface JokeImageListContract { interface View { /** * 获取数据 * * @param newsList newsList */ void onRefreshData(List<Contentlist> newsList); /** * 添加数据 * * @param newsList add newsList */ void onReceiveMoreListData(List<Contentlist> newsList); /** * 显示信息 e.g. 没有网络、正在加载、异常 * * @param INFOType 枚举值 * @param infoText 提示的文本内容 * @see Constant.INFO_TYPE */
void showInfo(Constant.INFO_TYPE INFOType, String infoText);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/ui/activity/ImageBrowseActivity.java
// Path: app/src/main/java/com/github/cchao/touchnews/util/ImageUtil.java // public class ImageUtil { // // public static void displayImage(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).into(imageView); // } // // public static void displayImage(Context context, File file, ImageView imageView) { // Glide.with(context).load(file).into(imageView); // } // // public static void displayCircularImage(final Context context, String url, final ImageView imageView) { // Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { // @Override // protected void setResource(Bitmap resource) { // RoundedBitmapDrawable circularBitmapDrawable = // RoundedBitmapDrawableFactory.create(context.getResources(), resource); // circularBitmapDrawable.setCircular(true); // imageView.setImageDrawable(circularBitmapDrawable); // // } // }); // } // // /*public static void displayBlurImage ( Context context, String url, ImageView imageView ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ) // .into ( imageView ); // } // public static void displayBlurImage ( Context context, String url, final View view ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ).into ( new SimpleTarget< GlideDrawable > ( ) { // @Override // public void onResourceReady ( GlideDrawable resource, GlideAnimation< ? super GlideDrawable > glideAnimation ) { // view.setBackground ( resource ); // } // } ); // }*/ // // }
import android.view.MenuItem; import android.widget.ImageView; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.util.ImageUtil;
package com.github.cchao.touchnews.ui.activity; /** * Created by cchao on 2016/5/4. * E-mail: cchao1024@163.com * Description: 图片浏览Aty */ public class ImageBrowseActivity extends BaseActivity { @Override protected int getLayoutID() { return R.layout.activity_image_browse; } @Override protected void initialize() { super.initialize(); String url = getIntent().getStringExtra("url");
// Path: app/src/main/java/com/github/cchao/touchnews/util/ImageUtil.java // public class ImageUtil { // // public static void displayImage(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).into(imageView); // } // // public static void displayImage(Context context, File file, ImageView imageView) { // Glide.with(context).load(file).into(imageView); // } // // public static void displayCircularImage(final Context context, String url, final ImageView imageView) { // Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { // @Override // protected void setResource(Bitmap resource) { // RoundedBitmapDrawable circularBitmapDrawable = // RoundedBitmapDrawableFactory.create(context.getResources(), resource); // circularBitmapDrawable.setCircular(true); // imageView.setImageDrawable(circularBitmapDrawable); // // } // }); // } // // /*public static void displayBlurImage ( Context context, String url, ImageView imageView ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ) // .into ( imageView ); // } // public static void displayBlurImage ( Context context, String url, final View view ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ).into ( new SimpleTarget< GlideDrawable > ( ) { // @Override // public void onResourceReady ( GlideDrawable resource, GlideAnimation< ? super GlideDrawable > glideAnimation ) { // view.setBackground ( resource ); // } // } ); // }*/ // // } // Path: app/src/main/java/com/github/cchao/touchnews/ui/activity/ImageBrowseActivity.java import android.view.MenuItem; import android.widget.ImageView; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.util.ImageUtil; package com.github.cchao.touchnews.ui.activity; /** * Created by cchao on 2016/5/4. * E-mail: cchao1024@163.com * Description: 图片浏览Aty */ public class ImageBrowseActivity extends BaseActivity { @Override protected int getLayoutID() { return R.layout.activity_image_browse; } @Override protected void initialize() { super.initialize(); String url = getIntent().getStringExtra("url");
ImageUtil.displayImage(this, url, (ImageView) findViewById(R.id.iv_browse));
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/ui/activity/NewsDetailActivity.java
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/news/Contentlist.java // public class Contentlist implements Serializable { // private static final long serialVersionUID = -7060210544600464481L; // private String channelId; // // private String channelName; // // private String desc; // // private List<Imageurls> imageurls; // // private String link; // // private String nid; // // private String pubDate; // // private String source; // // private String title; // // public void setChannelId(String channelId) { // this.channelId = channelId; // } // // public String getChannelId() { // return this.channelId; // } // // public void setChannelName(String channelName) { // this.channelName = channelName; // } // // public String getChannelName() { // return this.channelName; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public String getDesc() { // return this.desc; // } // // public void setImageurls(List<Imageurls> imageurls) { // this.imageurls = imageurls; // } // // public List<Imageurls> getImageurls() { // return this.imageurls; // } // // public void setLink(String link) { // this.link = link; // } // // public String getLink() { // return this.link; // } // // public void setNid(String nid) { // this.nid = nid; // } // // public String getNid() { // return this.nid; // } // // public void setPubDate(String pubDate) { // this.pubDate = pubDate; // } // // public String getPubDate() { // return this.pubDate; // } // // public void setSource(String source) { // this.source = source; // } // // public String getSource() { // return this.source; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/ImageUtil.java // public class ImageUtil { // // public static void displayImage(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).into(imageView); // } // // public static void displayImage(Context context, File file, ImageView imageView) { // Glide.with(context).load(file).into(imageView); // } // // public static void displayCircularImage(final Context context, String url, final ImageView imageView) { // Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { // @Override // protected void setResource(Bitmap resource) { // RoundedBitmapDrawable circularBitmapDrawable = // RoundedBitmapDrawableFactory.create(context.getResources(), resource); // circularBitmapDrawable.setCircular(true); // imageView.setImageDrawable(circularBitmapDrawable); // // } // }); // } // // /*public static void displayBlurImage ( Context context, String url, ImageView imageView ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ) // .into ( imageView ); // } // public static void displayBlurImage ( Context context, String url, final View view ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ).into ( new SimpleTarget< GlideDrawable > ( ) { // @Override // public void onResourceReady ( GlideDrawable resource, GlideAnimation< ? super GlideDrawable > glideAnimation ) { // view.setBackground ( resource ); // } // } ); // }*/ // // }
import android.content.Intent; import android.graphics.Bitmap; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ImageView; import android.widget.ProgressBar; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.javaBean.news.Contentlist; import com.github.cchao.touchnews.util.ImageUtil; import butterknife.Bind;
package com.github.cchao.touchnews.ui.activity; /** * Created by cchao on 2016/4/7. * E-mail: cchao1024@163.com * Description: 新闻详情页 - 使用WebView 加载外链 */ public class NewsDetailActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener { @Bind(R.id.iv_new_detail_top) ImageView mImageViewTop; @Bind(R.id.pb_new_detail) ProgressBar mProgressBar; @Bind(R.id.webview_new_detail) WebView mWebView;
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/news/Contentlist.java // public class Contentlist implements Serializable { // private static final long serialVersionUID = -7060210544600464481L; // private String channelId; // // private String channelName; // // private String desc; // // private List<Imageurls> imageurls; // // private String link; // // private String nid; // // private String pubDate; // // private String source; // // private String title; // // public void setChannelId(String channelId) { // this.channelId = channelId; // } // // public String getChannelId() { // return this.channelId; // } // // public void setChannelName(String channelName) { // this.channelName = channelName; // } // // public String getChannelName() { // return this.channelName; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public String getDesc() { // return this.desc; // } // // public void setImageurls(List<Imageurls> imageurls) { // this.imageurls = imageurls; // } // // public List<Imageurls> getImageurls() { // return this.imageurls; // } // // public void setLink(String link) { // this.link = link; // } // // public String getLink() { // return this.link; // } // // public void setNid(String nid) { // this.nid = nid; // } // // public String getNid() { // return this.nid; // } // // public void setPubDate(String pubDate) { // this.pubDate = pubDate; // } // // public String getPubDate() { // return this.pubDate; // } // // public void setSource(String source) { // this.source = source; // } // // public String getSource() { // return this.source; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/ImageUtil.java // public class ImageUtil { // // public static void displayImage(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).into(imageView); // } // // public static void displayImage(Context context, File file, ImageView imageView) { // Glide.with(context).load(file).into(imageView); // } // // public static void displayCircularImage(final Context context, String url, final ImageView imageView) { // Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { // @Override // protected void setResource(Bitmap resource) { // RoundedBitmapDrawable circularBitmapDrawable = // RoundedBitmapDrawableFactory.create(context.getResources(), resource); // circularBitmapDrawable.setCircular(true); // imageView.setImageDrawable(circularBitmapDrawable); // // } // }); // } // // /*public static void displayBlurImage ( Context context, String url, ImageView imageView ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ) // .into ( imageView ); // } // public static void displayBlurImage ( Context context, String url, final View view ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ).into ( new SimpleTarget< GlideDrawable > ( ) { // @Override // public void onResourceReady ( GlideDrawable resource, GlideAnimation< ? super GlideDrawable > glideAnimation ) { // view.setBackground ( resource ); // } // } ); // }*/ // // } // Path: app/src/main/java/com/github/cchao/touchnews/ui/activity/NewsDetailActivity.java import android.content.Intent; import android.graphics.Bitmap; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ImageView; import android.widget.ProgressBar; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.javaBean.news.Contentlist; import com.github.cchao.touchnews.util.ImageUtil; import butterknife.Bind; package com.github.cchao.touchnews.ui.activity; /** * Created by cchao on 2016/4/7. * E-mail: cchao1024@163.com * Description: 新闻详情页 - 使用WebView 加载外链 */ public class NewsDetailActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener { @Bind(R.id.iv_new_detail_top) ImageView mImageViewTop; @Bind(R.id.pb_new_detail) ProgressBar mProgressBar; @Bind(R.id.webview_new_detail) WebView mWebView;
Contentlist mContentlist;
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/ui/activity/NewsDetailActivity.java
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/news/Contentlist.java // public class Contentlist implements Serializable { // private static final long serialVersionUID = -7060210544600464481L; // private String channelId; // // private String channelName; // // private String desc; // // private List<Imageurls> imageurls; // // private String link; // // private String nid; // // private String pubDate; // // private String source; // // private String title; // // public void setChannelId(String channelId) { // this.channelId = channelId; // } // // public String getChannelId() { // return this.channelId; // } // // public void setChannelName(String channelName) { // this.channelName = channelName; // } // // public String getChannelName() { // return this.channelName; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public String getDesc() { // return this.desc; // } // // public void setImageurls(List<Imageurls> imageurls) { // this.imageurls = imageurls; // } // // public List<Imageurls> getImageurls() { // return this.imageurls; // } // // public void setLink(String link) { // this.link = link; // } // // public String getLink() { // return this.link; // } // // public void setNid(String nid) { // this.nid = nid; // } // // public String getNid() { // return this.nid; // } // // public void setPubDate(String pubDate) { // this.pubDate = pubDate; // } // // public String getPubDate() { // return this.pubDate; // } // // public void setSource(String source) { // this.source = source; // } // // public String getSource() { // return this.source; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/ImageUtil.java // public class ImageUtil { // // public static void displayImage(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).into(imageView); // } // // public static void displayImage(Context context, File file, ImageView imageView) { // Glide.with(context).load(file).into(imageView); // } // // public static void displayCircularImage(final Context context, String url, final ImageView imageView) { // Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { // @Override // protected void setResource(Bitmap resource) { // RoundedBitmapDrawable circularBitmapDrawable = // RoundedBitmapDrawableFactory.create(context.getResources(), resource); // circularBitmapDrawable.setCircular(true); // imageView.setImageDrawable(circularBitmapDrawable); // // } // }); // } // // /*public static void displayBlurImage ( Context context, String url, ImageView imageView ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ) // .into ( imageView ); // } // public static void displayBlurImage ( Context context, String url, final View view ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ).into ( new SimpleTarget< GlideDrawable > ( ) { // @Override // public void onResourceReady ( GlideDrawable resource, GlideAnimation< ? super GlideDrawable > glideAnimation ) { // view.setBackground ( resource ); // } // } ); // }*/ // // }
import android.content.Intent; import android.graphics.Bitmap; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ImageView; import android.widget.ProgressBar; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.javaBean.news.Contentlist; import com.github.cchao.touchnews.util.ImageUtil; import butterknife.Bind;
@Override protected int getLayoutID() { return R.layout.activity_new_detail; } @Override protected void initialize() { super.initialize(); initViews(); setWebView(); setNavigationClick(); } private void setNavigationClick() { mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); } @Override public void onBackPressed() { mWebView.setVisibility(View.INVISIBLE); super.onBackPressed(); } private void initViews() { mContentlist = (Contentlist) this.getIntent().getSerializableExtra("contentList");
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/news/Contentlist.java // public class Contentlist implements Serializable { // private static final long serialVersionUID = -7060210544600464481L; // private String channelId; // // private String channelName; // // private String desc; // // private List<Imageurls> imageurls; // // private String link; // // private String nid; // // private String pubDate; // // private String source; // // private String title; // // public void setChannelId(String channelId) { // this.channelId = channelId; // } // // public String getChannelId() { // return this.channelId; // } // // public void setChannelName(String channelName) { // this.channelName = channelName; // } // // public String getChannelName() { // return this.channelName; // } // // public void setDesc(String desc) { // this.desc = desc; // } // // public String getDesc() { // return this.desc; // } // // public void setImageurls(List<Imageurls> imageurls) { // this.imageurls = imageurls; // } // // public List<Imageurls> getImageurls() { // return this.imageurls; // } // // public void setLink(String link) { // this.link = link; // } // // public String getLink() { // return this.link; // } // // public void setNid(String nid) { // this.nid = nid; // } // // public String getNid() { // return this.nid; // } // // public void setPubDate(String pubDate) { // this.pubDate = pubDate; // } // // public String getPubDate() { // return this.pubDate; // } // // public void setSource(String source) { // this.source = source; // } // // public String getSource() { // return this.source; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/ImageUtil.java // public class ImageUtil { // // public static void displayImage(Context context, String url, ImageView imageView) { // Glide.with(context).load(url).into(imageView); // } // // public static void displayImage(Context context, File file, ImageView imageView) { // Glide.with(context).load(file).into(imageView); // } // // public static void displayCircularImage(final Context context, String url, final ImageView imageView) { // Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { // @Override // protected void setResource(Bitmap resource) { // RoundedBitmapDrawable circularBitmapDrawable = // RoundedBitmapDrawableFactory.create(context.getResources(), resource); // circularBitmapDrawable.setCircular(true); // imageView.setImageDrawable(circularBitmapDrawable); // // } // }); // } // // /*public static void displayBlurImage ( Context context, String url, ImageView imageView ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ) // .into ( imageView ); // } // public static void displayBlurImage ( Context context, String url, final View view ) { // Glide.with ( context ).load ( url ) // .bitmapTransform ( new BlurTransformation ( context ) ).into ( new SimpleTarget< GlideDrawable > ( ) { // @Override // public void onResourceReady ( GlideDrawable resource, GlideAnimation< ? super GlideDrawable > glideAnimation ) { // view.setBackground ( resource ); // } // } ); // }*/ // // } // Path: app/src/main/java/com/github/cchao/touchnews/ui/activity/NewsDetailActivity.java import android.content.Intent; import android.graphics.Bitmap; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ImageView; import android.widget.ProgressBar; import com.github.cchao.touchnews.R; import com.github.cchao.touchnews.javaBean.news.Contentlist; import com.github.cchao.touchnews.util.ImageUtil; import butterknife.Bind; @Override protected int getLayoutID() { return R.layout.activity_new_detail; } @Override protected void initialize() { super.initialize(); initViews(); setWebView(); setNavigationClick(); } private void setNavigationClick() { mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); } @Override public void onBackPressed() { mWebView.setVisibility(View.INVISIBLE); super.onBackPressed(); } private void initViews() { mContentlist = (Contentlist) this.getIntent().getSerializableExtra("contentList");
ImageUtil.displayImage(this, mContentlist.getImageurls().get(0).getUrl(), mImageViewTop);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/contract/JokeTextListContract.java
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/joke/JokeTextRoot.java // public static class Contentlist { // private String ct; // // private String text; // // private String title; // // private int type; // // public void setCt(String ct) { // this.ct = ct; // } // // public String getCt() { // return this.ct; // } // // public void setText(String img) { // this.text = img; // } // // public String getText() { // return this.text; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // public void setType(int type) { // this.type = type; // } // // public int getType() { // return this.type; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // }
import com.github.cchao.touchnews.javaBean.joke.JokeTextRoot.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List;
package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/8/26. * E-mail: cchao1024@163.com * Description: 笑话集 */ public interface JokeTextListContract { interface View { /** * 获取数据 * * @param newsList newsList */
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/joke/JokeTextRoot.java // public static class Contentlist { // private String ct; // // private String text; // // private String title; // // private int type; // // public void setCt(String ct) { // this.ct = ct; // } // // public String getCt() { // return this.ct; // } // // public void setText(String img) { // this.text = img; // } // // public String getText() { // return this.text; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // public void setType(int type) { // this.type = type; // } // // public int getType() { // return this.type; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // } // Path: app/src/main/java/com/github/cchao/touchnews/contract/JokeTextListContract.java import com.github.cchao.touchnews.javaBean.joke.JokeTextRoot.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List; package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/8/26. * E-mail: cchao1024@163.com * Description: 笑话集 */ public interface JokeTextListContract { interface View { /** * 获取数据 * * @param newsList newsList */
void onRefreshData(List<Contentlist> newsList);
cchao1024/TouchNews
app/src/main/java/com/github/cchao/touchnews/contract/JokeTextListContract.java
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/joke/JokeTextRoot.java // public static class Contentlist { // private String ct; // // private String text; // // private String title; // // private int type; // // public void setCt(String ct) { // this.ct = ct; // } // // public String getCt() { // return this.ct; // } // // public void setText(String img) { // this.text = img; // } // // public String getText() { // return this.text; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // public void setType(int type) { // this.type = type; // } // // public int getType() { // return this.type; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // }
import com.github.cchao.touchnews.javaBean.joke.JokeTextRoot.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List;
package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/8/26. * E-mail: cchao1024@163.com * Description: 笑话集 */ public interface JokeTextListContract { interface View { /** * 获取数据 * * @param newsList newsList */ void onRefreshData(List<Contentlist> newsList); /** * 添加数据 * * @param newsList add newsList */ void onReceiveMoreListData(List<Contentlist> newsList); /** * 显示信息 e.g. 没有网络、正在加载、异常 * * @param INFOType 枚举值 * @param infoText 提示的文本内容 * @see Constant.INFO_TYPE */
// Path: app/src/main/java/com/github/cchao/touchnews/javaBean/joke/JokeTextRoot.java // public static class Contentlist { // private String ct; // // private String text; // // private String title; // // private int type; // // public void setCt(String ct) { // this.ct = ct; // } // // public String getCt() { // return this.ct; // } // // public void setText(String img) { // this.text = img; // } // // public String getText() { // return this.text; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getTitle() { // return this.title; // } // // public void setType(int type) { // this.type = type; // } // // public int getType() { // return this.type; // } // // } // // Path: app/src/main/java/com/github/cchao/touchnews/util/Constant.java // public class Constant { // /** // * 显示提示信息给用户 e.g. 没有网络、正在加载、异常 // * // * @see // */ // public enum INFO_TYPE { // NO_NET, ALERT, LOADING, EMPTY, ORIGIN // } // // } // Path: app/src/main/java/com/github/cchao/touchnews/contract/JokeTextListContract.java import com.github.cchao.touchnews.javaBean.joke.JokeTextRoot.Contentlist; import com.github.cchao.touchnews.util.Constant; import java.util.List; package com.github.cchao.touchnews.contract; /** * Created by cchao on 2016/8/26. * E-mail: cchao1024@163.com * Description: 笑话集 */ public interface JokeTextListContract { interface View { /** * 获取数据 * * @param newsList newsList */ void onRefreshData(List<Contentlist> newsList); /** * 添加数据 * * @param newsList add newsList */ void onReceiveMoreListData(List<Contentlist> newsList); /** * 显示信息 e.g. 没有网络、正在加载、异常 * * @param INFOType 枚举值 * @param infoText 提示的文本内容 * @see Constant.INFO_TYPE */
void showInfo(Constant.INFO_TYPE INFOType, String infoText);