Enumeration example from book by Bloch

Hiya,
I would like to know how to do this stuff below AND if it has any sense with this construction of enumeration:
public enum Phase {
     SOLID, LIQUID, GAS;
     public enum Transition {
                //freeze2 it's made no sense but maybe does if I had another "kind" of object
          MELT(SOLID, LIQUID), FREEZE(LIQUID,SOLID), BOIL(LIQUID,GAS),  FREEZE2(LIQUID,SOLID), 
          CONDENSE(GAS,LIQUID), SUBLIME(SOLID,GAS), DEPOSIT(GAS,SOLID);
          final Phase src;
          final Phase dst;
          Transition(Phase src, Phase dst) {
               this.src = src;
               this.dst = dst;
          private static final Map<Phase, Map<Phase,Transition>> m =
               new EnumMap<Phase, Map<Phase, Transition>>(Phase.class);
          static {
               for (Phase p : Phase.values()) {
                    m.put(p, new EnumMap<Phase, Transition>(Phase.class ));
               for (Transition trans : Transition.values()) {
                    m.get( trans.src).put(trans.dst, trans);
          public static Transition from(Phase src, Phase dst) {
               return m.get(src).get(dst);
//main
//this below print out just Freeze2; I don't even know why; btw I'd like to have all transition LIQUID to SOLID, i.e freeze and freeze2
System.out.println( Phase.Transition.from(Phase.LIQUID, Phase.SOLID) );

mickey0 wrote:
Ok, I knew it was without sense. I even knew my problem was on Map. I just write "enumeration" because it's an enum exmaple in the book.
So: "pretending that FREEZE2 has sense": is there a way to rertrieve the two different Phase.??In the future, you'll get better answers if you use a meaningful subject, ask a question about the problem you're actually having, and use code that focuses on that problem, rather focusing on something else and having the problem as a minor bit on the side.
I can't really answer a nonsensical question by pretending it makes sense. I don't even know what you're asking. That is, if you were to have asked a question that makes sense, what problem would you really be trying to solve?
Your question is NOT simply "How do I get it to print both FREEZE and FREEZE2?" That doesn't even fit in with the example.
It looks like your question might be, "How do I associated multiple values with a single key in a Map?" If so, then the answer is, you don't, because java.util.Map is for mapping a key to a single value. Depending on your actual requirements and desired functionality, you might be able to do what you want by simply storing Lists or other Collections as the values, or you might have to download a third party collection that has a MultiMap or similar class (I think apache commons might), or write your own.
If that's not your question, then what is?

Similar Messages

  • Employee example from Book, only blank page

    Hi all!
    I have installed the CE 7.1 trail and i programmed the example from the SAP book "Java programming with SAP NetWeaver"
    I did't change the code, I followed all steps in the book but in the end when i trie to run the application ( the jsp ) i just get a blank page without any errors or hints.
    Generally he displays no jsp pages... html pages are working
    I tried it with firefox and IE, and java is aktivated.
    Maybe anyone here has an idea what the problem could be.
    Thankyou for your help
    Edited by: seeboeck on Feb 5, 2010 10:47 AM

    Select  ▹ System Preferences ▹ Network ▹ Advanced ▹ TCP/IP. What values are shown for the following:
    Configure IPv4
    IPv4 Address
    Subnet Mask
    Router

  • How to import examples from book "Advanced BSP Programming"

    Hello,
    i bought the book "advanced bsp programming". But i don't know how to import the "*.nsp" Transport files from the cd into the sap system.
    It is a sap R/3 with SAP Basis Release 6.20 Level 57.
    Could someone help me?
    Best regards,
    Nils Kloth

    Your best bet is to always make friends with a nice Basis person who does the transports for your landscape.  Quite often developers don't have access (OS and SAP) to perform transports.  However if this is sandbox system and you want to give it a try - you should probably just read up on TMS (Transport Mangement System) first.
    Assuing that TMS is configured properly on your system and you can perform exports and imports the process isn't terribly complicated.
    Copy the the transport files into your TRANS directory (/usr/sap/trans/).  The file name that begins with the letter K goes into the cofiles subdirectory.  The file name that begins with the letter R goes into the data subdirectory. 
    You can then log into your system and run transaction code STMS.  Go to the Import Overview.  Chose your local system ID. Choose Menu Option: Extras->Other Requests->Add.  Now supply the transport number.  This will attach the transport to your import que.  Now you can follow the normal process for importing the transport.
    I want to stress that you should NOT try to perform imports unless you are comfortable with the process or this is a sandbox system that no one will be upset if something goes wrong.  You should also NOT transport the code samples into a development system at all unless you are willing to take responsibility.  The authors of the book (myself and Brian) take no responsibility for any damage done by the transport (Legal CYA).  That is why we also supply all code in text files so that it can be imported manually and possibly renamed to match whatever naming standards you may have.  All the code is delivered in the customer name range as a customer object and can be modified in the delivery system.
    Please note that there will be some import errors on 620 because this transport contains code for 640 and 04S.  Most of these import errors are documented on the CD and do not effect the overall process.

  • Writing action script from books or memory?

    hey guys. I mess around with Flash and get into the most
    basic action scripting. My question is, for the most part, do
    designers all copy existing code and modify it to fit thier design
    needs, or do they just write it themselves all the time? I really
    cant imagine the latter. Im hoping that designers always have tons
    of books around.

    "Nicknamenick" <[email protected]> wrote in
    message news:ebue8f$s0c$[email protected]..
    > hey guys. I mess around with Flash and get into the most
    basic action
    > scripting. My question is, for the most part, do
    designers all copy existing
    > code and modify it to fit thier design needs, or do they
    just write it
    > themselves all the time? I really cant imagine the
    latter. Im hoping that
    > designers always have tons of books around.
    Books don't do it for me. It takes too long to get the right
    kind of example from books. What I do is to make folders of Flash
    source code that is categorized. One of the advantages of
    helping people on these forums is seeing so many code examples.
    Whenever
    I run across a good example of something or write a piece of
    code for someone I save it as a reference in one of the folders.
    Now
    when I need any code I either write it from memory if it's
    short enough or go to one of my source code folders for examples. I
    have
    lots of books but that aren't nearly as valuable to me as my
    sorted source code.
    Online website sources such as flashkit.com and others can be
    very counter-productive for me. The examples are often old code
    from
    Flash 4 and 5 and usually written by an amateur with bad
    coding style. The online book recourses like safari.com are great
    though.
    You can search for code snippets through all the Flash books.
    tralfaz

  • I can't run example from JEE5tutorial - books

    OS- Linux
    NetBeans 5.5.1 ( with ant 1.7 )
    ant 1.6
    I tried run:
    ant 1.6
    [root@zet books(0)]# ant create-tables
    Buildfile: build.xml
    BUILD FAILED
    /home/marcin/3ROK/1SEM/java1/javaeetutorial5/examples/web/books/build.xml:49: The following error occurred while executing this line:
    /home/marcin/3ROK/1SEM/java1/javaeetutorial5/examples/bp-project/main.xml:20: Class org.apache.tools.ant.taskdefs.ConditionTask doesn't support the "else" attribute.
    Total time: 1 secondon ant 1.7
    [root@zet books(0)]# /usr/local/netbeans-5.5.1/ide7/ant/bin/ant create-tables
    Unknown argument: -cp
    ant [options] [target [target2 [target3] ...]]
    Options:
      -help, -h              print this message
      -projecthelp, -p       print project help information
      -version               print the version information and exit
      -diagnostics           print information that might be helpful to
                             diagnose or report problems.
      -quiet, -q             be extra quiet
      -verbose, -v           be extra verbose
      -debug, -d             print debugging information
      -emacs, -e             produce logging information without adornments
      -lib <path>            specifies a path to search for jars and classes
      -logfile <file>        use given file for log
        -l     <file>                ''
      -logger <classname>    the class which is to perform logging
      -listener <classname>  add an instance of class as a project listener
      -noinput               do not allow interactive input
      -buildfile <file>      use given buildfile
        -file    <file>              ''
        -f       <file>              ''
      -D<property>=<value>   use value for given property
      -keep-going, -k        execute all targets that do not depend
                             on failed target(s)
      -propertyfile <name>   load all properties from file with -D
                             properties taking precedence
      -inputhandler <class>  the class which will handle input requests
      -find <file>           (s)earch for buildfile towards the root of
        -s  <file>           the filesystem and use it
      -nice  number          A niceness value for the main thread:
                             1 (lowest) to 10 (highest); 5 is the default

    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    What happens if you open Firefox in Save mode?
    *https://support.mozilla.com/kb/Safe+Mode
    *Help > Restart with Add-ons Disabled

  • Looking for an example from app gallery that uses WAAD for identity

    I'm looking for an example from the app gallery (http://azure.microsoft.com/en-us/gallery/active-directory/) that uses WAAD for identity. I need one the show our business what the process would look like for an organization signing up for a SaaS offering
    via the App Gallery. I know all the Microsoft applications use WAAD but I was hoping to find a third-party example.  What I mean is an app where all tenant and user identity is done using WAAD as opposed to federated identity.

    I doubt that what you are looking for exists yet.
    Cheers,
    Markus
    Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation

  • Exporting pdf from book

    I quite new in Java scripting and I'm working (or studing) to export pdf from book through a script.
    I want to save the pdf in the same paths and with the same name  of the books itself... is it possible?
    For what I found
    ExportFormat.pdfType,
      File(Folder.desktop + "/name.pdf"), true;
    there should be a way ti change or even to ask name and path.
    thanks

    The below link may help you:
    JavaScript Reference Guide:
    http://jongware.mit.edu/idcs6js/
    Script written by Great People:
    Scrips written by other people
    Vandy

  • Interface Monitoring - any example from your experience please ?

    Hi Gurus,
    In Interface Monitoring (as a subset of BPM), as you may be aware, as of Software Component ST-SER Release being  700_2008_1, a new functionality is supported:
    http://help.sap.com/saphelp_sm40/helpdata/en/2c/40328724e2431ba71958275b15e9fb/content.htm
    Well, I am keen to learn from your experiences if you have already used this.
    My specific question is: Can you please share an example, from your experience, an example of Interface Scenario, Interfaces and Interface Steps  for SAP interacting with Non-SAP systems inside/outside the company?
    Best regards,
    Srini

    Closing this for housekeeping sake.

  • FM to read files starting with TEST(for example) from Unix server

    Hi all,
    Is there a FM to read all the files which start with TEST (for example) from the Unix server?
    Requirement is if we put TEST* in the selection screen for the filename, it should read all the files which start with TEST from the default Unix path.
    Thanks and regards,
    Anishur

    Function Modules
    http://www.erpgenie.com/abap/functions.htm
    http://www.sapdevelopment.co.uk/fmodules/fmssap.htm
    http://www.erpgenie.com/abap/index.htm
    http://www.geocities.com/victorav15/sapr3/abapfun.html
    Rewards if useful.........
    Minal

  • OAS Error with Servelet example from OTN

    I have followed the servelet example
    from OTN Oracle Java Roadmap and it works
    in JDeveloper. THen I followed the steps for
    deployment to OAS and I get the following
    02-22-2000 13:21:43 0 demlwo193 `JAVAWEB` 445 7 0x400fff `Java cartridge runtime intialize..., thr_id: 19
    `
    02-22-2000 13:21:43 0 demlwo193 `JAVAWEB` 445 7 0x400fff `Notify object content initialized to null`
    02-22-2000 13:21:43 0 demlwo193 `JAVAWEB` 445 7 0x400fff `config flag: MAX_HEAP value: 64M
    `
    02-22-2000 13:21:43 0 demlwo193 `JAVAWEB` 445 7 0x400fff `config flag: SYSTEM_PROPERTY value: java.naming.factory.initial=oracle.oas.naming.jndi.CartxInitCtxFactory
    `
    02-22-2000 13:21:43 0 demlwo193 `JAVAWEB` 445 7 0x400fff `config flag: SYSTEM_PROPERTY value: ORACLE_HOME=e:\oracle\oas
    `
    02-22-2000 13:21:43 0 demlwo193 `JAVAWEB` 445 7 0x400fff `config flag: SYSTEM_PROPERTY value: ORAWEB_HOME=e:\oracle\oas\ows\4.0
    `
    02-22-2000 13:21:43 0 demlwo193 `JAVAWEB` 445 7 0x400fff `Using Servlet runtime
    `
    02-22-2000 13:21:43 0 demlwo193 `JAVAWEB` 445 7 0x400fff `config flag: RUNTIME_MODE value: JSERVLET
    `
    02-22-2000 13:21:43 0 demlwo193 `JAVAWEB` 445 7 0x400fff `CLASSPATH=e:\oracle\oas\ows\4.0\jdk\lib\classes.zip;e:\oracle\oas\ows\4.0\classes\services.jar;e:\oracle\oas\ows\cartx\jweb\classes\jweb.jar;e:\oracle\oas\ows\cartx\jweb\classes\j servlet.jar;e:\oracle\oas\orb\classes\yoj.jar;e:\oracle\oas\ows\4.0\classes\cosnam.jar;e:\oracle\oas\orb\classes\session.jar;e:\oracle\oas\orb\classes\cache.jar;e:\oracle\oas\jdbc\ lib\classes111.zip;e:\oracle\oas\ots\classes\oraclejts.jar;e:\oracle\oas\ots\classes\jtsjdbc.jar;e:\oracle\oas\ows\4.0\classes\ecoapi.jar;e:\oracle\oas\ows\4.0\classes\ejbapi.jar;e :\oracle\oas\ows\4.0\classes\oasdeploy.jar;c:\ctxdemo\DemoDBServelet.jar;c:\jCVS-5.1.1\jcvsii.jar
    `
    02-22-2000 13:21:47 0 demlwo193 `JAVAWEB` 445 0 0x400fff `Exception `
    02-22-2000 13:21:47 0 demlwo193 `JAVAWEB` 445 0 0x400fff `in thread `
    02-22-2000 13:21:47 0 demlwo193 `JAVAWEB` 445 0 0x400fff `"Thread-5"`
    02-22-2000 13:21:47 0 demlwo193 `JAVAWEB` 445 0 0x400fff ` `
    02-22-2000 13:21:47 0 demlwo193 `JAVAWEB` 445 0 0x400fff `Exception happend in executing:oracle.OAS.servlet.servletrunner.main(String[])
    `
    null

    1. Which version of JDK you are using. OAS 4081 is certified for JDK 1.1.6. If you are using JDeveloper3.0 (JDK 1.2.2), please change over to JDeveloper3.0 (JDK 1.1.8).
    2. Similarly, which version of JVM is used with OAS. You may have to edit your wrb.app to make necessary changes.
    Jayakumar
    null

  • Help w/SAX Example from JWSDP1.1

    I have been trying to execute the SAX Parser example from the WSDP1.1 tutorial -- Echo01.java with slideSample.xml and I keep getting the following exception even though the program has compiled successfully:
    C:\j2sdk1.4.2\programs>java Echo01 slideSample.xml
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/parsers/SAXParser
    I have a gut feeling this has something to do with my classpath variable, but I just can't seem to figure it out. I have placed all the required .jar files in the <JAVA_HOME>/jre/lib/endorsed directory.
    My classpath variable holds the following information, but when I try to view it in DOS, I get the following JVM error:
    Failed to load Main-Class mainfest attribute from C:\j2sdk1.4.2\jre\lib\endorsed\sax.jar
    My CLASSPATH variable reads as follows:
    C:\j2sdk1.4.2\jre\lib\endorsed\sax.jar;C:\j2sdk1.4.2\jre\lib\endorsed\dom.jar;C:\j2sdk1.4.2\jre\lib\endorsed\xalan.jar;C:\j2sdk1.4.2\jre\lib\endorsed\xercesImpl.jar;C:\j2sdk1.4.2\jre\lib\endorsed\xsltc.jar;C:\j2sdk1.4.2\programs
    PLEASE ADVISE!!!!!!!!!

    I came across this problem before. The problem maybe you have used an old version of java.exe. I am using Windows XP and I realise that there is another java.exe in the path "C:\WINDOWS\system32". Therefore, if the path "C:\j2sdk1.4.2\bin" is put after "C:\WINDOWS\system32" in your Path variable, your computer will always load the java.exe in "C:\WINDOWS\system32", which is an older version shipped with your Windows. So, try to move "C:\j2sdk1.4.2\bin" in front of "C:\WINDOWS\system32 in the Path variable.
    I hope this works!!

  • Problems doing the "Web Service" example from the 2-Day-Developer Guide

    Hello,
    I want to do the "web service" example from the 2-Day-Developer Guide.
    I give the application my proxy server address in the format address:port and go through the assistant creating the web service. After selecting the IBM UDDI-service and searching for %xMethods% as business name I get the following error:
    ORA-31011: XML-Parsing not successful ORA-19202: Error parsing XML LPX-00104: Warning: Element "html" is not declared in DTD Error at line 2
    What have I done wrong?
    With kind regards
    Florian Reiser

    Please.. Could you change your forum handle to something more human, we are a friendly group here and lik to know who we are talking to.. Secondly, WHy are you using such an OLD version oft he product. You would be better off installing 3.2.1 (latest released build) and asking your questions after you do that..
    (I am sorry, it's like asking for help in a Windows support forum about issues you are having with Windows 3.1)
    Thank you,
    Tony Miller
    Webster, TX

  • Could not run the bookstore1 example from the Java Web Services Tutorial

    The bookstore1 servlets example from the Java Web Services Tutorial (issue Aug 1, 2002) was built and deployed successfully by using the deploytool (following the steps described on pages 498ff of the tutorial).
    After deploying the application the Tomcat Web Application Manager shows the entry:
    /bookstore1:stopped:0:D:\Programme\Java\tomcat\jakarta-tomcat-4.1.8\work\Standalone\localhost\manager\bookstore1.war
    when entering the command: http://localhost:8080/manager/list.
    After entering the command: http://localhost:8080/manager/start?path=/bookstore1, the (uncomplete) message appears:
    FAIL - Application at context path /bookstore1 could not
    It should be noted that I was able to build and deploy the application GSApp (chapter 3 of the tutorial) successfully.

    Did you set up the database as described in
    http://java.sun.com/webservices/docs/1.0/tutorial/doc/WebApp13.html#69868

  • Running examples from J2EE Tutorial

    Has anyone been successfully running examples from
    J2EE Tutorial on Creator?
    I tried to import the JSP but Creator complains that it is
    not an XHTML document. Clicking on the 'Convert to XHTML'
    button or 'Preview...' button does not seem to do anything.
    Openning the Source panel shows parsing problems on
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    Does anyone know how to run these in Creator correctly?
    - weijyh

    Yes,
    It runs successfully....
    I have download the examples from Sun,
    unzipped It into my Projektfolder and open it in Creator, start it and works fine ...
    No error messages ....

  • To acess grid control out of the network (example from my house)

    Its possible to configure grid control console and oms to access out of the network , for example from my house by internet access.
    Thanks

    If you want to connect to the EM Website you should have a connection from your home to your company. Usually using a VPN you can solve this.
    If you want to monitor the temperature of your fridge using GridControl (if you manage to install an agent on the fridge) than you have to configure proxies for your GridControl and your agent - if there is a firewall between home and work (hopefully there is one ;-)
    We are using a VPN tunnel to connect from home office to our company lan. There are several ways to do this in a secure way (RSA tokens, smartcards, fingerprints etc.)
    regards
    Andreas

Maybe you are looking for