Help, how  would I store an array of objects ?

im doing a java project on creating a music database, i need to store an array of cd objects, each entry in the array will be a single object for a cd.
The objects are: Artist, Album, No of tracks
could sum1 point me in d right direction, thanks

This is the wrong forum. Please ask again in the [new to java forum|http://forum.java.sun.com/forum.jspa?forumID=54] .
Assuming you want to store them on disk, you can either use a database (java technologies for this is JDBC and JPA ) or write them to a file using the java technologies Serialization or Beans Persistence.

Similar Messages

  • How would you store a primitive type?

    Hello
    How would you store a primitive type in a Collection such as a List?
    Thanks
    Bobby

    <face grin=evil> myList.add(int.class); </face>

  • How can i store bytes array in MS ACCESS???

    Hi,
    i m making small project using Ms Access as a dataBase.
    In which i am encripting some confidential data say ACCOUNT_NAME and storing it into MS Access in encripted form........
    The problem is encripted data is in bytes array n how can i store it into MS access ??? is there any data type similar to BLOB in Ms Access ??
    please help me................
    i had searched net for this but till now not found any useful info :(

    You can try:
    binay type (JET3 255 bytes,JET4 510) Types.BINARY
    ole type (0~1 G) Types.LONVARBINARY
    You can use Text (JET3 255 bytes�CJET4 510bytes) Types.VARCHAR if you use base64 encoding for
    ACCOUNT_NAME column.

  • How Does On Reference An Array Of Objects?

    Howdy!
    Ive read through Flex 2's help and also through the wonderful
    book 'Developing Rich Clients With Flex' for topics relating to
    this question but very strangely with no luck (and I assume it's
    quite straight forward)! So hopefully you chaps can help...
    Now, to get a value from an object model is very straight
    forward -
    quote:
    <mx:Model id="MyModel">
    <Inbox>
    <Message>
    <Sender>[email protected]</sender>
    <Subject>Blah Blah</Subject>
    <Content>This is the content of the
    email!</Content>
    </Message>
    </Inbox>
    </mx:Model>
    To get the <Sender> value its a simple case of -
    quote:
    MyModel.Inbox.Message.Sender
    Because obviously 'Sender' is just an object. But when I have
    an array of objects like so -
    quote:
    <mx:Model id="MyModel">
    <Inbox>
    <Message>
    <Sender>[email protected]</sender>
    <Subject>Blah Blah</Subject>
    <Content>This is the content of the
    email!</Content>
    </Message>
    <Message>
    <Sender>[email protected]</sender>
    <Subject>Blah Blah</Subject>
    <Content>This is the content of the
    email!</Content>
    </Message>
    </Inbox>
    </mx:Model>
    How do I reference the individual 'Sender' objects?
    Any help would really perk up my day :-)
    Thanks

    Thank you kindly!
    Just one more question (i'd select a different forum but it's
    related to this)...
    How would I loop through e.g.
    MyModel.Inbox.Message.Sender[n], from within a dataProvidor for a
    repeator?
    I'm basically creating a UI which is based on template data
    stored in an external data model which is using nested loops -
    Data Model
    quote:
    <TemplatesConfigurator>
    <Template label="Elite II" table="tbl_Category" id="2"
    description="Elite II So Quote Template 00038_TMP_V9">
    <Category label="Heading - Base System Elite"
    table="tbl_CategorySub" id="1">
    <CategorySub label="Base System" table="tbl_CategorySub"
    id="4">
    <Parts1 label="08639" table="tbl_Template"
    id="1"></Parts1>
    </CategorySub>
    <CategorySub label="Elite II (included in base system)"
    table="tbl_CategorySub" id="5">
    <Parts1 label="05356" table="tbl_Template"
    id="2"></Parts1>
    <Parts1 label="03703" table="tbl_Template"
    id="3"></Parts1>
    <Parts1 label="05904" table="tbl_Template"
    id="4"></Parts1>
    <Parts1 label="06327" table="tbl_Template"
    id="5"></Parts1>
    <Parts1 label="06767" table="tbl_Template"
    id="6"></Parts1>
    </CategorySub>
    </Category>
    <Category label="Heading - Support Contracts &
    Warranty" table="tbl_CategorySub" id="28">
    <CategorySub label="Support Contract Options "
    table="tbl_CategorySub" id="29">
    </CategorySub>
    <CategorySub label="Warranty Options"
    table="tbl_CategorySub" id="30">
    </CategorySub>
    </Category>
    </Template>
    </TemplatesConfigurator>
    Repeaters
    quote:
    <mx:Repeater id="r1"
    dataProvider="{TemplateConfiguratorData.lastResult.TemplatesConfigurator.Template}">
    <mx:Form height="100%" width="100%"
    horizontalScrollPolicy="off" paddingBottom="0" paddingLeft="0"
    paddingRight="0" paddingTop="0" backgroundColor="#ffffff"
    verticalScrollPolicy="auto">
    <mx:Label
    text="{TemplateConfiguratorData.lastResult.TemplatesConfigurator.Template.label}"
    fontWeight="bold" fontSize="13" paddingBottom="0"/>
    <mx:Text
    text="{TemplateConfiguratorData.lastResult.TemplatesConfigurator.Template.description}"
    fontSize="10"/>
    <mx:Repeater id="r2"
    dataProvider="{TemplateConfiguratorData.lastResult.TemplatesConfigurator.Template.Categor y}">
    <mx:Label id="SubHeadings" text="{r2.currentItem.label}"
    fontWeight="bold" fontSize="12"/>
    <mx:Repeater id="r3" dataProvider="{
    TemplateConfiguratorData.lastResult.TemplatesConfigurator.Template.Category[0].CategorySub}">
    <mx:Label text="{r3.currentItem.label}" fontWeight="bold"
    fontSize="10"/>
    </mx:Repeater>
    </mx:Repeater>
    </mx:Form>
    </mx:Repeater>

  • Need help: How to key in input array, save in a buffer, and extract them later?

    Hi, I need help. I have several groups of data for input, and need to use them later in the same or different code. When I key in the input data, the code will ask the number of data group first, then in each group, there will be 6 data to key in, each has a specific variable name. The number of group and the data for each group will vary at each time running the code. The data group needs to be numbered sequently. After having all groups of data, these data will be sent to another sub VI to read. This sub VI needs to know each group number and each data of a group.
    I think I should create a 2-D array to read these data in a do loop, but I can't let my do loop read data in each time. Then when I sent the data out, the next sub VI was confused by the sequence of the data group and the sequence of data in each group. Can someone help me or give me some example how to do it? Thank you very much for your help.
    Message Edited by ccyang on 06-06-2006 10:37 AM

    From what I understand of your explanation, an event structure might be
    the way to go (LV 6+ I think).  Events could be based off of
    keypresses in a particular control (a 2D array like you mentioned), and
    once input in that particular field is complete, the user presses say
    the 'enter' key, and you can use the "VKey" of the event data node to
    determine which key is pressed (i.e. VKey = enter?).  From there,
    you would continue to the next portion of data entry or processing of
    entered information.
    Hope this helps.

  • How do u make an array of objects

    I have 2 classes Helper and HelperWorker
    Helper has a constructor which looks like this public
    Helper(String Iname, double IhoursWorked) {
              name = Iname;
              hours = IhoursWorked;
    }I have two arrays in the HelperWorker class with the following values
    String Names[] = {"Tim Brown","Jack Blink","Pat Gold","Jim Done","Eloise Tricot"};
         double Work[] = {35,50,34,22,71};I need to create an array of Helper class objects, using the arrays Names and Work, representing 5 helpers with hours each of them worked.
    can some one help becuse i can not see any way I used a forloop to create an object but that only Initialize s the same object x number of times. also on arrays i wanted to know if i want to change the values of array x[2] with a varible y how do i append or replace the value at x[2].

    Try this:
    class Helper
         private String name="";
         private double hours;
         Helper(String Iname, double IhoursWorked)
              name = Iname;     
              hours = IhoursWorked;
         public void print()
              System.out.println("\nName : " +name);
              System.out.println("Hours : " +hours);
    public class HelperWorker
         String Names[] = {"Tim Brown","Jack Blink","Pat Gold","Jim Done","Eloise Tricot"};     
         double Work[] = {35,50,34,22,71};
         Helper[] helperArray=new Helper[Names.length];
         HelperWorker()
              Helper temp=null;
              for(int i=0;i<Work.length;i++)
                   temp=new Helper(Names,Work[i]);
                   helperArray[i]=temp;
              for(int i=0;i<Work.length;i++)
                   helperArray[i].print();     
         public static void main(String s[])
              new HelperWorker();

  • How Would One Go About Making an Object Rotate to Face in Direction of Mouse?

    I'm just a teenager who happens to have Flash as part of CS4 Production Premium, which I got as a gift.  I don't have any training or previous experience in Flash, and have only just in the past few month been looking into what ActionScript is.  I've just been fiddling with Flash in my spare time, just as something to do, and am working on making very basic computer games.  Currently I am trying to make a very basic top-down shooter computer game.  I've gotten it to where I can move the player (a circle with an arrow on the edge) in eight directions using the standard FPS movement keys (W,A,S,D) and make it move faster for a limited time by holding down the SHIFT key. 
    But now I've come to a standstill.  I am trying to make the player rotate in the direction of the mouse cursor (made to look like crosshairs) so that the player can move in any of the eight directions and aim in any direction at the same time.  I've searched the Internet for hours on end, looking for anything that might help, but not a single Web page section relates to this kind of thing.  So now I'm giving up on searching for a help article, and am making one instead.  Is there anyone that's successfully done this kind of thing before?  Or at least someone who actually knows how to properly use ActionScript 3.0 and can figure it out themselves, then tell me what they did?   (In the meantime, I've made it so that the player rotates and faces in the direction he is traveling in.)
    I've attatched all the code that I've typed to make the game work, so that anyone can look at it and tell me if I'm doing something wrong already.  I've only been learning ActionScript by figuring it out on my own as I go (watched a few videos I have on a disc too), and in the case of this game, I've just been making is up as I go, so to all of you people who actually know this stuff pretty well, this code is probably going to look nasty.

    I pasted it to the bottom of my code on the main timeline (correcting it for my use), but I get this message in the Compiler Errors window:
    Warning: 1090: Migration issue: The onMouseMove event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0.  You must first register this handler for the event using addEventListener ( 'mouseMove', callback_handler).
    So what do I do about that?  (again, I'm just a beginner, so I don't know what any of this means)
    (attached is a snapshot of the various objects refered to in the code.  also the original code is attached to the original post.  in case these help at all.)

  • How would I change JLabel and place object randomly

    hello, I am trying to make sort of a one-sided Battleship game and I have an 8X8 Grid-Layout and do have the MouseListener set up to when one is clicked the color changes. How can I make it so when one is clicked, the word "MISSED" or a graphic of a big X is layed across the appropriate square? Also, is it possible to lay an object down randomly over 3 or so different squares? Here's my code:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.event.*;
    public class CreateBoard extends JFrame
    public static void main(String[] args)
    {   JFrame board = new CreateBoard();
    public CreateBoard()
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setPreferredSize(new Dimension(600,600));
    setTitle("BattleShip");
    getContentPane().setLayout(new GridLayout(8,8));
    for (int i = 0; i < 8; i++)
    {   for (int j = 0; j < 8; j++)
    getContentPane().add(new GameSpace());
    pack();
    setVisible(true);
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class GameSpace extends JPanel
    {   GameSpace()
    setBackground(Color.WHITE);
    Border borderColor = BorderFactory.createLineBorder(Color.BLACK);
    setBorder(borderColor);
    addMouseListener(new MouseClickListener());
    class MouseClickListener extends MouseAdapter
    {   public void mouseClicked(MouseEvent evt)
    setBackground(Color.LIGHT_GRAY);
    repaint();
    Thanks

    You could perhaps make use of some JButtons.
    * Tweak the border property so noone can tell it's buttons (that is of course if you don't want anyone to see they are buttons...)
    * start with no text on the buttons
    * when a button is clicked -> change colors, put some text or icon on the button or something
    What I'm suggesting is basically that your GameSpace class extends JButton (or perhaps JToggleButton if you want to make use of two "states") instead of JPanel...

  • How would you do uneven distribution of objects?

    I whish the Transform Each... tool had a feature allowing specified number of copies along with the Skew feature that is available in the Grid tool.
    So far I've been doing this by using the Grid tool as a reference and manually arranging objects which is a big pain in the a**
    Anyone knows a better way?
    or another vector program, plug in, script, etc?
    This is a piece of cake in most 3D programs which is a much more complex task for the 3D programmers and I can't believe that Illustrator still doesn't have such essential tool.

    Emil,
    Any brush approach wil lead to trouble in a case like this because they will either give you misalignment with the path or distortion.
    A blend approach may do it.
    In addition to what Steve just said (I had to leave while writing the following, and saw his new post #13):
    Your grid approach (upper row) seems to lead to a strange decrease pattern (reduction in distance between pairs of vertical stroked paths),
    The first decrease being 3.449 pt, the next three being 2.821, 2.823, and 2.822 (constant), then 3.507 and back to 2.822 again
    The last five decreases being 0.314, 0.626, 0.631, 0.338, and 0.002.
    Your blend approach (lower row) seems quite consistent with a decrease pattern (reduction in distance between (outer bounds of) pairs of squares) that has a constantly decreasing decrease (the change in the reduction to the next pair) of about 0.053 (with slight variations between 0.049 and 0.057, and leading to an intriguing end game where the reduction is actually increased.
    The blend made by Steve seems to lead to an exponentially decreasing decrease (something like 1/1.1875, corresponding to an increasing increase from right to left by the factor 1.1875). I am afraid we should have to ask Teri what the exact relation between handle lengths and nature of decreasing decrease is; I believe it is somewhat complex with (at least) two different handle lengths.
    As it appears, I believe your grid approach is less useful than it seems.
    Depending on the desired nature of the decrease/increase (depending on which end you start with) you may do it in a few different ways, including the blends mentioned above.
    If you wish to really control the decrease/increase, I am afraid you will have to use a more laborious blend approach, a bit similar to the one in this thread with a fake blend:
    http://forums.adobe.com/thread/808345?tstart=30
    Possible approach:
    Using a blend to fill a full circle, be aware that you need to cut the circle where you wish the blend to start/stop, and that the first/last objects are on top of each other so you need one extra.
    Preparing the contents of the fake blend:
    If you want a specific exponentially decreasing/increasing decrease/increase, you may, using the Alt/Option+O+T+M shortcut (or something similar) to copy:
    1) Create the basic object and the first copy, inserting the first distance;
    2) For the next distance insert the percentage distance (110% for a 10% increasing increase, or similar) and copy the percentage distance;
    3) For the following distances, until you have them all, insert the copied percentage distance instead of the current value (in this case you just get 110%);
    If you want a specific constantly decreasing/increasing decrease/increase, you may, using the Alt/Option+O+T+M shortcut (or something similar) to copy:
    1) Create the basic object and the first copy, inserting the first distance;
    2)  For the next distance add/subtract the constant change of distance (+2pt for a 2pt  increasing increase, or similar) and copy the constant change of distance;
    3) For the following distances, until you have them all, insert the constant change of distance after the current value (in this case you get the current value +2pt);
    To create the fake blend, you may:
    4) Object>Blend>Options set Spacing to Specified Steps with the value 1 and Orientation to Align to Path;
    5) Select all objects and Object>Blend>Make, now you have surplus objects in between the desired objects, see 8).
    To finish the work, you may:
    6) Apply the blend to the (cut) circle;
    7) Object>Blend>Expand;
    8) Delete the surplus objects.
    I hope this was not too easy (to understand).

  • An array of objects

    Hi,
    I'm having trouble creating an array of objects to store data I'm reading in from a text file.
    I have created a class called mssg, and as I read each line of the textfile in, I've created a method called setMsg that I'm using to populate the mssg object I've created.
    This works fine when I use this method on a single instance of a mssg object, but when I try to use the same code on a mssg object that's part of an array, I get an exception (and one that doesn't have any friendly error text)
    mssg ms = new mssg();  //this works as expected
    mssg msgs[] = new mssg [msgCounter]; //I believe the exception relates to how I'm declaring the array of objects here, but the exception doesn't occur until I try to assign data to an element of the arrayThe lines below are where the problem becomes apparent. The first object 'ms' gets assigned its values as I'd expect, however, the line below that tries to assign values to a mssg object in the msgs array, and I get an exception immediately.
    ms.setMsg(currMsg,mDt,mTm,mDir,mData);
    msgs[currMsg].setMsg(currMsg,mDt,mTm,mDir,mData);Can anyone tell me what I'm doing wrong in terms of declaring/assigning values to an array of objects?

    It's the following error: java.lang.NullPointerException
    Full error text if I take my code out of a try/catch loop is:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at FIXparserUI.jMenuLoadActionPerformed(FIXparserUI.java:301)
            at FIXparserUI.access$100(FIXparserUI.java:20)
            at FIXparserUI$3.actionPerformed(FIXparserUI.java:129)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1170)
            at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1211)
            at java.awt.Component.processMouseEvent(Component.java:6038)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
            at java.awt.Component.processEvent(Component.java:5803)
            at java.awt.Container.processEvent(Container.java:2058)
            at java.awt.Component.dispatchEventImpl(Component.java:4410)
            at java.awt.Container.dispatchEventImpl(Container.java:2116)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
            at java.awt.Container.dispatchEventImpl(Container.java:2102)
            at java.awt.Window.dispatchEventImpl(Window.java:2429)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)at the point that the following line of code is run:
    msgs[currMsg].setMsg(currMsg,mDt,mTm,mDir,mData);msgCounter is used to count the number of lines in the file (about 2300)
    I had hoped that what I was doing with this line:
    mssg msgs[] = new mssg [msgCounter];was create 2300 empty mssg records, ready to be populated from each line of data, however I have the feeling you're going to tell me I'm wrong.

  • Urgent query about copying array of objects to html item

    I have an urgent query about how I can display an array of objects on a html form. The only suitable html item I can see for this is a drop down box. Ideally a combo box would be preferable but I cant find anything like this. Basically the display item needs to contain 3 columns of data and has to display a number of rows. Can anyone tell me how to copy the array of values into a drop down box?

    Here is all the code from my jsp. It keeps returning null:
    <%@ page language="java" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ page import="java.util.*, java.lang.*" %>
    <html:html locale="true">
    <head>
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"/>
    <link rel="stylesheet" type="text/css" name="timesheet" href="stylesheets/timesheet.css"></link>
    <script type="text/javascript" language="javascript" src="javascript/sum.js"></script>
    <title><bean:message key="eng.title"/></title>
    <html:base/>
    </head>
    <body bgcolor="white">
    <table border="0" width="100%">
    <tr>
    <td width="30%"><html:img page="/images/PwC_logo.gif"/></td>
    <td width="40%" class="applicationTitleCell">
    <div align="center">
    <bean:message key="application.title"/>
    </div>
    </td>
    <td width="30%"> </td>
    </tr>
    </table>
    <center>
    <html:form action="/selectEng" focus="engSearchNumber">
    <table border="0" width="100%">
    <tr>
    <td width="30%"></td>
    <td width="20%" align="center"> <b> <bean:message key="eng.prompt.engSearchNumber"/> </b> </td>
    <td width="20%" align="center"> <b> <bean:message key="eng.prompt.clientSearchName"/> </b> </td>
    <td width="40%">   </td>
    </tr>
    <tr>
    <td width="30%"></td>
    <td width="20%" align="center"> <html:text property="engSearchNumber" size="20" maxlength="9" onchange='<%= "SearchLength(this)" %>' onkeypress="return NumberOnly()" /> </td>
    <td width="20%" align="center"> <html:text property="clientSearchName" size="20" maxlength="20" onchange='<%= "SearchLength(this)" %>'/> </td>
    <td width="30%">   </td>
    </tr>
    </table>
    <table border="0" width="100%">
    <tr>
    <td width="30%"></td>
    <td width="40%" align="center"><html:image property="findButton" src="images/Find.gif" alt="Find"/></td>
    <td width="30%">   </td>
    </tr>
    <jsp:useBean id="selectEngForm" scope="session" class="Time.SelectEngForm" />
    <% if (selectEngForm.getEngSearchNumber() != null) { %>
    <tr>
    <td width="30%"></td>
    <td width="40%" align="center"><select name="engListing" size="5">
    <%= selectEngForm.getEngListing() %>
    </select></td>
    <td width="30%">   </td>
    </tr>
    <% } else if (selectEngForm.getClientSearchName()!=null){ %>
    <tr>
    <td width="30%"></td>
    <td width="40%" align="center"><select name="engListing" size="5">
    <%= selectEngForm.getEngListing()%>
    </select></td>
    <td width="30%">   </td>
    </tr>
    <% } %>
    <%=request.getParameter("engListing")%>
    </table>
    <br><br>
    <table border="0" width="100%">
    <tr>
    <td width="30%"></td>
    <td width="11%" align="center"> <html:image property="addButton" src="images/Add.gif" alt="Add the selected engagement to the timesheet"/> </td>
    <td width="11%" align="center"> <html:image property="cancelButton" src="images/Cancel.gif" alt="Cancel"/> </td>
    <td width="30%">   </td>
    </tr>
    </table>
    </html:form>
    </center>
    <br>
    <center><html:link forward="timesheet"> <html:img src="images/Back.gif" border="0"/> </html:link></center>
    </body>
    </html:html>

  • How do you store parsed XML data in an array

    Hi, i am trying to complete a small program which implements the SAX parser to parse an XML file. My problem is that i am writing a custom class to store the parsed data into an array, and then make the array available to the main program via a simple method which returns the array. I know this must be very simple to do, but i seem to have developed a mental block with this part of the program. I can parse the data and print all the elements to the screen, but i just cant figure out how to store all the data elements into the array. I will post the class which is supposed to do this, and ask anyone out there if they know what i'm doing wrong, and also, if there is a more effeicient way of achieving this ( i expect there definitely is!! but i have never used the SAX parser before and am getting confused by the API docs on it!!) Any help very much appreciated.
    Here is my attempt at coding the class to handle the parsed XML data
    class Sink extends org.xml.sax.helpers.DefaultHandler
         implements org.xml.sax.ContentHandler{
    Customer[] customers = new Customer[20];
         int count = 1;
         int x = 0;
         int tagCount = 0;
         String name;
    String custID;
         String username;
         String address;
         String phoneNum;
    public void startElement(String uri, String localName, String rawName, final org.xml.sax.Attributes attributes)throws org.xml.sax.SAXException{
    //count the number of <name> tags in the XML file
         if(rawName.equals("name")){
              tagCount++;
    public void characters(char[] ch, int start, int len){
    //get the current string
         String text = new String(ch, start, len);
         String text1 = text.trim();
    //there are 5 elements for each customer found in the XML file so when the count reaches 6
    // i reset this to 1
         if(count == 6){
         count = count - 5;
         if(text1.length()>0 && count == 1){
              name = text1;
              System.out.println(name);
              }else{
         if(text1.length()>0 && count == 2){
              custID = text1;
              System.out.println(custID);
                   }else{
                   if(text1.length()>0 && count == 3){
                   username = text1;
                   System.out.println(username);
                   }else{
                        if(text1.length()>0 && count == 4){
                        address = text1;
                        System.out.println(address);
                        }else{
                        if(text1.length()>0 && count == 5){
                             phoneNum = text1;
                             System.out.println(phoneNum);
                             //add data to the customer array
                             customers[x] = new Customer(name, custID, username, address, phoneNum);
    // increment the array index counter
                        x = x+1;
                        }//end of if
                        }//end else
                        }//end else
                   }//end else
              }//end else
    }//end of characters method
    public void endDocument(){
         System.out.println("There are " + tagCount +
         " <name> elements.");
    }//end of class Sink
    Before the end of this class i also need to make the array available to the calling program!!
    Any help would be much appreciated
    Thanks
    Iain

    Ok, yer going about this all the wrong way. You shouldn't have to maintain a count of all the elements. Basically you are locking yourself into the XML tags not only all being there but are assuming they are all in the same order. What you should do is in your characters() method, put all of the characters into a string buffer. Then, in endElement() (which you dont use btw, you should) you grab the information that is in the string buffer and store it into your Customer object depending on what the tagName is.
    Also, you should probably use a List to store all the Customer objects and not an single array, it's more dynamic and you arent locked into a set number of Customers.
    I wont do it all for you, but I'll give you a good outline to use.
    public class CustomerHandler extends DefaultHandler {
        private java.util.List customerList;  // List of Customer objects
        private java.util.StringBuffer buf;   // StringBuffer to store the string of characters between the start and end tags
        private Customer customer;  // Customer object that is initialized with each entry.
        public CustomerHandler() {
            customerList = new java.util.ArrayList();   // Initialize the List
            buf = new java.util.StringBuffer();   // Initialize the string buffer
        //  Make your customer list available to other classes
        public java.util.List getCustomerList() {
            return customerList;
        public void startElement(String nsURI, String sName, String tagName, Attributes attributes) throws SAXException {
            // Clear the String Buffer
            //  If the tagName is "Customer" then create a new Customer object
        public void characters(char[] ch, int start, int length) {
            //  append the characters into the string buffer
        public void endElement(String nsURI, String sName, String tagName) throws SAXException {
            // If the tagName is "Customer" add your customer object to the List
            // Place the data from the String Buffer into a String
            //  Depending on the tagName, call the appropriate set method on your customer object
    }

  • I linux inode which contains 13 member array wich stores the actual block address of data .Similarly in windows how data is managed in disk ?. How many members in this array ?

    I linux inode which contains 13 member array wich stores the actual block address of data .Similarly in windows how data is managed in disk ?. How many members in this array ?

    Hello Vijay Nerkar,
    Your question is not related to Windows Forms General. What is the data you mean and also what is that array?
    If you are looking for something related to Windows File System, see some words here:
    http://en.wikipedia.org/wiki/File_system
    For example
    "Windows makes use of the
    FAT, NTFS,
    exFAT and ReFS file systems (the last of these is only supported and usable in
    Windows Server 2012; Windows cannot boot from it).
    Windows uses a drive letter abstraction at the user level to distinguish one disk or partition from another. For example, the
    path <tt>C:\WINDOWS</tt> represents a directory <tt>WINDOWS</tt> on the partition represented by the letter C. Drive C: is most commonly used for the primary hard disk partition, on which Windows is usually installed and from which it boots. This "tradition"
    has become so firmly ingrained that bugs exist in many applications which make assumptions that the drive that the operating system is installed on is C. The use of drive letters, and the tradition of using "C" as the drive letter for the primary hard disk
    partition, can be traced to
    MS-DOS, where the letters A and B were reserved for up to two floppy disk drives. This in turn derived from
    CP/M in the 1970s, and ultimately from IBM's
    CP/CMS of 1967.
    For more details, consider consult on MS Answers:
    http://answers.microsoft.com/en-us/windows
    Regards,
    Barry Wang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Help, store an array of cd objects

    im doing a java project on creating a music cd database, i need to store an array of cd objects, each entry in the array will be a single object for a cd.
    The objects are: Artist, Album, No of tracks
    I need some help with this, thanks
    here's the code ive done so far:
    import javax.swing.JOptionPane;
    class Cd1
         public static void main (String[] args)
              int menu_choice;
              CdRecord one = new CdRecord();
              one.artist_name = JOptionPane.showInputDialog("Enter artist name.");
              one.album_name = JOptionPane.showInputDialog("Enter album name.");
              one.no_of_tracks =Integer.parseInt(JOptionPane.showInputDialog("Enter the number of tracks on the album"));
         one.printCdRecord();          
    class CdRecord
         public String artist_name;
         public String album_name;
         public int no_of_tracks;
    public CdRecord (String artist, String album, int tracks, int year)
         artist_name = artist;
         album_name = album;
         no_of_tracks = tracks;
    public CdRecord()
    artist_name = "A";
    album_name = "B";
    no_of_tracks = 0;
    public void printCdRecord ()
    String o = "Artist Name: " + artist_name + "\nAlbum Name: " album_name"\nNo. Of Tracks: " + no_of_tracks;;
    System.out.println(o);
    }

    where should i put this in my code?this part would normally be a class field, accessible from many parts of the class
    java.util.List<CdRecord> records;to it may look something like this
    class Cd1
      private java.util.List<CdRecord> records;//and use constructor to create
      //or
      private java.util.List<CdRecord> records = new java.util.ArrayList<CdRecord>();
      ...as is, the above will cause you a problem because you have most of your code in main() which is static.
    before you go much further, rethink your program design:
    - your class name is Cd1, which would indicate a single CD, but you're doing a CD database so call it CdInventory, CdCollection, etc
    - the only code you want in main() is to start the program, so that would be new CdInventory(), nothing more (unless creating a GUI)
    - how are you going to get new records - a GUI with buttons add/edit/delete, or the console.
    - are you going to save new/edited records to a file (the database), and read existing data back into the program at startup
    - basically how you go about the above determines what you have in the constructor of the program (and do not use main() for this)

  • How do I read a text file line by line and store to array

    I have a text file, I want to be able to store each line of the file in an array, how would I go about doing this? code example? tutorial? Thank you

    Well, you got the pseudo code:
    a) read line
    b) add to array
    So whats the problem? What don't you know how to do?
    What does your text book tell you about reading files. I'm sure it has an example, every book I've read does.
    By the way I would use an ArrayList to store each line of text, that way you don't need to know in advance.

Maybe you are looking for

  • Java Proxy - Libraries in EAR File

    Hello I am developing some Java Proxies with the NWDS. For these mappings i need to reference some jars required by the Java Proxies aii_proxy_xirt.jar aii_msg_runtime.jar aii_utilxi_misc.jar guidgenerator.jar does anyone know how to include these li

  • Does this work?

    http://www.amazon.com/Cisco-USB300M-Cisco-Linksys-Ethernet-Adapter/dp/B001NLV4TQ /ref=sr_1_8?s=electronics&ie=UTF8&qid=1337663431&sr=1-8 Would this product make it so that I get internet wherever I am? I'm not sure if that is what it is used for.

  • The data is not loading in second level ODS

    Hi Gurus, I am loading the data from first level to second. The data is properly loading to first level but second it is picking 0 records inspite there are 19604 records. This problem arised after the changes went live which I have done and tested i

  • How do I know what video card will be compatable​?

    Hi,  I think I need a new video card, but I'm really not sure what new card will be compatable with my computer , an HP m9077c that operates with Vista.I see it has an Nvidia Geforce 8500 gt in it now, but looking for new ones to buy I see things lik

  • Service request fields enhanced through AET are not reflecting in BW DS

    Hi All, the CRM developer has added 3 service request fields to crmd_orderadm_h, crmd_service_h via AET. He has marked all the 3 fields as 'BW reporting relevant'. I have now checked the BW extractors in the hope that these 3 fields will now be appen