Solved

Java typesafe file parser

Posted on 2010-08-23
7
305 Views
Last Modified: 2012-05-10
I have a input file contains Color, Size and Shape like this:
RED LARGE TRIANGLE YELLOW SMALL SQUARE ...

Color would be RED YELLOW BLUE
Size would be LAREG SMALL MEDIUM
Shape would be TRIANGE CICLE SQUARE
All the three classes implements the same interface.

I need three bean classes which are Color, Size and Shape and driver class to read this file and loaded into each bean class and sort them, search them. Also I need make sure typesafe is used to make sure what is read is right. So Enum should be used for the bean classes.

0
Comment
Question by:SarahDeng
7 Comments
 

Author Comment

by:SarahDeng
ID: 33507856
I should give more details about this. Except those three bean classes, Color, Size and Shape which implements the same interface,
I have another bean class which has those three bean classes as property. e.g.
class MyClass{
      Color color;
      Size size;
      Shape shape;

}
And the driver class will read the file and load the input to MyClass, then sort MyClass.
0
 
LVL 11

Assisted Solution

by:Manish
Manish earned 100 total points
ID: 33507861
0
 

Author Comment

by:SarahDeng
ID: 33507937
I know how to read the file and parse them into those bean class, but I got stuck at how to use Color, Size, and Shape as Enum. which is typesafe.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:SarahDeng
ID: 33507958
Let me add more detail. The Color class would be like this
class Color{

    String color; //The color should be one of them, like RED BLUE YELLOW

    public String getColor(){
    return color;
    }
   public void setColor(String color){
   this.color = color;
   }
 }

The same thing for Size and Shape class.
0
 
LVL 92

Accepted Solution

by:
objects earned 300 total points
ID: 33507974
0
 
LVL 16

Assisted Solution

by:Valeri
Valeri earned 100 total points
ID: 33521017
0
 

Author Closing Comment

by:SarahDeng
ID: 33536063
Thanks!!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JList custom Cell Renderer refresh 15 57
session migration servlets 2 36
servlet filter example 37 61
String array comparison 4 33
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question