1 /*
   2  * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  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 com.sun.javafx.tools.resource;
  27 
  28 import java.io.File;
  29 
  30 public class DeployResource extends PackagerResource {
  31     private final Type type;
  32     private final String mode;
  33     private final String os;
  34     private final String arch;
  35 
  36     public static enum Type {
  37         UNKNOWN, jnlp, jar, nativelib, icon, license, data
  38     };
  39 
  40     public static final String TYPE_LICENSE = "license";
  41     public static final String TYPE_DATA    = "data";
  42 
  43     public DeployResource(final File baseDir, final String path) {
  44         this(baseDir, path, "eager");
  45     }
  46 
  47     public DeployResource(final File baseDir, final File file) {
  48         this(baseDir, file, "eager");
  49     }
  50 
  51     public DeployResource(final File baseDir, final String path,
  52                           final String mode) {
  53         super(baseDir, path);
  54         this.mode = mode;
  55         this.type = null;
  56         this.os = null;
  57         this.arch = null;
  58     }
  59 
  60     public DeployResource(final File baseDir, final File file,
  61                           final String mode) {
  62         this(baseDir, file, mode, null, null, null);
  63     }
  64 
  65     public DeployResource(final File baseDir, final File file,
  66                           final String mode, final String type,
  67                           final String os, final String arch) {
  68         super(baseDir, file);
  69         if (type == null) {
  70            if (file.getName().endsWith(".jar")) {
  71                this.type = Type.jar;
  72            } else if (file.getName().endsWith(".jnlp")) {
  73                this.type = Type.jnlp;
  74            } else {
  75             this.type = Type.UNKNOWN;
  76            }
  77         } else {
  78               this.type = Type.valueOf(type);
  79         }
  80         this.os = os;
  81         this.arch = arch;
  82         this.mode = mode;
  83     }
  84 
  85     public String getMode() {
  86         return mode;
  87     }
  88 
  89     public Type getType() {
  90         return type;
  91     }
  92 
  93     public String getOs() {
  94         return os;
  95     }
  96 
  97     public String getArch() {
  98         return arch;
  99     }
 100 }