I went and tried to learn how to use Enum So I apologize for the lack of logical construction but I had
to start somewhere I have code that I am not sure how to use it because I don't know
how to call it so all the logic went down the tubes.
Can someone look at this and tell me if it is even possible?
If you have any clue what I am tring to do any feed back would be most usefull to say the least.

Thanks for your time.

I am tring to send the AvailablilityRecordEnum each of the processDates elements with its unique data to be
kept with it all the way to the insert.

private boolean prepareRecord(DateTime[] processDates) throws ... {

   
//set everything in one location

        DateTime startTimeField =         

LocationAvailableFormController.locationAvailableDataModel.locationAvailableBean.startTimeValue;
        DateTime endTimeField =         

LocationAvailableFormController.locationAvailableDataModel.locationAvailableBean.endTimeValue;

        LocationAvailableFormController.setStartTimeField(startTimeField);
        LocationAvailableFormController.setEndTimeField(endTimeField);
        LocationAvailableFormController.setLocationDesc(thisLocation);
        LocationAvailableFormController.setTableName(tableName);

//some how call the enum so it can throw my firs error...

       for (int i = 0; i < processDates.length; i++) {
            DateTime element = processDates[i];
          AvailabilityRecordEnum.LocationAvailableEnum();
        }
       
         return bDone;
    }

I just copied a structure that seemed logical and that I am done it makes no sense :

public enum AvailabilityRecordEnum {

    LocationAvailableEnum(LocationAvailableFormController.getAvailableDate(),
    LocationAvailableFormController.getStartTimeField(),
    LocationAvailableFormController.getEndTimeField(),
    LocationAvailableFormController.getEndDate(),
    LocationAvailableFormController.getLocationDesc(),
    LocationAvailableFormController.tableName);
   
    public DateTime dt; //  each record
    public static DateTime startDate;    
    public DateTime startHour;
    public DateTime endHour;
    public DateTime endDate;
    public String locationDesc;
    public int timeSlots;
    public String tableName;

    // Constructor
    AvailabilityRecordEnum(DateTime startDate,
            DateTime startHourField,
            DateTime endHourField,
            DateTime endDateConstant,
            String thisLocation,
            String thisTableName) {

        dt = startDate;
        startHour = startHourField;
        endHour = endHourField;
        endDate=endDateConstant;
        locationDesc=thisLocation;
        tableName=thisTableName;
        startHourToEndHourtimeSlots();
        
       /*
        *  deriveEndHourFromStartHour();
        deriveNewStartHour();
        */
    }

    private void startHourToEndHourtimeSlots() {

        int diff = JodaTimeUtil.differenceInHours(startHour, endHour);
        timeSlots = diff;
       

        setTimeSlots(timeSlots);

    }

    private void deriveNewStartHour() {


    }

    private void deriveEndHourFromStartHour() {

 

    }

    //_____________setters
    public DateTime getDt() {
        return dt;
    }

    public void setDt(DateTime dt) {
        this.dt = dt;
    }

    .......
    ..........

a class to make a record and insert it: the insert is not even close because I do not even know how to call an Enumeration

public class LocationAvailabilityRecordData {

  
    public AvailabilityRecordEnum availabilityRecordEnun;

    /*
     * <entry key="insertLocationAvailable">INSERT INTO location_Available(
    loc_desc,
    available_start_date,
    available_end_date,
    available_start_time,
    available_end_time)
    VALUES (?, ?, ?, ?, ?)
    </entry>
     */
  
    public String locationDesc;
    public String availableStartDate;
    public String availableEndDate;
    public String availableStartTime;
    public String availableEndTime;
    public String tableName;

    public LocationAvailabilityRecordData() throws SQLException, ...{

    
//////////////////////////        submit this //////////////////////////////////////



        locationDesc = availabilityRecordEnun.LocationAvailableEnum.locationDesc;
        availableStartDate = JodaTimeUtil.dateToString(availabilityRecordEnun.LocationAvailableEnum.getStartDate());
        availableEndDate = JodaTimeUtil.dateToString(availabilityRecordEnun.LocationAvailableEnum.getEndDate());
        availableStartTime = JodaTimeUtil.timeToString(availabilityRecordEnun.LocationAvailableEnum.getStartHour());
        DateTime inputEndDate = availabilityRecordEnun.LocationAvailableEnum.getEndDate();
        DateTime inclusiveEndTime = inputEndDate.plusHours(1);
        availableEndTime = JodaTimeUtil.timeToString(inclusiveEndTime);//end time is a product of time slots
        tableName = availabilityRecordEnun.LocationAvailableEnum.tableName;






        //_________on submit
        ConnectLocationAvailableDAO clad = new ConnectLocationAvailableDAO();
        ArrayList<String> columns = clad.countColumns(tableName);
        int columnCount = columns.size();
        String[] fillColumns = new String[columnCount];

        fillColumns[0] = locationDesc;
        fillColumns[1] = availableStartDate;
        fillColumns[2] = availableEndDate;
        fillColumns[3] = availableStartTime;
        fillColumns[4] = availableEndTime;




        //____________on submit
        AvailabilityFormActions rfa = new AvailabilityFormActions();
        rfa.locationAvailableRegisterAction(fillColumns);
    }

    public AvailabilityRecordEnum getAvailabilityRecordEnun() {
        return availabilityRecordEnun;
    }

    public void setAvailabilityRecordEnun(AvailabilityRecordEnum availabilityRecordEnun) {
        this.availabilityRecordEnun = availabilityRecordEnun;
    }

  

    public String getAvailableEndDate() {
        return availableEndDate;
    }

    public void setAvailableEndDate(String availableEndDate) {
        this.availableEndDate = availableEndDate;
    }

    more setters ....
    ....................

Why not start with a smaller program to get the techniques down. Then you could post it when you have problems.
The posted code here is just too big for most people to work with.

Thanks for that link. I have seen that an a few others and the problem right from the
start is that all the examples I have seen ,probably for good reason, instantiate
constants that never change.

I have seen constants set up as:

enum Grade {
 A, B, C, D, F, INCOMPLETE
 };

and I just looked at an Enumeration that gets initialized by a class

enum AntStatus {
  INITIALIZING,
  COMPILING,
  COPYING,
  JARRING,
  ZIPPING,
  DONE,
  ERROR
}
public class AntStatusTester {

  public AntStatusTester() { }

  public void testEnumMap(PrintStream out) throws IOException {
    // Create a map with the key and a String message
    EnumMap<AntStatus, String> antMessages =
      new EnumMap<AntStatus, String>(AntStatus.class);

    // Initialize the map
    antMessages.put(AntStatus.INITIALIZING, "Initializing Ant...");
    antMessages.put(AntStatus.COMPILING,    "Compiling Java classes...");
    antMessages.put(AntStatus.COPYING,      "Copying files...");
    antMessages.put(AntStatus.JARRING,      "JARring up files...");
    antMessages.put(AntStatus.ZIPPING,      "ZIPping up files...");
    antMessages.put(AntStatus.DONE,         "Build complete.");
    antMessages.put(AntStatus.ERROR,        "Error occurred.");

I do not have a grasp of this yet because I would probably try to change my code to some how initialize my

LocationAvailableEnum

as some kind of list as apposed to the above map. I guess I am not clear on what would be possible because my rough I posted earlier needs to feed a set of data into the Enumeration and be able to change the data for each element in

for (int i = 0; i < processDates.length; i++) {
            DateTime element = processDates[i];
         //LocationAvailableEnum();
        }

Clearly I am not grasping some basic concept.
Thanks

An enum is, by definition, a set of constants that never change, eg the days of the week. In this case AntStatus has exactly seven constant values that never change.
The rest of that code uses a map (enum constant as key, text as value) to link each of those constants to a descriptive String.
ps That's a poor way to do that. The enum implementation in Java is powerful enough for you to implement those descriptive strings directly in the enum itself.

I will have to scrap this Enumeration and revert back to my convoluted cluster
of for loops and multi dimensional arrays intialized by lists lol

Because I do not see how these Enums load in the first place because the pattern
below is almost the same as a constants (objects) having parameters but instead of
it being a

LocationAvailableConstant("2011-06-27", ect

I expect it to get that value from another class.

I guess there is no way to make a re-usable Enumeration.

thanks anyway.

public enum AvailabilityRecordEnum {

    LocationAvailableConstant(LocationAvailableFormController.getAvailableDate(),
    LocationAvailableFormController.getStartTimeField(),
    LocationAvailableFormController.getEndTimeField(),
    LocationAvailableFormController.getEndDate(),
    LocationAvailableFormController.getLocationDesc(),
    LocationAvailableFormController.tableName);
    private DateTime dt;
    private DateTime startHour;
    private DateTime endHour;
    private DateTime endDate;
    private String locationDesc;
    private String tableName;
    private int timeSlots;
    
    AvailabilityRecordEnum(DateTime startDate,
            DateTime startHourField,
            DateTime endHourField,
            DateTime endDateConstant,
            String thisLocation,
            String thisTableName) {

        dt = startDate;
        startHour = startHourField;
        endHour = endHourField;
        endDate = endDateConstant;
        locationDesc = thisLocation;
        tableName = thisTableName;
        startHourToEndHourtimeSlots();
        
    }
    private void startHourToEndHourtimeSlots() {


        int diff = JodaTimeUtil.differenceInHours(startHour, endHour);
        timeSlots = diff;
      
        setTimeSlots(timeSlots);

    }

    public int getTimeSlots() {
        return timeSlots;
    }

    public void setTimeSlots(int timeSlots) {
        this.timeSlots = timeSlots;
    }
    
    

}

enums are fully defined in the source code and are in effect initialised when they are loaded by the classloader. There is nothing you can do to change their values at run time. So if you need to do something else, enums are not the solution.
Can you give a simple description of what it is you are trying to achieve?

enums are fully defined in the source code and are in effect initialised when they are loaded by the classloader. There is nothing you can do to change their values at run time. So if you need to do something else, enums are not the solution.
Can you give a simple description of what it is you are trying to achieve?

Thank you that was my problem I was ignorant of how the Enumerations were loaded.
not a good thing. so I worked around a new constructor.

Actually the data types concern me here because I am not sure of if they will be usefull. My form sets the said
setters with different data types and my values() returns some good data yet the first column represents
the date that should be changing so I changed the constructor on my class that uses the Enumeration to track
the new "element". I have to evaluate the results too but this is what I returned.

thanks for your time.

 private boolean prepareRecord(DateTime[] processDates) throws SQLException, FileNotFoundException, IOException {

        bDone = true;



        DateTime startTimeField = 

LocationAvailableFormController.locationAvailableDataModel.locationAvailableBean.startTimeValue;
        DateTime endTimeField = 

LocationAvailableFormController.locationAvailableDataModel.locationAvailableBean.endTimeValue;

        LocationAvailableFormController.setStartTimeField(startTimeField);
        LocationAvailableFormController.setEndTimeField(endTimeField);
        LocationAvailableFormController.setLocationDesc(thisLocation);
        LocationAvailableFormController.setTableName(tableName);

       for (int i = 0; i < processDates.length; i++) {
            DateTime element = processDates[i];
            LocationAvailableFormController.setAvailableDate(element);
            InitalizeData id =new InitalizeData(element);
        }


         return bDone;
    }

InitalizeData.java

public InitalizeData(DateTime element) {

    for(AvailabilityRecordEnum data : AvailabilityRecordEnum.values()){
        System.out.printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n", element,data.getEndDate(),data.getEndHour(),
                data.getStartHour(),data.getTimeSlots(),data.getLocationDesc(),data.getTableName());
    }

}

some output:

Monday<----looking for
Wednesday<----looking for
Friday<----looking for
2011-06-01T16:00:00.000-05:00 is a Wednesday: [Lorg.joda.time.DateTime;@14ab90d[+0+]: 

2011-06-03T16:00:00.000-05:00 is a Friday: [Lorg.joda.time.DateTime;@14ab90d[+1+]: 

2011-06-06T16:00:00.000-05:00 is a Monday: [Lorg.joda.time.DateTime;@14ab90d[+2+]: 

2011-06-08T16:00:00.000-05:00 is a Wednesday: [Lorg.joda.time.DateTime;@14ab90d[+3+]: 

2011-06-10T16:00:00.000-05:00 is a Friday: [Lorg.joda.time.DateTime;@14ab90d[+4+]: 

2011-06-13T16:00:00.000-05:00 is a Monday: [Lorg.joda.time.DateTime;@14ab90d[+5+]: 

2011-06-15T16:00:00.000-05:00 is a Wednesday: [Lorg.joda.time.DateTime;@14ab90d[+6+]: 

2011-06-17T16:00:00.000-05:00 is a Friday: [Lorg.joda.time.DateTime;@14ab90d[+7+]: 

2011-06-20T16:00:00.000-05:00 is a Monday: [Lorg.joda.time.DateTime;@14ab90d[+8+]: 

2011-06-22T16:00:00.000-05:00 is a Wednesday: [Lorg.joda.time.DateTime;@14ab90d[+9+]: 

2011-06-24T16:00:00.000-05:00 is a Friday: [Lorg.joda.time.DateTime;@14ab90d[+10+]: 

2011-06-27T16:00:00.000-05:00 is a Monday: [Lorg.joda.time.DateTime;@14ab90d[+11+]: 

2011-06-29T16:00:00.000-05:00 is a Wednesday: [Lorg.joda.time.DateTime;@14ab90d[+12+]: 

 --> in  private boolean prepareRecord(13) var: (DateTime[] processDate)<-- 

2011-06-01T16:00:00.000-05:00: 13[+0+]: 

2011-06-03T16:00:00.000-05:00: 13[+1+]: 

2011-06-06T16:00:00.000-05:00: 13[+2+]: 

2011-06-08T16:00:00.000-05:00: 13[+3+]: 

2011-06-10T16:00:00.000-05:00: 13[+4+]: 

2011-06-13T16:00:00.000-05:00: 13[+5+]: 

2011-06-15T16:00:00.000-05:00: 13[+6+]: 

2011-06-17T16:00:00.000-05:00: 13[+7+]: 

2011-06-20T16:00:00.000-05:00: 13[+8+]: 

2011-06-22T16:00:00.000-05:00: 13[+9+]: 

2011-06-24T16:00:00.000-05:00: 13[+10+]: 

2011-06-27T16:00:00.000-05:00: 13[+11+]: 

2011-06-29T16:00:00.000-05:00: 13[+12+]: 

The data from the Enumeration : the first column below "elememt" is now changing
So it looks promising and one for loop in my form is much better than the other
80 lines of code.

2011-06-01T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-03T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-06T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-08T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-10T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-13T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-15T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-17T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-20T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-22T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-24T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-27T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
2011-06-29T16:00:00.000-05:00        2011-06-30T16:00:00.000-05:00        2011-06-01T20:00:00.000-05:00        2011-06-

01T16:00:00.000-05:00        4        south side        LOCATION_AVAILABLE
 --> in  public void actionPerformed(javax.swing.JButton) var: (ActionEvent evt)<-- 

 --> in  public void actionPerformed(javax.swing.JButton) var: (ActionEvent evt)<-- 

 --> in  public void updateBtnAction() var: xxxxxxxxx : xxxxxxxx<-- 

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.