< prev index next >

src/jdk.incubator.jpackage/windows/classes/jdk/incubator/jpackage/internal/WinAppBundler.java

Print this page




  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.incubator.jpackage.internal;
  27 
  28 import java.io.File;
  29 import java.nio.file.Path;
  30 import java.text.MessageFormat;
  31 import java.util.*;
  32 
  33 import static jdk.incubator.jpackage.internal.WindowsBundlerParam.*;
  34 
  35 public class WinAppBundler extends AbstractImageBundler {
  36 
  37     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  38             "jdk.incubator.jpackage.internal.resources.WinResources");
  39 
  40     static final BundlerParamInfo<File> ICON_ICO =
  41             new StandardBundlerParam<>(
  42             "icon.ico",
  43             File.class,
  44             params -> {
  45                 File f = ICON.fetchFrom(params);
  46                 if (f != null && !f.getName().toLowerCase().endsWith(".ico")) {
  47                     Log.error(MessageFormat.format(
  48                             I18N.getString("message.icon-not-ico"), f));
  49                     return null;
  50                 }
  51                 return f;
  52             },
  53             (s, p) -> new File(s));
  54 
  55     @Override
  56     public boolean validate(Map<String, ? super Object> params)
  57             throws ConfigException {
  58         try {
  59             Objects.requireNonNull(params);
  60             return doValidate(params);
  61         } catch (RuntimeException re) {
  62             if (re.getCause() instanceof ConfigException) {
  63                 throw (ConfigException) re.getCause();
  64             } else {
  65                 throw new ConfigException(re);
  66             }
  67         }
  68     }
  69 
  70     // to be used by chained bundlers, e.g. by EXE bundler to avoid
  71     // skipping validation if p.type does not include "image"
  72     private boolean doValidate(Map<String, ? super Object> p)
  73             throws ConfigException {
  74 




  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.incubator.jpackage.internal;
  27 
  28 import java.io.File;
  29 import java.nio.file.Path;
  30 import java.text.MessageFormat;
  31 import java.util.*;
  32 
  33 import static jdk.incubator.jpackage.internal.WindowsBundlerParam.*;
  34 
  35 public class WinAppBundler extends AbstractImageBundler {
  36 
  37     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  38             "jdk.incubator.jpackage.internal.resources.WinResources");
  39 















  40     @Override
  41     public boolean validate(Map<String, ? super Object> params)
  42             throws ConfigException {
  43         try {
  44             Objects.requireNonNull(params);
  45             return doValidate(params);
  46         } catch (RuntimeException re) {
  47             if (re.getCause() instanceof ConfigException) {
  48                 throw (ConfigException) re.getCause();
  49             } else {
  50                 throw new ConfigException(re);
  51             }
  52         }
  53     }
  54 
  55     // to be used by chained bundlers, e.g. by EXE bundler to avoid
  56     // skipping validation if p.type does not include "image"
  57     private boolean doValidate(Map<String, ? super Object> p)
  58             throws ConfigException {
  59 


< prev index next >