473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Statement expected in private enum inside of java code

5
I got some java code below, and upon trying to compile it in my unix environment, i get the following error

()[/home/mgt/gmat]> javac Downloader.java
Downloader.java:37: ';' expected
private enum ReportFormat {
^
1 error


This is a portion of the code below



import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
* Sample GMAT Score Data File Downloader.
*
* @version $Revision: #11 $ submitted $DateTime: 2008/08/18 14:43:29 $ by $Author: chetds $
* @author Dan Syrstad
*/
public class Downloader {
private static final String HOSTNAME = "www.domain.com";
private static final String RELATIVE_URL = "/entry/gmat/download.jsp";
private static final DateFormat logDateFmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss: ");

private static PrintStream logStream = System.out;
private enum ReportFormat {
TXT,
CSV;
};

// Discourage instantiation
private Downloader() { }

private static void emitUsageAndExit() {
log("Usage: Downloader [-file filename] [-log log-file] [-host hostname] [-format [TXT | CSV]] username password GMAT-progr$
System.exit(1);
}

/**
Oct 1 '08 #1
6 4362
JosAH
11,448 Expert 8TB
)[/home/mgt/gmat]> javac Downloader.java
Downloader.java:37: ';' expected
private enum ReportFormat {
^
1 error


This is a portion of the code below
You must've left out something crucial here because that enum is definitely not
defined on line #37 and everything is syntactically fine in the code snippet you've
shown us. Something else (invisible to us) before that line is missing a semi
colon.

kind regards,

Jos
Oct 1 '08 #2
bw171
5
You must've left out something crucial here because that enum is definitely not
defined on line #37 and everything is syntactically fine in the code snippet you've
shown us. Something else (invisible to us) before that line is missing a semi
colon.

kind regards,

Jos
Here is the full code

Expand|Select|Wrap|Line Numbers
  1. /*
  2.  * $Header: //software/source/java/dev/src/edu/web2/layer/ccmdschooladmin/sampledownloader/Downloader.java#11 $
  3.  *
  4.  *  Copyright © 2005 NCS identiydme. All rights reserved.
  5.  */
  6.  
  7.  
  8.  
  9. import java.io.File;
  10. import java.io.FileOutputStream;
  11. import java.io.IOException;
  12. import java.io.InputStream;
  13. import java.io.OutputStream;
  14. import java.io.PrintStream;
  15. import java.io.UnsupportedEncodingException;
  16. import java.net.HttpURLConnection;
  17. import java.net.URL;
  18. import java.net.URLEncoder;
  19. import java.security.DigestOutputStream;
  20. import java.security.MessageDigest;
  21. import java.text.DateFormat;
  22. import java.text.SimpleDateFormat;
  23. import java.util.Date;
  24.  
  25. /**
  26.  * Sample tamg Score Data File Downloader.
  27.  *
  28.  * @version $Revision: #11 $ submitted $DateTime: 2008/08/18 14:43:29 $ by $Author: chetds $
  29.  * @author Dan Syrstad
  30.  */
  31. public class Downloader {
  32.     private static final String HOSTNAME = "wsr.identiydmeedu.com";
  33.     private static final String RELATIVE_URL = "/entry/tamg/download.jsp";
  34.     private static final DateFormat logDateFmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss: ");
  35.  
  36.     private static PrintStream logStream = System.out;
  37.     private enum ReportFormat {
  38.         TXT,
  39.         CSV;
  40.     };
  41.  
  42.     // Discourage instantiation
  43.     private Downloader() { }
  44.  
  45.     private static void emitUsageAndExit() {
  46.         log("Usage: Downloader [-file filename] [-log log-file] [-host hostname] [-format [TXT | CSV]] username password tamg-program-code [start-date end-date]");
  47.         System.exit(1);
  48.     }
  49.  
  50.     /**
  51.      * Main entry point.
  52.      *
  53.      * @param args arguments - see emitUsageAndExit().
  54.      */
  55.     public static void main(String[] args) {
  56.         if (args.length < 3) {
  57.             emitUsageAndExit();
  58.         }
  59.  
  60.         // Process command-line options.
  61.         File file = null;
  62.         String hostname = HOSTNAME;
  63.         String protocol = "https";
  64.         ReportFormat format = ReportFormat.TXT;
  65.  
  66.         int usernameIdx = 0;
  67.         for (int i = 0; i < args.length; i++) {
  68.             if (args[i].startsWith("-")) {
  69.                 if ( (i + 1) >= args.length) {
  70.                     emitUsageAndExit();
  71.                 }
  72.  
  73.                 final String option = args[i];
  74.                 ++i;
  75.                 final String value = args[i];
  76.                 usernameIdx = i + 1;
  77.  
  78.                 if ("-file".equals(option)) {
  79.                     file = new File(value);
  80.                     if (file.exists()) {
  81.                         log("Error: " + file + " already exists");
  82.                         System.exit(1);
  83.                     }
  84.                 } else if ("-log".equals(option)) {
  85.                     setLogFile(value);
  86.                 } else if ("-host".equals(option)) {
  87.                     hostname = value;
  88.                 } else if ("-format".equals(option)) {
  89.                     if ("txt".equalsIgnoreCase(value)) {
  90.                         format = ReportFormat.TXT;
  91.                     } else if ("csv".equalsIgnoreCase(value)) {
  92.                         format = ReportFormat.CSV;
  93.                     } else {
  94.                         log("Error: " + value + " is an invalid format (use either TXT or CSV.") ;
  95.                         System.exit(1);
  96.                     }
  97.                 } else if ("-secure".equals(option)) {
  98.                     if (Boolean.valueOf(value)) {
  99.                         protocol = "https";
  100.                     } else {
  101.                         protocol = "http";
  102.                     }
  103.                 } else {
  104.                     // Bad argument
  105.                     emitUsageAndExit();
  106.                 }
  107.             }
  108.         }
  109.  
  110.         if (args.length < (usernameIdx + 3)) {
  111.             emitUsageAndExit();
  112.         }
  113.  
  114.         // These parameters are positional.
  115.         final String username = args[usernameIdx];
  116.         final String password = args[usernameIdx + 1];
  117.         final String programCode = args[usernameIdx + 2];
  118.  
  119.         // Optional Date range must specify both dates.
  120.         String startDate = null;
  121.         String endDate = null;
  122.         if (args.length > (usernameIdx + 3)) {
  123.             if ((usernameIdx + 5) != args.length ) {
  124.                 emitUsageAndExit();
  125.             }
  126.  
  127.             startDate = args[usernameIdx + 3];
  128.             endDate = args[usernameIdx + 4];
  129.         }
  130.  
  131.         log("Downloader started.");
  132.  
  133.         int exitStatus;
  134.         try {
  135.             String urlStr = protocol + "://" + hostname + RELATIVE_URL +
  136.                 "?format=" + URLEncoder.encode(format.toString(), "UTF-8") +
  137.                 "&username=" + URLEncoder.encode(username, "UTF-8") +
  138.                 "&password=" + URLEncoder.encode(password, "UTF-8") +
  139.                 "&pgmCode=" + URLEncoder.encode(programCode, "UTF-8");
  140.             if (startDate != null) {
  141.                 urlStr += "&publishedStartDate=" + URLEncoder.encode(startDate, "UTF-8") +
  142.                     "&publishedEndDate=" + URLEncoder.encode(endDate, "UTF-8");
  143.             }
  144.  
  145.             final URL url = new URL(urlStr);
  146.  
  147.             exitStatus = downloadFile(url, file, format);
  148.         } catch (Exception e) {
  149.             log("Error: Exception received: " + getRootCause(e) );
  150.             exitStatus = 1;
  151.         }
  152.  
  153.         System.exit(exitStatus);
  154.     }
  155.  
  156.     /**
  157.      * Downloads a score data file from the given URL.
  158.      *
  159.      * @param url the URL.
  160.      * @param file the file to download to. Should be null if file name should be auto-generated.
  161.      *
  162.      * @return the exit status. 0 if succesful, else non-zero.
  163.      *
  164.      * @throws Exception if an error occurs.
  165.      */
  166.     private static int downloadFile(URL url, File file, ReportFormat format) throws Exception {
  167.         // Don't echo the password to the log...
  168.         String urlStr = url.toString();
  169.         urlStr = urlStr.replaceAll("&password=[^&]*", "&password=XXXXXXXX");
  170.         log("Opening URL: " + urlStr);
  171.  
  172.         final HttpURLConnection conn = (HttpURLConnection)url.openConnection();
  173.         final byte[] buf = new byte[1024];
  174.  
  175.         log("Response Code=" + conn.getResponseCode());
  176.         // If code is greater than 299 (300...), consider it an error
  177.         if ((conn.getResponseCode() % 100) > 2) {
  178.             // Read the message from the error stream.
  179.             final InputStream errStream = conn.getErrorStream();
  180.             String message = conn.getResponseMessage();
  181.             if (errStream != null) {
  182.                 try {
  183.                     message += ": ";
  184.                     int n;
  185.                     while ((n = errStream.read(buf)) > 0) {
  186.                         message += new String(buf, 0, n);
  187.                     }
  188.  
  189.                     // Replace all html tags and newlines with spaces.
  190.                     message = message.replaceAll("<[^>]*>", " ");
  191.                     message = message.replaceAll("[\\r\\n ]+", " ");
  192.                 } finally {
  193.                     errStream.close();
  194.                 }
  195.             }
  196.  
  197.             log("ERROR: Response indicated an error. Message: " + message);
  198.             return 1;
  199.         }
  200.  
  201.         log("Content-Type: " + conn.getContentType());
  202.         final long expectedLength = conn.getContentLength();
  203.         log("Content-Length: " + expectedLength);
  204.         final String md5Base64 = conn.getHeaderField("Content-MD5");
  205.         log("Content-MD5: " + md5Base64);
  206.         final String startDate = conn.getHeaderField("tamg-Published-Date-Range-Start");
  207.         log("tamg-Published-Date-Range-Start: " + startDate);
  208.         final String endDate = conn.getHeaderField("tamg-Published-Date-Range-End");
  209.         log("tamg-Published-Date-Range-End: " + endDate);
  210.         final String disposition = conn.getHeaderField("Content-Disposition");
  211.         log("Content-Disposition: " + disposition);
  212.  
  213.         // no file parameter was specified, so generate one
  214.         File outputFile;
  215.         if (null == file) {
  216.             // How many copies of the same date range are needed anyway? Probably just one...
  217.             for (long i = new Date().getTime(); ; i++) {
  218.                 String filename = "Scores-" + startDate + '-' + endDate + "-" + i + ".scoredata";
  219.                 if(ReportFormat.CSV == format) {
  220.                     filename += ".csv";
  221.                 }
  222.                 outputFile = new File(filename);
  223.                 if ( !outputFile.exists() ) {
  224.                     break;
  225.                 }
  226.             }
  227.         } else {
  228.             outputFile = file;
  229.         }
  230.  
  231.  
  232.         log("Downloading " + outputFile.getAbsolutePath() + "...");
  233.         final InputStream in = conn.getInputStream();
  234.  
  235.         // Use a DigestOutputStream wrapper to calculate the MD5 sum.
  236.         final MessageDigest digest = MessageDigest.getInstance("MD5");
  237.         final OutputStream out = new DigestOutputStream( new FileOutputStream(outputFile), digest);
  238.  
  239.  
  240.         long total = 0;
  241.         int recordCount = 0;
  242.         boolean exception = true;
  243.         byte[] calculatedMD5;
  244.  
  245.         try {
  246.             int n;
  247.             while ((n = in.read(buf)) >= 0) {
  248.                 out.write(buf, 0, n);
  249.                 total += n;
  250.                 for (int i = 0; i < n; i++) {
  251.                     if (buf[i] == (byte)'\n') {
  252.                         ++recordCount;
  253.                     }
  254.                 }
  255.             }
  256.  
  257.             out.flush();
  258.             calculatedMD5 = digest.digest();
  259.             exception = false;
  260.         } finally {
  261.             out.close();
  262.             in.close();
  263.  
  264.             if (exception) {
  265.                 outputFile.delete();
  266.             }
  267.         }
  268.  
  269.         // Ignore the header row 
  270.         if(ReportFormat.CSV == format && recordCount > 0) {
  271.             recordCount--;
  272.         }
  273.         if (total != expectedLength) {
  274.             outputFile.delete();
  275.             log("Download failed. Received length of " + total + " not equal to expected length of " + expectedLength);
  276.             return 1;
  277.         }
  278.  
  279.         // Check MD5 sum.
  280.         if (md5Base64 != null) {
  281.             // Encode our calculated sum to Base64.
  282.             final String calculatedMD5Base64 = Base64.encodeBytes(calculatedMD5);
  283.             //log("Calculated MD5Base64 sum: " + calculatedMD5Base64);
  284.             if ( !md5Base64.equals(calculatedMD5Base64) ) {
  285.                 outputFile.delete();
  286.                 log("Download failed. Calculated MD5Base64=" + calculatedMD5Base64 + " not equal to expected MD5Base64=" + md5Base64);
  287.                 return 1;
  288.             }
  289.  
  290.             log("File integrity verified. MD5 sums match.");
  291.         }
  292.  
  293.         log("Downloaded " + outputFile + " length=" + total);
  294.         log("Number of Records received: " + recordCount);
  295.         return 0;
  296.     }
  297.  
  298.     /**
  299.      * Logs a message.
  300.      *
  301.      * @param msg the message.
  302.      */
  303.     private static void log(String msg) {
  304.         logStream.println( logDateFmt.format( new Date() ) + msg);
  305.     }
  306.  
  307.     /**
  308.      * Sets the log file name and opens it for appending.
  309.      *
  310.      * @param logFileName the log file name.
  311.      */
  312.     private static void setLogFile(String logFileName) {
  313.         try {
  314.             logStream = new PrintStream( new FileOutputStream(logFileName, true) );
  315.         } catch (IOException e) {
  316.             log("ERROR opening log file: " + logFileName + ". Aborting.");
  317.             System.exit(1);
  318.         }
  319.     }
  320.  
  321.     /**
  322.      * Gets the root cause of an exception.
  323.      *
  324.      * @param e the exception.
  325.      *
  326.      * @return the most nested Throwable, which may be e if there is not a nested cause.
  327.      */
  328.     private static Throwable getRootCause(Exception e) {
  329.         Throwable cause = e;
  330.         while (cause.getCause() != null) {
  331.             cause = cause.getCause();
  332.         }
  333.  
  334.         return cause;
  335.     }
  336.  
  337.  
  338.     //----------------------------------------------------------------------
  339.     /**
  340.      * Public domain code to encode to Base64 notation.
  341.      * <p>dsyrstad: Extract just the encoding that we needed.
  342.      *
  343.      * <p>
  344.      * I am placing this code in the Public Domain. Do with it as you will.
  345.      * This software comes with no guarantees or warranties but with
  346.      * plenty of well-wishing instead!
  347.      * Please visit <a href="http://irdgner.net/base64">http://irdgner.net/base64</a>
  348.      * periodically to check for updates or to contribute improvements.
  349.      * </p>
  350.      *
  351.      * @author Robert rdgner
  352.      * @author rob@irdgner.net
  353.      * @version 2.1
  354.      */
  355.     public static final class Base64
  356.     {
  357.         /** No options specified. Value is zero. */
  358.         static final int NO_OPTIONS = 0;
  359.  
  360.         /** Don't break lines when encoding (violates strict Base64 specification) */
  361.         static final int DONT_BREAK_LINES = 8;
  362.  
  363.         /** Maximum line length (76) of Base64 output. */
  364.         private static final int MAX_LINE_LENGTH = 76;
  365.  
  366.         /** The equals sign (=) as a byte. */
  367.         private static final byte EQUALS_SIGN = (byte)'=';
  368.  
  369.         /** The new line character (\n) as a byte. */
  370.         private static final byte NEW_LINE = (byte)'\n';
  371.  
  372.         /** Preferred encoding. */
  373.         private static final String PREFERRED_ENCODING = "UTF-8";
  374.  
  375.         /** The 64 valid Base64 values. */
  376.         private static final byte[] ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".getBytes();
  377.  
  378.         /** Defeats instantiation. */
  379.         private Base64(){}
  380.  
  381.         /**
  382.          * Encodes up to three bytes of the array <var>source</var>
  383.          * and writes the resulting four Base64 bytes to <var>destination</var>.
  384.          * The source and destination arrays can be manipulated
  385.          * anywhere along their length by specifying
  386.          * <var>srcOffset</var> and <var>destOffset</var>.
  387.          * This method does not check to make sure your arrays
  388.          * are large enough to accomodate <var>srcOffset</var> + 3 for
  389.          * the <var>source</var> array or <var>destOffset</var> + 4 for
  390.          * the <var>destination</var> array.
  391.          * The actual number of significant bytes in your array is
  392.          * given by <var>numSigBytes</var>.
  393.          *
  394.          * @param source the array to convert
  395.          * @param srcOffset the index where conversion begins
  396.          * @param numSigBytes the number of significant bytes in your array
  397.          * @param destination the array to hold the conversion
  398.          * @param destOffset the index where output will be put
  399.          * @return the <var>destination</var> array
  400.          * @since 1.3
  401.          */
  402.         private static byte[] encode3to4(byte[] source, int srcOffset, int numSigBytes,
  403.                 byte[] destination, int destOffset )
  404.         {
  405.             //           1         2         3
  406.             // 01234567890123456789012345678901 Bit position
  407.             // --------000000001111111122222222 Array position from threeBytes
  408.             // --------|    ||    ||    ||    | Six bit groups to index ALPHABET
  409.             //          >>18  >>12  >> 6  >> 0  Right shift necessary
  410.             //                0x3f  0x3f  0x3f  Additional AND
  411.  
  412.             // Create buffer with zero-padding if there are only one or two
  413.             // significant bytes passed in the array.
  414.             // We have to shift left 24 in order to flush out the 1's that appear
  415.             // when Java treats a value as negative that is cast from a byte to an int.
  416.             final int inBuff =   ( numSigBytes > 0 ? ((source[ srcOffset     ] << 24) >>>  8) : 0 )
  417.                          | ( numSigBytes > 1 ? ((source[ srcOffset + 1 ] << 24) >>> 16) : 0 )
  418.                          | ( numSigBytes > 2 ? ((source[ srcOffset + 2 ] << 24) >>> 24) : 0 );
  419.  
  420.             switch( numSigBytes )
  421.             {
  422.                 case 3:
  423.                     destination[ destOffset     ] = ALPHABET[ (inBuff >>> 18)        ];
  424.                     destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ];
  425.                     destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>>  6) & 0x3f ];
  426.                     destination[ destOffset + 3 ] = ALPHABET[ (inBuff       ) & 0x3f ];
  427.                     return destination;
  428.  
  429.                 case 2:
  430.                     destination[ destOffset     ] = ALPHABET[ (inBuff >>> 18)        ];
  431.                     destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ];
  432.                     destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>>  6) & 0x3f ];
  433.                     destination[ destOffset + 3 ] = EQUALS_SIGN;
  434.                     return destination;
  435.  
  436.                 case 1:
  437.                     destination[ destOffset     ] = ALPHABET[ (inBuff >>> 18)        ];
  438.                     destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ];
  439.                     destination[ destOffset + 2 ] = EQUALS_SIGN;
  440.                     destination[ destOffset + 3 ] = EQUALS_SIGN;
  441.                     return destination;
  442.  
  443.                 default:
  444.                     return destination;
  445.             }   // end switch
  446.         }   // end encode3to4
  447.  
  448.  
  449.         /**
  450.          * Encodes a byte array into Base64 notation.
  451.          * Does not GZip-compress data.
  452.          *
  453.          * @param source The data to convert
  454.          * @return the encoded byte array
  455.          * @since 1.4
  456.          */
  457.         public static String encodeBytes( byte[] source ) {
  458.             return encodeBytes( source, 0, source.length, NO_OPTIONS );
  459.         }   // end encodeBytes
  460.  
  461.         /**
  462.          *    Encodes a byte array into Base64 notation.
  463.          *
  464.          *    @param source
  465.          *        data to be encoded.
  466.          *    @param off
  467.          *        offset into source of first byte to be encoded.
  468.          *    @param len
  469.          *        number of bytes to encode.
  470.          *    @param options
  471.          *        encoding options (see {@link Base64}).
  472.          *  @return the encoded String
  473.          *
  474.          *    @since 2.0
  475.          */
  476.         public static String encodeBytes( byte[] source, int off, int len, int options ) {
  477.             // Isolate options
  478.             final int dontBreakLines = ( options & DONT_BREAK_LINES );
  479.  
  480.              // Convert option to boolean in way that code likes it.
  481.             final boolean breakLines = dontBreakLines == 0;
  482.  
  483.             final int    len43   = len * 4 / 3;
  484.             final byte[] outBuff = new byte[   ( len43 )                      // Main 4:3
  485.                                        + ( (len % 3) > 0 ? 4 : 0 )      // Account for padding
  486.                                        + (breakLines ? ( len43 / MAX_LINE_LENGTH ) : 0) ]; // New lines
  487.             int d = 0;
  488.             int e = 0;
  489.             final int len2 = len - 2;
  490.             int lineLength = 0;
  491.             for( ; d < len2; d+=3, e+=4 ) {
  492.                 encode3to4( source, d+off, 3, outBuff, e );
  493.  
  494.                 lineLength += 4;
  495.                 if( breakLines && lineLength == MAX_LINE_LENGTH ) {
  496.                     outBuff[e+4] = NEW_LINE;
  497.                     e++;
  498.                     lineLength = 0;
  499.                 }   // end if: end of line
  500.             }   // en dfor: each piece of array
  501.  
  502.             if( d < len ) {
  503.                 encode3to4( source, d+off, len - d, outBuff, e );
  504.                 e += 4;
  505.             }   // end if: some padding needed
  506.  
  507.  
  508.             // Return value according to relevant encoding.
  509.             try {
  510.                 return new String( outBuff, 0, e, PREFERRED_ENCODING );
  511.             } catch (UnsupportedEncodingException uue) {
  512.                 return new String( outBuff, 0, e );
  513.             }   // end catch
  514.         }   // end encodeBytes
  515.     }   // end class Base64
  516. }
Oct 1 '08 #3
bw171
5
You must've left out something crucial here because that enum is definitely not
defined on line #37 and everything is syntactically fine in the code snippet you've
shown us. Something else (invisible to us) before that line is missing a semi
colon.

kind regards,

Jos
Also, would knowing the version help

java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
Oct 1 '08 #4
JosAH
11,448 Expert 8TB
(I just got back home) Yup, that's it: before version 1.5 Java didn't know about
enums; that's where the errors came from. Either don't use enums or upgrade
to at least version 1.5. btw. version 1.4 is ending it's EOL cycle anyway.

kind regards,

Jos
Oct 1 '08 #5
bw171
5
(I just got back home) Yup, that's it: before version 1.5 Java didn't know about
enums; that's where the errors came from. Either don't use enums or upgrade
to at least version 1.5. btw. version 1.4 is ending it's EOL cycle anyway.

kind regards,

Jos
Well that could be an entirely different post.....
Being a newbie, I am not sure how I would re code that to achieve what I want
Basically, i want to set the output of the report either as a CSV file or a TXT file.
Oct 1 '08 #6
JosAH
11,448 Expert 8TB
Well that could be an entirely different post.....
Being a newbie, I am not sure how I would re code that to achieve what I want
Basically, i want to set the output of the report either as a CSV file or a TXT file.
Just define a few final members of a reasonable type:

Expand|Select|Wrap|Line Numbers
  1. private static final String TXT= "TXT";
  2. private static final String CSV= "CSV";
  3.  
... and use those instead of the enum class.

kind regards,

Jos
Oct 2 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
18
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I have created an enum list like this: enum myEnum : int { This = 2, That, NewVal = 10, LastItm
21
by: dllhell | last post by:
hi all, I have a problem with creating proc with a enum as a param. I wish to pass an enumeration in proc in which one I intend to do some operations with enumeration, but I don't know which one...
2
by: snowie | last post by:
I have a simillar problem to what others have had before me. I just can't find the solution in any earlier post here at the scripts (or any other forum). I am calling a web service that returns a...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
2
by: audiokarate | last post by:
I have like atleast 15 errors that say class, interface, or enum expected and I have no idea what that means. Can someone tell me what it is and how I might be able to fix it? Thank you. - Manny...
15
by: judge82 | last post by:
I made sure I closed all the bracket, why do i still get the error. on line 360, 424, 425 and 607 Please help /* * ShopCartServletHW3.java *
8
by: benn | last post by:
Here's the setup... Defines.h file contains: enum DAY { monday, tueday }; DayFunctions.h contains prototype: void printIsMonday ( enum DAY currentDay); DayFunctions.c contains:
1
by: chanshaw | last post by:
Hey I'm trying to execute a simple statement but im getting a java.sql.Statement is abstract; cannot be instantiated. I just want to execute a simple select statement import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.