Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2008

Tip: Looking for answers? Try searching our database.

how to set a state

Thread view: 
mike - 15 May 2008 13:32 GMT
Hi,

I am using a class called session that contains a has an internal
state object. However I can only do get on the state.
This is the code I need to test but since I cannot set the sate since
Session is an external interface with an innner class called State. Is
there a way around this for me?

cheers,

//mikael

switch (session.getState()) {

               case TERMINATED:
                   //Do something
                   break;

               case EARLY:
                  //do something
                   break;

               case CONFIRMED:
                  //do something
                   break;

               case INITIAL:
                //do something
                   break;

               }
           }
Roedy Green - 15 May 2008 13:39 GMT
On Thu, 15 May 2008 05:32:17 -0700 (PDT), mike
<mikaelpetterson@hotmail.com> wrote, quoted or indirectly quoted
someone who said :

>I am using a class called session that contains a has an internal
>state object. However I can only do get on the state.
>This is the code I need to test but since I cannot set the sate since
>Session is an external interface with an innner class called State. Is
>there a way around this for me?

for hints on writing state machines see
http://mindprod.com/jgloss/finitestate.html

The trick is to use enums that implement a next method to find the
next state given the input.
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 15 May 2008 13:47 GMT
> Hi,
>
[quoted text clipped - 28 lines]
>                 }
>             }

In the first place, what is the point of this code fragment?  You don't
provide the code for Session, you don't provide the code for State, and you
don't provide the code for State's enclosing class.  What are we supposed to
do, read your mind?  Instead you provide a snippet that tells us nothing
relevant to your question.  We can't even tell from this or your other post on
this code whether getState() returns an enum or an int.  Come on, dude.
<http://sscce.org/>

As to your question, if Session is an "external" (what does that mean?)
interface, then it cannot have any inner classes.

<http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.5>
>> Interfaces may contain member type declarations (§8.5).
>> A member type declaration in an interface is implicitly static and public.

<http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.5.2>
>> The static keyword may modify the declaration of a member type C
>> within the body of a non-inner class T.
>> Its effect is to declare that C is not an inner class.

<http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.3>
>> An inner class is a nested class that is not
>> explicitly or implicitly declared static.

Next, what *does* set the State?  It's got to come from somewhere.  Where?  How?

Answer our questions that we may answer yours.
<http://sscce.org/>

Signature

Lew

mike - 15 May 2008 13:59 GMT
> > Hi,
>
[quoted text clipped - 32 lines]
> provide the code for Session, you don't provide the code for State, and you
> don't provide the code for State's enclosing class.

I am using a SIP API that I am not responsible for.

 What are we supposed to
> do, read your mind?  Instead you provide a snippet that tells us nothing
> relevant to your question.  We can't even tell from this or your other post on
> this code whether getState() returns an enum or an int.  Come on, dude.
> <http://sscce.org/>

getState returns the following:

/ Method descriptor #21 ()Ljavax/servlet/sip/SipSession$State;
 public abstract javax.servlet.sip.SipSession.State getState();

> As to your question, if Session is an "external" (what does that mean?)
> interface, then it cannot have any inner classes.
[quoted text clipped - 22 lines]
> --
> Lew
Lew - 15 May 2008 14:18 GMT
>> Next, what *does* set the State?  It's got to come from somewhere.  Where?  How?

Signature

Lew

mike - 15 May 2008 14:31 GMT
> >> Next, what *does* set the State?  It's got to come from somewhere.  Where?  How?
>
> --
> Lew

Well there is no public method for the API so I guess that there is
something handled internally in the API.

cheers,

//mike
Lew - 16 May 2008 02:21 GMT
>>>> Next, what *does* set the State?  It's got to come from somewhere.  Where?  How?
>> --
>> Lew
>
> Well there is no public method for the API so I guess that there is
> something handled internally in the API.

So it just changes state for no reason, arbitrarily?

Surely there is some external interaction that affects the state.  Surely you
just don't sit there waiting for it to change state by itself.

I ask again, what *does* set the state?  It's got to come from somewhere.
Where?  How?

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.