/* * [ViaCommon.java] * * Summary: Centralised logic that depends on the how the Replicator is delivered. * * Copyright: (c) 2003-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 7.6 2007-07-16 */ package com.mindprod.replicatorcommon; import java.io.Serializable; /** * Centralised logic that depends on the how the Replicator is delivered. *

* This code is distributed to both sender and receiver. * * @author Roedy Green, Canadian Mind Products * @version 7.6 2007-07-16 * @since 2003-10-20 */ public enum ViaCommon implements Serializable { /** * gets files from website */ @SuppressWarnings( { "EnumeratedConstantNamingConvention" } ) VIA_WEBSITE( false, "website", "via website", false ), /** * gets files from LAN */ @SuppressWarnings( { "EnumeratedConstantNamingConvention" } ) VIA_LAN( false, "lan", "via LAN", true ), /** * gets files from website to relay to others. */ @SuppressWarnings( { "EnumeratedConstantNamingConvention" } ) VIA_RELAY( true, "relay", "relaying from website to offnet clients", false ), /** * TEST, gets files from sender's staging directory loops back to same machine. */ @SuppressWarnings( { "EnumeratedConstantNamingConvention" } ) VIA_TEST( false, "test", "test loopback to sending machine", true ), /** * CD, gets files from CD. */ @SuppressWarnings( { "EnumeratedConstantNamingConvention" } ) VIA_CD( false, "cd", "via CD", true ); /** * Layout version number. */ private static final long serialVersionUID = 360L; /** * English description for this viaCode */ private final String description; /** * English short description for this viaCode */ private final String name; /** * true if we keep zips by default for this viaCode */ private final boolean defaultKeepZips; /** * true if can process zips without an Internet Connection */ private final boolean isOfflineAllowed; /** * constructor * * @param defaultKeepZips true if we keep zips by default for this viaCode * @param name short English name for this via code. * @param description long English description for this via code. * @param isOfflineAllowed true if can process zips without an Internet connection. */ ViaCommon( boolean defaultKeepZips, String name, String description, boolean isOfflineAllowed ) { this.defaultKeepZips = defaultKeepZips; assert name != null : "name null"; this.name = name; assert description != null : "description null"; this.description = description; this.isOfflineAllowed = isOfflineAllowed; } /** * convert from string to enum form of via. * * @param viaString string form of how client deployed. * * @return enum of how client deployed. */ public static ViaCommon valueOfAlias( String viaString ) { if ( viaString.equalsIgnoreCase( "website" ) ) { return VIA_WEBSITE; } if ( viaString.equalsIgnoreCase( "lan" ) ) { return VIA_LAN; } if ( viaString.equalsIgnoreCase( "relay" ) ) { return VIA_RELAY; } if ( viaString.equalsIgnoreCase( "test" ) ) { return VIA_TEST; } if ( viaString.equalsIgnoreCase( "cd" ) ) { return VIA_CD; } throw new IllegalArgumentException( "invalid viaString: \"" + viaString + "\"" ); } /** * Do we usually keep zips for this via after downloading? * * @return true if we keep zips by default for this viaCode */ @SuppressWarnings( { "BooleanMethodNameMustStartWithQuestion" } ) public boolean defaultKeepZips() { return defaultKeepZips; } /** * convert via enum to long string description. * * @return long string form of enum */ public String getDescription() { return description; } /** * online vs offline processing. * * @return true if can process zips without an Internet connection. */ public boolean isOfflineAllowed() { return isOfflineAllowed; } /** * convert via enum to string. * * @return string form of enum. */ public String toString() { return name; } } // end ViaCommon