I'm confused about accessor methods.

Part of the application I'm developing translates a sequence of strings into a series of hex values. The number of strings will be either 2 or 3. In the cass where there's 3 strings the last would represent an integer or a decimal fraction.
I have a class Xlate that has 3 translation methods thus:
public int[] translate(String msg) {};
public int[] translate(String msg, int val) {};
public int[] translate(String msg, String aValString) {};
The problem I have is that the Xlate does not return what is expected when passed an argument via the method signature. If explicitly passed a string sequence it works OK.
If I pass the argumants... "pause" "21.09876"
I would expect to see a translation of ... "msg translation array = 76,98,10,20,0A"
What I get is "msg translation array = FF, FF, FF, FF,FF" which indicates the array has not been amended after initialised.
This is most likely due to the lack of accessor definitions and their use. HOWEVER, I am confused by such methods.
I now realise that to pass values setter/getter accessor methods are .
I think these might be along the lines of the following:
private String[] commandList; // declares a string variable
public Xlate() { this(""); }
public Xlate(String[] msg) { this.commandList = msg[1]; } // holds the name
public String getCommandStrings() { return this.commandList; } // gets the commandList
I can't get this to work and know these are not correct.
I need help to get me moving ahead of this problem. Any help would be appreciated.
Thanks.
Philip
import java.lang.String;
public class Control {
  public Control() {
   int i;
  static final public Xlate x = new Xlate();
//  static final public Comms rc = new Comms();
  public static void main(String[] args) {
    String cmd[] =  args;
    for (int i=0;i<args.length;i++)
      cmd=args[i];
controller(cmd);
// public static void controller(String portName, String command, String parameter) {
public static void controller(String[] parameters) {
Control c = new Control();
int[] msg ={1,1,1,1,1};
// Booleans 'pragmaN' are used to select/deselect debug statements
// though would be embedded in the bytecode
// so these are not compiler directives
boolean pragma1=true, pragma2=true, pragma3=true; // toggle using !
int pVal;
if (pragma1==true) {
System.out.print("msg array = ");
for (pVal=0; pVal<4;pVal++)
     System.out.print(Integer.toHexString(msg[pVal]).toUpperCase() + ",");
System.out.println(Integer.toHexString(msg[pVal++]).toUpperCase());
// rc.setupComPort(parameters[0]); // Configure the port referenced
msg = x.translate("start"); //*********TRANSLATE()************
msg = x.translate("pause","12.34567"); //*********TRANSLATE()************
if (pragma2==true) {
System.out.print("msg translation array = ");
for (pVal=0; pVal<4;pVal++)
     System.out.print(Integer.toHexString(msg[pVal]).toUpperCase() + ",");
System.out.println(Integer.toHexString(msg[pVal++]).toUpperCase());
// rc.writeCmd(msg);
// Control messages have 3 fixed formats comprising 'a string', 'a string
// plus an integer' and 'a String plus a String'.
// For the control messages with an argument a string is constructed before
// translation by parging the arguments.
// Do ensure the number of args is greater than 1 and less than 3.
// Converts integer types to Strings
String argString="";
System.out.println("arg len = "+ parameters.length);;
switch (parameters.length) {
case 2:
     System.out.println("in switch 2");;
     argString = (parameters[1]);
     msg = x.translate(argString); //*********TRANSLATE()************
     if (pragma3==true) {
     System.out.print("msg translation array = ");
     for (pVal=0; pVal<4;pVal++)
     System.out.print(Integer.toHexString(msg[pVal]).toUpperCase() + ",");
     System.out.println(Integer.toHexString(msg[pVal++]).toUpperCase());
     break;
case 3:
     if (pragma3==true) {
     System.out.println("in switch 3"); ;
     argString = (parameters[1] + parameters[2]);
     msg = x.translate(argString); //*********TRANSLATE()************
     if (pragma3==true) {
     System.out.print("msg translation array = ");
     for (pVal=0; pVal<4;pVal++)
     System.out.print(Integer.toHexString(msg[pVal]).toUpperCase() + ",");
     System.out.println(Integer.toHexString(msg[pVal++]).toUpperCase());
     break;
default:
     System.out.println("Argument length error");
break;
// rc.writeCmd(msg);
import java.text.*;
import java.text.StringCharacterIterator; // required for CharacterIterator class
public class Xlate {
private String[] commandList; // declares a string variable
public Xlate() { this(""); }
public Xlate(String[] msg) { this.commandList = msg[1]; } // holds the name
public String getCommandStrings() { return this.commandList; } // gets the commandList
// These methods form a basic translation mechanism used as proof
public int[] translate(String msg) {
int[] paramList = {
     0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; //initialise this array
//Power On and Off controls
if (msg == "start") {
paramList = new int[] {
     0xFF, 0xFF, 0xFF, 0x01, 0x20};
if (msg == "stop") {
paramList = new int[] {
     0xFF, 0xFF, 0xFF, 0x00, 0x20};
return (paramList);
public int[] translate(String msg, int val) {
int[] paramList = {};
int pVal;
// Memory recall with memory ID.
if (msg == "M") { // Recall memory
paramList = new int[] {
     0xFF, 0xFF, 0xFF, 0xFF, 0x02};
// stuff the argument in to the paramList array
paramList[3] = Integer.decode(Integer.toHexString(val)).shortValue();
return (paramList);
  public int[] translate(String msg, String aValString) {
// Convert the string
    int i, j, k;
    int index = 0, c = 0;
    int[] p, paramList = {};
    final StringBuffer result = new StringBuffer(); // only ever one buffer
    char character;
    if (msg == "pause") {
      paramList = new int[] {
       0xFF, 0xFF, 0xFF, 0xFF, 0x0A};
// The period character is the axle where operations centre...
// working from the left most position index until period is found.
// append chars to result string en route.
// if period then stop - this is the integer part
    StringCharacterIterator sci = new StringCharacterIterator(aValString);
    result.append('0'); // a fudge to pad out the resulting string
    character = sci.current();
    while (character != '.') {
      //char is not a period so append to buffer
      result.append(character);
      character = sci.next();
    character = sci.next();
// working from the position of 'the period character' append chars to result string en route.
// stop at the end having bound the fraction part
    while (character != StringCharacterIterator.DONE) {
      result.append(character);
      character = sci.next();
    aValString = result.toString(); // save the result
    sci = new StringCharacterIterator(aValString);
    String[] part = {
     "00", "00", "00", "00"}; // array index ordered 0 to 3 from left to right
    result.delete(0, result.capacity()); // initialise the StringBuffer result
    character = sci.first();
    for (index = 0; index <= 3; ++index) {
      for (i = 0; i <= 1; ++i) {
     if (character != StringCharacterIterator.DONE) {
       result.append(character);
       character = sci.next();
     else {
       result.append('0');
      part[index] = result.toString();
      result.delete(0, result.capacity()); // initialise the StringBuffer result
// the sequence handles the conversion of decimal to packed BCD for transmission
    for (k = 0; k <= 3; k++) {
      // cast the String in the array part indexed by k to an int
      i = Integer.parseInt(part[k]);
      for (j = 0; j < 10; j++) {
     if ( (i >= (j * 10)) & (i < ( (j + 1) * 10))) {
       paramList[k] = (j * 0x10 + (i - (j * 10)));
    return (paramList);

Sorry, this is way too much to look at (at least for me). Please create a small test function that fails & post the formatted code. In doing this, you may even spot the problem yourself!

Similar Messages

  • Confused about update method in JComponents

    Hello,
    I'm a bit confused about the update method in JComponents. What I remember from applets was that the update method was called whenever something changed such as a window being dragged across it or something.
    I've written a class that extends a JPanel and overwrites the paint method. Any components I add to it aren't drawn. I can add JComponent.update() methods to my paint() method but this is very inefficient as I'm having repaint() called by a thread 15 times a second. I tried to put the update methods in the JPanels update() but that doesn't work, in fact update isn't called at all. What does update do ?

    Let me take another crack at it...
    1) Grab the 9.2.0.8 patchset for the Oracle database (i.e. patch 4547809 on Metalink assuming you're using 32-bit Windows). Install this to upgrade your Oracle client to 9.2.0.8. Installation instructions are in the README.
    2) Grab the 9.2.0.8 Oracle ODBC driver, which you already appear to have, and follow the installation instructions in the README you're looking at.
    Justin

  • Slightly confused about notify method

    Hi,
    I'm currently studying for the SCJP exam and have 2 questions about the thread notify call.
    (1) Is it possible when a thread owns an object lock, i.e. say in synchronized code, that it can call the notify method on a particular thread. For example, say there are 2 threads, names thread1 and thread2, and thead1 obtains object lock, can it call Thread2.notify()? The reason I'm read conflicting web-pages, saying it isn't possible for 1 thread to notify another thread and it is up to Object to decide which thread to invoke, say must use notifyAll() or notify() call. Is this true?
    (2) Which thread in following code is Thread.sleep() referring to? Is it the main thread that created 2 threads?
    class running extends Thread
         public void run(){
    public class fredFlintStone{     
         public static void main(String[] args) {
              running  thread1 = new running();
              running thread2 = new running();
              thread1.start();
              thread2.start();
              try
              //confused here     
            Thread.sleep(12L);
              catch(InterruptedException e)
    }Cheers!

    its best not to confuse terminology here.
    marktheman wrote:
    I ... have 2 questions about the thread notify call.Thread is an object which has a notify() method. However you should never use it. You should only use notify() on regular objects.
    (1) Is it possible when a thread owns an object lock, A Thread holds a lock, see [http://java.sun.com/javase/6/docs/api/java/lang/Thread.html#holdsLock(java.lang.Object)]
    i.e. say in synchronized code, that it can call the notify method on a particular thread. A thread calls notify() on an object not a given thread. (Unless that object is a thread, but don't do that!)
    For example, say there are 2 threads, names thread1 and thread2, and thead1 obtains object lock, can it call Thread2.notify()?It can, but it would fail as you can only call notify() on an object you hold the lock to.
    The reason I'm read conflicting web-pages, saying it isn't possible for 1 thread to notify another thread It is possible but not in any useful way.
    and it is up to Object to decide which thread to invoke,The Object has no say in the matter, its up to the scheduler in the OS.
    say must use notifyAll() or notify() call. Is this true?no.
    (2) Which thread in following code is Thread.sleep() referring to? The javadoc says "Causes the currently executing thread to sleep". You should always check the documentation for asking that sort of question.

  • Confused about BatchInteract method

    I am using a web service and the DI Server API to connect to the SBO database. I am able to login and to use the Interact method, but I have problems using the BatchInteract method. I think, my xml document has some failures. Can someone give me an example of a working batchinteract xml document?

    Hi Nico,
    I'm in the process of using the DI Server to create GL Accounts. Here is a copy of the XML that I'm using to create the GL Entries.
    <?xml version="1.0" encoding="UTF-16"?>
    <env:Envelopes xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Envelope>
         <env:Header>
              <SessionID></SessionID>
         </env:Header>
         <env:Body>
         <dis:AddObject xmlns:dis="http://www.sap.com/SBO/DIS" CommandID="Add GL Account">
         <BOM>
         <BO>
         <AdmInfo>
              <Object>oChartOfAccounts</Object>
         </AdmInfo>
         <ChartOfAccounts>
              <row>
                   <Name></Name>
                   <FatherAccountKey></FatherAccountKey>
                   <FormatCode></FormatCode>
              </row>
         </ChartOfAccounts>
         </BO>
         </BOM>
         </dis:AddObject>
         </env:Body>
    </env:Envelope>
    <env:Envelope>
         <env:Header>
              <SessionID></SessionID>
         </env:Header>
         <env:Body>
         <dis:AddObject xmlns:dis="http://www.sap.com/SBO/DIS" CommandID="Add GL Account">
         <BOM>
         <BO>
         <AdmInfo>
              <Object>oChartOfAccounts</Object>
         </AdmInfo>
         <ChartOfAccounts>
              <row>
                   <Name></Name>
                   <FatherAccountKey></FatherAccountKey>
                   <FormatCode></FormatCode>
              </row>
         </ChartOfAccounts>
         </BO>
         </BOM>     
         </dis:AddObject>
         </env:Body>
    </env:Envelope>
    </env:Envelopes>
    Please let me know if this helps.
    Thank You
    Stephen Sjostrom

  • Confused about nonGUI beans and events

    The crux of this is the question "When will a NON GUI bean use events to communicate?"
    Articles I have read advocate that Beans are not just GUI components, and I agree. However I've only ever seen examples of GUI Beans!
    I am writing a non GUI Bean to represent a credit card.
    Before I got concerned with beans I would have just written the class with some accessor methods and some functional methods to do what I want, something like;
    void setCardNumber(String n)
    boolean isNumberValid() //check the card number using MOD10
    and then used that class in my application.
    But now I want to make it conform closer to JavaBeans. I know that beans have methods, but I am confused somewhat about how events figure into this. Do nonGUI beans fire events/listen for events? Very often?
    What I am asking is, what events should a Bean like CreditCard fire? The main function of this Bean is to determine if the number conforms to MOD10 checks using isNumberValid() method.
    Consider that I want to write another Bean, a GUI component that takes card details and updates the nonGUI CreditCard Bean. Of course I want loose coupling, not every user will use my CreditCard Bean (especially if I dont get these events straight!). If I use property change events to fill in the card number etc in the CreditCard Bean, should I make it (the CreditCard bean) listen for focusLost events from the interface to determine when all the details have been filled in and fire an event about the validity of the card number?? Doesn't this break the rules a bit, by providing prior knowledge to the CreditCard nonGUI Bean??
    Should the CreditCard nonGUI bean fire an event to say that the number is valid/invalid?
    You will probably say, "WHY use events, when you only need methods?" and that is my question! When would a non GUI bean fire or listen to events? I want my non GUI bean to be completely ignorant of GUI stuff, so no focusLost listener.
    Should the credit card interface fire a custom event (CardDetailsEnteredEvent) and the non GUI bean listen for these? But that's tighter coupling than just implementing the methods isn't it?
    I think that the nonGUI bean will have property change listeners for the card number etc, but this begs the question, what is the point of setter methods if I am bound the properties anyway??
    I've read everything pertinent at http://java.sun.com/products/javabeans/training.html
    Thanks to anyone who can stop my head hurting.
    Jim

    Ah, I think I may have figured it out from the spec.
    "Conceptually, events are a mechanism for propagating state change notifications between a
    source object and one or more target listener objects."
    key phrase being "state change" - my non GUI bean CreditCard only really has two states; 1. incomplete card details and 2. complete card details. So I guess I could/should only fire an event (DetailsEntered) when the details are completely 'filled in'.
    Which leaves me with the GU interface bean, it has two states also, 1. details being edited (focus gained) and 2. details finished being edited (focus lost) - should then this bean fire its own event (DetailsEdited) or should it just rely on other beans listening for the focus lost event? It's my functional interpretation that a focus lost event signifies that the details have been edited, perhaps I should therefore implement my own event that has this contextual meaning (DetailsEdited).
    I'm aware that the names of these events are quite poor, I always find good naming to be another very important head scratcher!!
    Jim

  • Confused about extending the Sprite class

    Howdy --
    I'm learning object oriented programming with ActionScript and am confused about the Sprite class and OO in general.
    My understanding is that the Sprite class allows you to group a set of objects together so that you can manipulate all of the objects simultaneously.
    I've been exploring the Open Flash Chart code and notice that the main class extends the Sprite class:
    public class Base extends Sprite {
    What does this enable you to do?
    Also, on a related note, how do I draw, say, a line once I've extended it?
    Without extending Sprite I could write:
    var graphContainer:Sprite = new Sprite();
    var newLine:Graphics = graphContainer.graphics;
    And it would work fine. Once I extend the Sprite class, I'm lost. How do I modify that code so that it still draws a line? I tried:
    var newLine:Graphics = this.graphics;
    My understanding is that since I'm extending the Sprite class, I should still be able to call its graphics method (or property? I have no idea). But, it yells at me, saying "1046: Type was not found or was not a compile-time constant: Graphics.

    Thanks -- that helped get rid of the error, I really appreciate it.
    Alas, I am still confused about the extended Sprite class.
    Here's my code so far. I want to draw an x-axis:
    package charts {
        import flash.display.Sprite;
        import flash.display.Graphics;
        public class Chart extends Sprite {
            // Attributes
            public var chartName:String;
            // Constructor
            public function Chart(width:Number, height:Number) {
                this.width = width;
                this.height = height;
            // Methods
            public function render() {
                drawAxis();
            public function drawAxis() {
                var newLine:Graphics = this.graphics;
                newLine.lineStyle(1, 0x000000);
                newLine.moveTo(0, 100);
                newLine.lineTo(100, 100);
    I instantiate Chart by saying var myChart:Chart = new Chart(); then I say myChart.render(); hoping that it will draw the axis, but nothing happens.
    I know I need the addChild method somewhere in here but I can't figure out where or what the parameter is, which goes back to my confusion regarding the extended Sprite class.
    I'll get this eventually =)

  • Confused about passing by reference and passing by valule

    Hi,
    I am confuse about passing by reference and passing by value. I though objects are always passed by reference. But I find out that its true for java.sql.PreparedStatement but not for java.lang.String. How come when both are objects?
    Thanks

    Hi,
    I am confuse about passing by reference and passing
    by value. I though objects are always passed by
    reference. But I find out that its true for
    java.sql.PreparedStatement but not for
    java.lang.String. How come when both are objects?
    ThanksPass by value implies that the actual parameter is copied and that copy is used as the formal parameter (that is, the method is operating on a copy of what was passed in)
    Pass by reference means that the actual parameter is the formal parameter (that is, the method is operating on the thing which is passed in).
    In Java, you never, ever deal with objects - only references to objects. And Java always, always makes a copy of the actual parameter and uses that as the formal parameter, so Java is always, always pass by value using the standard definition of the term. However, since manipulating an object's state via any reference that refers to that object produces the same effect, changes to the object's state via the copied reference are visible to the calling code, which is what leads some folk to think of java as passing objects by reference, even though a) java doesn't pass objects at all and b) java doesn't do pass by reference. It passes object references by value.
    I've no idea what you're talking about wrt PreparedStatement, but String is immutable, so you can't change its state at all, so maybe that's what's tripping you up?
    Good Luck
    Lee
    PS: I will venture a guess that this is the 3rd reply. Let's see...
    Ok, second. Close enough.
    Yeah, good on yer mlk, At least I beat Jos.
    Message was edited by:
    tsith

  • Using mutator and accessor methods in main.

    Would somebody explain to me exactly how mutator and accessor methods make a class and it's driver program work together. I understand the principle of encapsulation, but I'm obviously missing something. I get the syntax, but what actually happens? I'm hoping a fresh perspective on it will help me understand better.
    I guess another way to ask the question could be: how do you use accessor and mutator methods in the main program that calls them?

    >
    the assignment says to have a
    "reasonable set of accessor and mutator methods
    whether or not you use them". So in my case I have
    them written in the class but do not call them inthe
    driver program. And like I said, the program does
    what it's supposed to do.This class you're in worries me. I'm sure what
    polytropos said is true: they're trying to make you
    think about reuse. But adding to an API without cause
    is widely considered to be a mistake, and there are
    those who are strongly opposed to accessors/mutators
    (or worse, direct field access) on OOP design grounds.The class is based on the book Java: Introduction to Computer Science and Progamming, by Walter Savitch. Until now I've been pretty happy with it. Another problem, to me anyway, is that so far we've done a few, cumulative programming projects per chapter. This time, there was one assignment for the whole chapter that is suppsoed to incorporate everything. But that's just me complaining.
    Here is the code I have and that it looks like I'll be turning in... criticisms welcome.
    Here is the class:
    public class GradeProgram//open class
         private double quiz1;
         private double quiz2;
         private double mid;
         private double fin;
         private double finalGrade;
         private char letterGrade;
         public void readInput()//open readInput object
              do
                   System.out.println("Enter the total points for quiz one.");
                   quiz1 = SavitchIn.readLineInt();
                   System.out.println("Enter the total points for quiz two.");
                   quiz2 = SavitchIn.readLineInt();
                   System.out.println("Enter the mid term score.");
                   mid = SavitchIn.readLineInt();
                   System.out.println("Enter final exam score.");
                   fin = SavitchIn.readLineInt();
                   if ((quiz1>10)||(quiz2>10)||(quiz1<0)||(quiz2<0))
                   System.out.println("Quiz scores are between one and ten.  Re-enter scores");
                   if ((mid>100)||(fin>100)||(mid<0)||(fin<0))
                   System.out.println("Exam scores are between zero and one hundred.  Re-enter scores.");
              while ((quiz1>10)||(quiz2>10)||(quiz1<0)||(quiz2<0)||(mid>100)||(fin>100)||(mid<0)||(fin<0));
         }//end readInput object
         public void output()//open output object
              System.out.println();
              System.out.println("You entered:");
              System.out.println("Quiz 1: " + (int)quiz1);
              System.out.println("Quiz 2: " + (int)quiz2);
              System.out.println("Mid term: " + (int)mid);
              System.out.println("Final exam: " + (int)fin);
              System.out.println();
              System.out.println("Final grade: " + (int)percent() + "%");
              System.out.println("Letter grade: " + letterGrade());
         }//end output object
         public void set(double newQuiz1, double newQuiz2, double newMid, double newFin, double newFinalGrade, char newLetterGrade)
              if ((newQuiz1 >= 0)&&(newQuiz1 <= 10))
              quiz1 = newQuiz1;
              else
                   System.out.println("Error: quiz scores are between zero and ten.");
                   System.exit(0);
              if ((newQuiz2 >= 0)&&(newQuiz2 <= 10))
              quiz2 = newQuiz2;
              else
                   System.out.println("Error: quiz scores are between zero and ten.");
                   System.exit(0);
              if ((newMid >= 0)&&(newMid <= 100))
              mid = newMid;
              else
                   System.out.println("Error: exam scores are between zero and one hundred.");
                   System.exit(0);
              if ((newFin >= 0)&&(newFin <= 100))
              fin = newFin;
              else
                   System.out.println("Error: exam scores are between zero and one hundred.");
                   System.exit(0);
              letterGrade = newLetterGrade;
         public double getQuiz1()
              return quiz1;
         public double getQuiz2()
              return quiz2;
         public double getMid()
              return mid;
         public double getFin()
              return fin;
         public char getLetterGrade()
              return letterGrade;
         private double finalPercent()//open finalPercent object
              double quizPercent = (((quiz1 + quiz2) /2) * 10) / 4;
              if (((((quiz1 + quiz2) /2) * 10) % 4) >= 5)
                   quizPercent++;
              double midPercent = mid / 4;
              if ((mid % 4) >= 5)
                   midPercent++;
              double finPercent = fin / 2;
              if ((fin % 2) >= 5)
                   finPercent++;
              finalGrade = (quizPercent + midPercent + finPercent);
              return (finalGrade);
         }//end final percent object
         private double percent()//open percent object - helping object
              double percentGrade = finalPercent();
              return (percentGrade);
         }//end percent object
         private char letterGrade()//open letterGrade object
              double letter = percent();
              if (letter >= 90)
                   return ('A');
              else if (letter >= 80)
                   return ('B');
              else if (letter >= 70)
                   return ('C');
              else if (letter >= 60)
                   return ('D');
              else
                   return ('F');
         }//end letterGrade object
         private double quizScore()//open quizScore object
              double quizes = ((quiz1 + quiz2) /2) * 10;
              return (quizes);
         }// close quizScore object
    }//end classAnd here is the driver program:
    public class GradeProgramDemo
         public static void main(String[] args)
              String cont;
              do
                   GradeProgram firstStudent = new GradeProgram();
                   firstStudent.readInput();
                   firstStudent.output();
                   System.out.println();
                   System.out.println("Enter more student grades?  Enter Y to continue");
                   System.out.println("or press enter to quit.");
                   cont = SavitchIn.readLine();
                   System.out.println();
              while (cont.equalsIgnoreCase("y"));

  • Which of the following are true about abstract methods in EJB 2.0

    Hi guys I'm beginner to EJB and i got some unanswered questions.
    Can any one of you please.. give answers?
    Thanks if you do...
    Which of the following are true about abstract methods in EJB 2.0
    CMP?
    Choose all correct answers:
    1. Abstract accessor methods should not be exposed in the EJB
    component's interface
    2.Abstract accessor/mutator methods are used to access and modify
    persistent state and relationship information for entity objects
    3.Abstract Accessor/Mutator methods do not throw exceptions
    4.The EJB developer must implement the Accessor/Mutator methods
    5.Abstract accessor methods may or may not be exposed in the EJB
    component's interface
    2.Which ONE of the following is true?
    Choose the best answer:
    1.Local interfaces cannot have a relationship with other Entity
    components
    2.Local interfaces cannot be used for Stateless Session EJB
    3.Local interfaces can be a part of Object's persistent state
    4.Local interfaces have the same functionality as that of a
    stateless Session EJB
    3.Which of the following describe the <cmr-field> in a EJB 2.0
    descriptor?
    Choose all correct answers:
    1.A Local interface/Entity can be a value of a <cmr-field>
    2.There is no <cmr-field> in EJB 2.0 descriptor
    3.It is used to represent one meaningful association between any
    pair of Entity EJBs, based on the business logic of the Application
    4.It provides a particular mapping from an object model to a
    relational database schema
    5.It allows the Local Entity interfaces to participate in
    relationships
    4.Which of the following are the advantages of using Local interfaces
    instead of dependent value classes?
    Choose all correct answers:
    1.Local Entity Interfaces can participate in Relationships
    2.The life cycle of Local Entity Interfaces is managed by EJB
    container, intelligently
    3.Local Entity Interfaces can be used in EJB QL Queries
    4.Local Entity Interfaces can be a part of the <cmp-field> but not
    <cmr-field>
    5.Which of the following are true about Local interfaces
    1.A local interface must be located in the same JVM to which the EJB
    component is deployed
    2.Local calls involve pass-by-reference.
    3.The objects that are passed as parameters in local interface
    method calls must be serializable.
    4.In general, the references that are passed across the local
    interface cannot be used outside of the immediate call chain and must
    never be stored as part of the state of another enterprise bean.
    6.Which of the following specifies the correct way for a client
    to access a Message driven Bean?
    Choose the best answer:
    1. via a Remote interface
    2. via Home interface
    3. Message driven bean can be accessed directly by the client
    4. both 1 & 2
    5. none of the above
    ------------------------------------------------------------------------7.Which of the following statements are true about message-driven
    bean Clients?
    ------------------------------------------------------------------------Choose all correct answers:
    They can create Queue and QueueConnectionFactory objects
    They can create Topic and TopicConnectionFactory objects
    They can lookup the JNDI server and obtain the references for
    Queue and Topic and their connection Factories
    Only 1 and 2 above

    Hi guys I'm beginner to EJB and i got some unanswered
    questions.
    Can any one of you please.. give answers?
    Thanks if you do...
    Which of the following are true about abstract methods
    in EJB 2.0
    CMP?
    Choose all correct answers:
    1. Abstract accessor methods should not be exposed
    d in the EJB
    component's interfacefalse
    2.Abstract accessor/mutator methods are used to
    access and modify
    persistent state and relationship information for
    entity objectstrue
    >
    3.Abstract Accessor/Mutator methods do not throw
    exceptionstrue
    >
    4.The EJB developer must implement the
    Accessor/Mutator methodsfalse
    5.Abstract accessor methods may or may not be exposed
    in the EJB
    component's interfacetrue
    2.Which ONE of the following is true?
    Choose the best answer:
    1.Local interfaces cannot have a relationship with
    other Entity
    componentsfalse
    2.Local interfaces cannot be used for Stateless
    Session EJBfalse
    3.Local interfaces can be a part of Object's
    persistent statefalse
    4.Local interfaces have the same functionality as
    that of a
    stateless Session EJBtrue
    3.Which of the following describe the <cmr-field> in a
    EJB 2.0
    descriptor?
    Choose all correct answers:
    1.A Local interface/Entity can be a value of a
    <cmr-field>true
    2.There is no <cmr-field> in EJB 2.0 descriptorfalse
    3.It is used to represent one meaningful association
    between any
    pair of Entity EJBs, based on the business logic of
    the Applicationtrue
    4.It provides a particular mapping from an object
    model to a
    relational database schematrue
    5.It allows the Local Entity interfaces to
    participate in
    relationshipstrue
    4.Which of the following are the advantages of using
    Local interfaces
    instead of dependent value classes?
    Choose all correct answers:
    1.Local Entity Interfaces can participate in
    Relationshipsis
    2.The life cycle of Local Entity Interfaces is
    managed by EJB
    container, intelligentlyis
    3.Local Entity Interfaces can be used in EJB QL
    Queriesnot
    4.Local Entity Interfaces can be a part of the
    <cmp-field> but not
    <cmr-field>not
    >
    >
    5.Which of the following are true about Local
    interfaces
    1.A local interface must be located in the same JVM
    M to which the EJB
    component is deployedtrue
    2.Local calls involve pass-by-reference.true
    3.The objects that are passed as parameters in local
    l interface
    method calls must be serializable.false
    4.In general, the references that are passed across
    s the local
    interface cannot be used outside of the immediate
    e call chain and must
    never be stored as part of the state of another
    r enterprise bean.true
    >
    6.Which of the following specifies the correct way for
    a client
    to access a Message driven Bean?
    Choose the best answer:
    1. via a Remote interfacefalse
    2. via Home interfacefalse
    3. Message driven bean can be accessed directly by
    the clientfalse
    4. both 1 & 2false
    5. none of the abovetrue.
    >
    ----------------7.Which of the following statements
    are true about message-driven
    bean Clients?
    ----------------Choose all correct answers:
    They can create Queue and QueueConnectionFactory
    objectsthe container can, dunno bout clients
    >
    They can create Topic and TopicConnectionFactory
    objectsthe container can, dunno bout clients
    >
    They can lookup the JNDI server and obtain the
    references for
    Queue and Topic and their connection Factories
    true
    Only 1 and 2 abovefalse
    somebody correct me if i'm wrong

  • Newbie question about abstract methods

    hey, I'm working on a web application that I was given and I'm a little confused about
    some of the code in some of the classes. These are some methods in this abstract class. I don't understand
    how this post method works if the method it's calling is declared abstract. Could someone please tell me how this works?
        public final Representation post(Representation entity, Variant variant) throws ResourceException {
            prePostAuthorization(entity);
            if (!authorizeGet()) {
                return doUnauthenticatedGet(variant);
            } else {
                return doAuthenticatedPost(entity, variant);
    protected abstract boolean authorizeGet();Thanks
    Edited by: saru88 on Aug 10, 2010 8:09 PM

    Abstract Methods specify the requirements, but to Implement the functionality later.
    So with abstract methods or classes it is possible to seperate the design from the implementation in a software project.
    Abstract methods are always used together with extended classes, so I am pretty sure that you are using another class.
    Btw: Please post the Code Keyword in these brackets:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

  • Confusion about TreeMap

    Hi,
    I'm currently studying for SCJP exam and am confused about the following code.
         public static void main(String[] args) {
         TreeMap myMap = new TreeMap();
         myMap.put("ab", 10);
         myMap.put("cd", 5);
         myMap.put("ca", 30);
         myMap.put("az",20);
         NavigableMap myMap2 = myMap.headMap("cd", true);
         myMap.put("bl",100);
         myMap.put("hi",100);
         myMap2.put("bi", 100);
         System.out.println(myMap.size() + " " + myMap2.size());
         }When I run it, it outputs 7 6.
    What I'm confused about is how when after the line NavigableMap myMap2 = myMap.headMap("cd", true);and values are being entered into the myMap object, that it is still possible for them to be entered in the NavigableMap object? Are the 2 entities not seen seperately? Is it to do with the "inclusive" field of the headMap method.
    The solution states that the myMap contains the objects "ab","cd","ca","az","b1","h1","bi"
    and myMap2 "ab","cd","ca","az","b1","bi".
    But how when adding key-value pairs do both objects (myMap,myMap2) get considered for putting into?
    Thanks.

    From the API:
    headMap
    public NavigableMap<K,V> headMap(K toKey,
    boolean inclusive)
    Description copied from interface: NavigableMap
    Returns a view of the portion of this map whose keys are less than (or equal to, if inclusive is true) toKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map >supports all optional map operations that this map supports. So myMap2 contains all the elements from myMap that are <= "cd" (which are all except "hi"), and changes in either map are reflected on both, as stated.

  • Basic Cryptography Question about Cryptograpic Methodes

    Hi
    I have some text data that i need to encrypt and save to a file (kind of a licence file). Than that file is distributed with the software. Upon runtime the software should be able to read in that crypted data file and decrypt it so it can read the information for use.
    I know how this is done using DES for example. But with DES i have to distribute the DES Key with the software, so everbody could use that key to create new encrypted data files.
    What i'm looking for is something like a key i can use to encrypt the data and another key that can only be used to decrypt the data but not for encrypting it, so i can destribute that key with the software with out the danger that anybody can use that key to create new data (licence) files.
    Is there a cryptography mehtode to do this? If yes, is that methode available in JCE?
    I'm a newbie to crypthography, i just read little about the basic concepts, so i'm very thankful about your help.

    I'm not sure whether i understand what you mean. I don't see a reason why i have to exchange any kind of data with the client.
    i thought i package the public key and the encrypted data file with the software i distribute. Than, upon runtime the software loads the public key (as a serialized object) and the encrypted data file and decryptes the data file.
    But this just fits my needs, if the public key may just be used to decrypt the crypted data file and not for encryption. I'm a little bit confused about this point, because i read a lot in the past hours about this topic and the statement was, that private keys are used to decrypt and public keys are used to encrypt. So what i need is the opposite. And i couldn't find such an algorithm until know.
    Maybe you can help me to see that a little bit clearer?
    Thanks a lot for your help!

  • LV OOP when using accessor methods (subVIs) or bundle/unbundle operation?

    Hello
    When should I use the (private) accessor methods (subVIs) and when the bundle/unbundle operation to access the class data? What is the reason that the bundle/unbundle operation is introduced to LabVIEW OOP? I need some rules for a coding guideline.
    Thanks
    Solved!
    Go to Solution.

    Thanks for your hints. I wanted to understand the differences between a private vi access and the unbundle operation like in the picture.
    I found some more explanations on the website: http://www.ni.com/white-paper/3574/en
    -> "Creating "read" and "write" methods for every data value in a class is a process acknowledged to be cumbersome. LabVIEW 8.5 introduced the ability to create accessor VIs from a wizard dialog, and LV2009 added further options to that dialog.
    We were concerned about the performance overhead of making a subVI call instead of just unbundling the data. We found that our current compiler overhead for the subVI call is negligible (measured between 6 and 10 microseconds on average PC). A bundle/unbundle operation directly on the caller VI versus in a subVI is nearly the same amount of time. We do have an issue with data copies for unbundled elements because much of LabVIEW's inplaceness algorithm does not operate across subVI boundaries. As a workaround, you may also choose to avoid accessor methods in favor of methods that actually do the work in the subVI to avoid returning elements from the subVI, thus avoiding data copies. This choice is frequently better OO design anyway as it avoids exposing a class' private implementation as part of its public API. In future versions, we expect that inlining of subVIs will become possible, which will remove the overhead entirely.  
    We feel in the long term it is better to improve the editor experience and the compiler efficiency for these VIs rather than introducing public/protected/community data."

  • Confused about JTable::setCellEditor

    Hi
    I'm a bit confused about what JTable::setCellEditor does.
    I wrote my own TableCellEditor implementation which can handle dates and other additional stuff and which can decide for itself what type of editing control to display.
    Now I want my table to use only this editor.
    However using
    tblTest.setCellEditor( MyEditorInstance );didn't work. But when I used
    tblTest.getColumnModel().getColumn(0).setCellEditor( MyEditorInstance );
    tblTest.getColumnModel().getColumn(1).setCellEditor( MyEditorInstance );
    tblTest.getColumnModel().getColumn(2).setCellEditor( MyEditorInstance );for every column it worked fine.
    How can I avoid setting the default editor manually and set it for all columns?
    As always, any help is greatly appreciated
    Marcus

    I agree with you, its not clear what that method does.
    If you don't set a cell editor to a column then JTable determines which of its default editors to use based on the Class returned from the getColumnClass() method, which is defined by the JTable and the TableModel. If you are using the default implementation of this method then it will always return Object as the class type. You can use your editor as the default by doing:
    table.setDefaultEditor(Object.class, MyEditorInstance);

  • Confusion about applet

    sir
    i have confusion about applet that if an applet compile successfully but on running it shows a exception message about "main"that no such method exist.help me out please

    The full text of the error message would make it easier for us to see what is wrong BUT it sounds like you are trying to run the Applet as an applicaiton from the comand line rather than through an HTML tag in an HTML page loaded into your browser!
    Though you can make Applets run as applications it not normal to do so.

Maybe you are looking for

  • Is there a way to do a mass delete of emails without selecting each one of them individually?

    Is there a way to do a mass deleye on the IPhone 4s without selecting each email individually?

  • How to set up basic POP email on N8

    I've been reading up on all the email discussions about the N8, and it seems like some things work fine, while others need more development. In my case, I would like to set up email using a basic POP email account setup.  I have no need for "push" em

  • OC4J 10.0.3 Standalone LDAP / OID JAZN Authentication

    I have tried to setup OID based authentication on OC4J 10.0.3, but I can't get it working. Here is my log output: ==> log/oc4j.err.log <== 04/10/27 16:21:28 java.lang.NoClassDefFoundError: oracle/ldap/util/Guid 04/10/27 16:21:28 at oracle.security.ja

  • Procedural confusion (several questions)

    My task is to develop a Course Management System: I have the desired variables for an abstract Course class which will be extended by 3 subclasses of CourseType Side: this task is due in 6 days and the how and why are becoming blurred At this time I

  • Transforming data within SQL Loader

    Can I do simple data transformation while loading data? I need to "recode" a field rather than just copying its values from the source text file, e.g. case when scode = '000057' then '800' when scode = '000015' then '815' when scode = '000060' then '