How to understand this strange code?

Hi,everyone
When I analysing the petstore source code ,I find it very difficult to understand the following code,who can help me?please send email to [email protected]
thank you!
public XMLFilter setup(XMLReader reader) throws PopulateException {
return new XMLDBHandler(reader, rootTag, XML_INVENTORY) {
public void update() throws PopulateException {}
public void create() throws PopulateException {
createInventory(getValue(XML_ID), getValue(XML_QUANTITY, 0));
return;
}

This function is returning an anonymous class.
This new class is constructed and defined on the fly in this code.

Similar Messages

  • How to understand this java code?

    for example:
    * The HelloWorldApp class implements an application that
    * simply displays "Hello World!" to the standard output.
    class HelloWorldApp {
    public static void main(String[] args) {
    System.out.println("Hello World!"); //Display the string.
    the explaination of above example is below:
    above example
    The method signature for the main method contains three modifiers:
    public indicates that the main method can be invoked by any object. Controlling Access to Members of a Class covers the ins and outs of the access modifiers supported by the Java programming language.
    static indicates that the main method is a class method (as opposed to an instance method). Understanding Instance and Class Members talks about class methods and variables.
    void indicates that the main method doesn't return any value.
    in that statement :
    void indicates that the main method doesn't return any value.
    while (System.out.println("Hello World!"); //Display the string.) is in
    main method
    when we run that example and it runs below result:
    Hello World!
    so i think "Hello World" is that the main method return value.
    i know i have misunderstood.
    who can help me?

    What the hell are you on about?
    System.out is a PrintStream. When you call print() or println() the parameter is displayed in/on whatever that PrintStream is associated with. If you have java 1.5 you can run the below code and see that the output will be in the file out.txt. Not in the console and definately not returned.
    import java.io.*;
    class OutTest {
      public static void main(String[] args) {
        File file = new File("out.txt");
        PrintStream ps = null;
        try {
          ps = new PrintStream(file);
        } catch(FileNotFoundException fnfe) {
          fnfe.printStackTrace();
        System.setOut(ps);
        System.out.println("Hello World");
    }

  • How to understand this statement?

    How to understand this statement?
    What is a zero-parameter public constructor
    <key-partitioning/class-name>: Specifies the name of a class that implements the com.tangosol.net.partition.KeyPartitioningStrategy interface. This implementation must have a zero-parameter public constructor.

    It is a public constructor that doesn't take any parameters. See the following simple class.
    public class Platypus
      public Platypus() {} //public constructor with no arguments
    }

  • How to use this example code in Flash AS3?

    Hi,
    How can I use this AS3 code in my Flash CS4 document? The following code is in the below link:
    http://pv3d.org/2009/12/18/tweenmax-tweening-a-timeline-advanced-tweening/#
    Please help.
    Thanks.

    Hi,
    It is working quite nice. I want to use the same code but instead of as "Document Class" I want to put that code in a first key frame of my project. I tried the following but gets an error:
    The error is : 1131: Classes must not be nested.
    And the following code  I tried is:
        import com.greensock.TimelineMax;
        import com.greensock.TweenMax;
        import com.greensock.easing.Linear;
        import com.greensock.easing.Quart;
        import flash.display.Sprite;
         * @author John Lindquist
        [SWF(width="900", height="480", frameRate="31")]
        class EasingATimeline extends Sprite
            private var square:Sprite;
            private static const STEP_DURATION:Number = 1;
            public function EasingATimeline()
                square = new Sprite();
                square.graphics.beginFill(0xcc0000);
                square.graphics.drawRect(0, 0, 50, 50);
                square.graphics.endFill();
                square.x = 100;
                square.y = 50;
                addChild(square);
                //set all the eases of your steps to Linear.easeNone
                var step1:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 700, y: 50, ease: Linear.easeNone});
                var step2:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 700, y: 350, ease: Linear.easeNone});
                var step3:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 100, y: 350, ease: Linear.easeNone});
                var step4:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 100, y: 50, ease: Linear.easeNone});
                var timeline:TimelineMax = new TimelineMax();
                timeline.append(step1);
                timeline.append(step2);
                timeline.append(step3);
                timeline.append(step4);
                //pause your timeline
                timeline.pause();
                //tween your timeline with whatever ease you want
                TweenMax.to(timeline, timeline.totalDuration, {currentTime: timeline.totalDuration, ease: Quart.easeInOut, repeat: -1});
    Please help me to solve this problem.
    Thanks.

  • How to conver this sqlserver code into Oracle

    Hi,
    Any one can help me how to covert below sqlserver code into Oracle?
    DECLARE @t1 DATETIME;
    DECLARE @t2 DATETIME;
    SET @t1 = GETDATE();
    select * from table;
    SET @t2 = GETDATE();
    SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms;

    Hi,
    Do Like This ,
    This is The function going to calculate elapsed time ,execute this before the second script,
    CREATE function DATEDIFF
      startTime in timestamp with time zone,
      endTime in timestamp with time zone
    return number
    as
      interval_ interval day (9) to second (3);
    begin
      interval_ := endTime - startTime;
      return (extract(day from (interval_)) * 86400 +
             extract(hour from (interval_)) * 3600 +
             extract(minute from (interval_)) * 60 +
             extract(second from (interval_))) * 1000;
    end;And this Is the Script that i converted to oracle,
    SET server out put on;
    DECLARE
       v_t1         TIMESTAMP;
       v_t2         TIMESTAMP;
       lv_cur       sys_refcursor;
       lv_elapsed   VARCHAR2 (30);
    BEGIN
       v_t1 := SYSTIMESTAMP;
       OPEN lv_cur FOR
          SELECT *
            FROM emp;
       v_t2 := SYSTIMESTAMP;
       SELECT datediff (v_t1, v_t2) elapsed_ms
         INTO lv_elapsed
         FROM DUAL;
       DBMS_OUTPUT.put_line (v_t1);
       DBMS_OUTPUT.put_line (v_t2);
    END;Thanks & Rgds
    BCV.

  • How to transform this pascal code into java code!

    I want to transform this pascal code into java code . Please tel me how to do it because I really don't know how to do it!
    Thanks!
    {CALCULATE HOHN-LONDON FACTORS}
    var kk:tab4;
    PROCEDURE INTENS(var kk:tab4);
    begin
    for n:=0 to nr+2 do
    begin
    kk^[1,n]:=sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1)) +lup*(yg-2);
    kk^[2,n]:= sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1))-lup*(yg-2);
    kk^[3,n]:=0.5*(kk^[1,n]*kk^[1,n]+4*(sqr(n+1)-lup*lup));
    kk^[4,n]:= 0.5*(kk^[2,n]*kk^[2,n]+4*(sqr(n+1)-lup*lup));
    kk^[5,n]:= sqrt(ldown*ldown*yd*(yd-4)+4*sqr(n+1)) +ldown*(yd-2);
    end;
    end;
    BEGIN
    new (kk);
    intens(kk);
    writeln(f2,' ','N ','V','branch ','H-L');
    for n:=1 to np do
    begin
    fp1[n,v]:=(n-ldown)*(n+ldown+1)*sqr(kk^[2,n-1]*kk^[6,n]+4*(n+ldown)*(n-ldown+1));
    fp1[n,v]:=fp1[n,v]/(4*(n+0.5)*kk^[4,n-1]*kk^[8,n]) ;
    writeln(f2,' ',n,' ',v,' fp1 ',fp1[n,v]:10:2);
    end;
    for n:=1 to nq do
    begin
    fq1[n,v]:=sqr(kk^[2,n]*kk^[6,n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)) ;
    fq1[n,v]:=fq1[n,v]/(2*(n+0.5)*kk^[4,n]*kk^[8,n]*(n+1.5));
    fq1[n,v]:=fq1[n,v]*(n+1);
    writeln(f2,' ',n,' ',v,' fq1 ',fq1[n,v]:10:2);
    end;
    for n:=1 to nr do
    begin
    fr1[n,v]:=sqr(kk^[2,n+1]*kk^[6,n]+4*(n-ldown+2)*(n+ldown+1));
    fr1[n,v]:=fr1[n,v]/(4*kk^[4,n+1]*kk^[8,n]*(n+1.5));
    fr1[n,v]:=fr1[n,v]*(n-ldown+1)*(n+ldown+2) ;
    writeln(f2,' ',n,' ',v,' fr1 ',fr1[n,v]:10:2);
    end;

    Basically it looks like this:
    public class KK{
         private your_type[][] kk = new your_type[length][length];
         private void intens(your_type[] kk){
              for(int n= 0; n<nr+2; n++){
                   kk[1][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2)) +lup*(yg-2);
                   kk[2][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2))-lup*(yg-2);
                   kk[3][n] = 0.5*(kk[1][n]*kk[1][n]+4*(Math.pow((n+1), 2)-lup*lup));
                   kk[4][n] = 0.5*(kk[2][n]*kk[2][n]+4*(Math.pow((n+1), 2)-lup*lup));
                   kk[5][n] = Math.sqrt(ldown*ldown*yd*(yd-4)+4*Math.pow((n+1), 2)) +ldown*(yd-2);
         public static void main(String args[]){
              KK k = new KK();
              k.intens(kk);
              System.out.println(f2  + ' ' + 'N ' + 'V' + 'branch ' + 'H-L');
              for(int n=1; n < np; n++){
                   fp1[n][v] = (n-ldown)*(n+ldown+1)*Math.pow((kk[2][n-1]*kk[6][n]+4*(n+ldown)*(n-ldown+1)), 2);
                   fp1[n][v] = fp1[n][v]/(4*(n+0.5)*kk[4][n-1]*kk[8][n]) ;
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fp1 ' + fp1[n][v]:10:2);
              for(int n=1; n< nq;n++){
                   fq1[n][v] = Math.pow((kk[2][n]*kk[6][n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)), 2);
                   fq1[n][v] = fq1[n][v]/(2*(n+0.5)*kk[4][n]*kk[8][n]*(n+1.5));
                   fq1[n][v] = fq1[n][v]*(n+1);
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fq1 ' + fq1[n][v]:10:2);
              for(int n=1; n < nr; n++){
                   fr1[n][v] = Math.pow((kk[2][n+1]*kk[6][n]+4*(n-ldown+2)*(n+ldown+1)), 2);
                   fr1[n][v] = fr1[n][v]/(4*kk[4][n+1]*kk[8][n]*(n+1.5));
                   fr1[n][v] = fr1[n][v]*(n-ldown+1)*(n+ldown+2) ;
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fr1 ' + fr1[n][v]:10:2); //fr1[n][v]:10:2 --> Here you must use the BigDecimal class
    }I'm not very sure because my pascal knowledge is extremely "dated".
    What about the converter I told you about?

  • How to improve this timer code ??

    Dear Sir:
    I have following code, it can works and if I remove the line "new JFrame("New Test Timer").setVisible(true);"
    Then It did not show up timer message,
    What is wrong here??
    I want to remove this line but still keep timer moving,
    How to do this??
    Thanks
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.Timer;
    public class TimerSample {
      public static void main(String args[]) {
        new JFrame("New Test Timer").setVisible(true);
        ActionListener actionListener = new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("Hello World Timer");
        Timer timer = new Timer(1000, actionListener);
        timer.start();
    }

    Swing timers are called in the event dispatch thread. If you don't start the event dispatch thread (by setting your GUI visible) then they don't get called.
    If you want a timer but you don't want a GUI, then use a java.util.Timer.

  • How to understand the strange parameter values shown by 'pstack core'

    I encounterred a problem that led to a core dump. I use 'pstack core' to shown the calling stack.
    However I could hardly understand some of the parameter values below:
    core 'core.150108' of 5016:     cmcfun
    ff1e1370 __1cLComEndPointFsendv6MpnFiovec_i_i_ (c, ffbfedf8, 2, 2, c, 0) + 4
    Why did the 'this' pointer of the instance of class ComEndPoint become 0xc? I don't think it is a valid value of pointer. Does anybody have any idea about this problem?
    ff1e5b00 __1cYComTransaction_Icallback6FpnPpdo_transaction_pcii_v_ (6ab90, 0, 0, 0, ffbff1b8, 0) + dc
    According to the source code, the 3rd parameter in the function below, which value is 0x66, was not changed in the scope of the function. However it became 0x0 when it was used as the 4th parameter to call the function above. What't the matter?
    ff1528e8 pdo_dispatch (6ab90, ad, 66, 0, 0, 0) + dc
    I heard that Sun C++ uses 'register windows' to pass the parameters, i0~i5 are used for the first 6 ones. Somebody told me that what I saw in the pstack might not be creditable because the registers might be changed within the function. Is that so? Would anybody plz tell me more details?
    Thanks in advance.
    Edited by: DirtyBear on Feb 15, 2008 1:17 AM

    Register windows are a property of the SPARC computer architecture, not a property of a compiler. SPARC has multiple sets of registers. The function call instruction advances the "register window" to reveal the next set of registers, if there is one. If not, the registers are spilled to the stack to free up a window. The function return instruction moves the window back. (It's a purely hardware feature.) Eight of the registers in adjacent windows overlap, the origin of the "window" term. Registers %o0 thorugh %o7 in the caller become registers %i0 through %i7 in the called function.
    On SPARC and x64, some function arguments are passed in registers, depending on how many arguments there are and their types. (The x86 architecture has no registers available for passing arguments.) On entry to a function, the parameters passed in registers might be saved on the stack, but do not necessarily need to be saved on SPARC. The Solaris ABI requires that space for the registers be allocated, but the space is not necessarily used.
    In a core dump, the actual registers, particularly for functions other than the current one, are not available. The pstack operation doesn't know how many parameters a function has or what type they are. It shows the contents of the first 6 words on the stack that would hold arguments, if there were arguments, and if they were actually saved on the stack.
    In optimized code on any platform, the stack area for a variable or argument is not kept up to date. Computations are kept in registers to the extent possible, and saved in memory only when necessary.
    On SPARC in particular, the argument values shown in a stack trace need not be accurate.

  • Anyone understand this strange LR3 side panel behaviour?

    In the last couple of days my laptop has developed a piece of strange behaviour related to the side panels.  I'm pretty sure it didn't start when I installed the LR3.5 update, but this may have been a contributing factor.
    Until recently I always worked in "solo" mode.  A couple of days ago, LR's behaviour changed so that opening or closing any of the side panels would cause the relevant side (left or right) to become totally unresponsive.  The rest of the program continued to work fine, and the equivalent side panel in other modules continued to work properly until a panel was opened or closed.
    In an attempt to understand what was going on, I turned "solo" mode off.  This led to some very interesting behaviour indeed:
    If I used the triangle to open or close a side panel, everything worked exactly as expected.
    If I clicked on the dark grey bar to open or close a side panel, it became stuck in one of the two states.
    When stuck in "open" state, clicking in the grey area simply caused the panel to close and then re-open, very rapidly.
    When stuck in "closed" state, something similar happened in that the panel opened and then re-closed, very rapidly.
    When in "stuck" state, clicking on the triangle had no effect on the displayed panel but it seemed to toggle the internal state between opened and closed.
    Once toggled, clicking on the grey bar opened the panel where it used to close it, and vice versa.
    When collapsed, the panel displays as pale grey rather than the more usual dark grey.  See below for an illustration.
    I have a desktop machine as well which doesn't show the behaviour.  I've tried reinstalling LR3.5, to no avail.  My guess is that we're dealing with inconsistent panel state information in the "preferences" file, but I don't know for sure.
    If anyone knows what is happening, or (more importantly) how to stop it happening, I'd be enormously grateful for some help. 
    Many thanks in advance,
    Ian Wilson
    Cambridge UK

    Further investigation yielded yet more interesting behaviour - and, it turns out, a pointer to the problem.
    I tried renaming the old "preferences" file, causing LR to create a new one.  The problem was unchanged, apart from losing my registration information... 
    I tried creating a new, virgin catalogue.  This behaved normally, so I thought I was onto something!
    I tried importing a folder of pictures into the new catalogue.  The old behaviour returned.
    I created a new virgin catalogue, which reverted to good behaviour.  I then imported one picture into the catalogue.  Behaviour BAD.
    I then tried removing the single picture from the catalogue and restarted LR.  Behaviour GOOD!
    Conclusion:  Lightroom works just fine for me providing I never put any pictures into my catalogue!! 
    This got me thinking that, perhaps, the issue was related to the rendering of images.  I tried installing the latest nVidia drivers for my laptop, but this had no effect whatsoever.  Given the issue clearly related to how images are rendered, however, I wondered whether the problem could relate to colour profiles.  BINGO!!  I'd recently upgraded my "i1xtreme" to X-Rite's new "i1publish".  The profiles created with the latest software are ".icm" rather than ".icc", although this shouldn't matter (and doesn't matter to PS and Bridge).  It seems to matter to LR, however, as reverting to my earlier ".icc" profiles made everything work again just fine. 
    There is obviously a bug somewhere, but it's not clear whether I should be chasing Adobe or X-Rite.  I'd welcome any comments or advice...
    Many thanks for the suggestions,
    Ian.

  • How to fix this class code

    This program simply takes two string arguments supplied to it from the command line, and swaps them. Then it prints the results. The actual swapping is done by the class I made called SwapWords, and I think here is the problem. I don't quite understand how to make classes other then the one class that has main in it.
    Here's the program:
    public class SwapWords {
         public SwapWords(String s1, String s2) {
              String temp = s1;
              s1 = s2;
              s2 = temp;
    class SwapStr {
         public static void main(String[] args) {
              if(args.length < 2) {
              System.out.println("usage: SwapStr [word1] [word2]");
              return;
              SwapWords(args[0], args[1]);
              for(int i =0 ; i < args.length; i++) {
                   System.out.println(args);
    Edited by: psvm on Mar 27, 2008 2:47 AM

    public class SwapWords {
         public SwapWords(String s1, String s2) {
              String temp = s1;
              s1 = s2;
              s2 = temp;
    public class SwapStr {
         public static void main(String[] args) {
              if(args.length < 2) {
              System.out.println("usage: SwapStr [word1] [word2]");
              return;
              SwapWords(args[0], args[1]);
              for(int i =0 ; i < args.length; i++) {
                   System.out.println(args);

  • How to write this java code in jsp using jstl  tags?

    Can anybody help me on this?
    I dont know how to check the containsKey using jstl tags?
    <%
         LinkedHashMap yearMap     =     (LinkedHashMap)request.getAttribute("yearMap");
         TreeSet nocSet               =     (TreeSet)request.getAttribute("nocSet");
         Iterator     yearMapIt     =     yearMap.keySet().iterator();
         while(yearMapIt.hasNext())
              int yearValue               =     (Integer)yearMapIt.next();
    %>
    <tr>
              <td><%=yearValue%></td>
    <%
              LinkedHashMap monthMap     =     (LinkedHashMap)yearMap.get(yearValue);
              Iterator     nocSetIt     =     nocSet.iterator();
              while(nocSetIt.hasNext())
                   String nCase=(String)nocSetIt.next();
                   if(monthMap.containsKey(nCase))
                        String count     =     (String)monthMap.get(nCase);
    %>
                        <td> <%= count %> </td>
    <%            }
                   else
    %>          
                        <td> 0 </td>     
    <%          
    %>
    </tr>
    <% } %>Edited by: avn_venki on Feb 18, 2008 11:54 PM

    <c:forEach var="yearMap" items="${requestScope.yearMap}">
         <th> <c:out value="${yearMap.key}"/> </th>
    <bean:define id="monthMap" value="${yearMap.value}"/>
    <c:forEach var="nocSet" items="${nocSet}">
    then how to write containsKey using tags??

  • How to implement this C code line: for ( int i = 0; i G_ReadLen; i = i + 2 )

    I want to implement the following C++ code in labview but i cannot make or loop to increase by two
    int j = 0; for ( int i = 0; i < G_ReadLen; i = i + 2 ) {
    BYTE AD_H = ByteArray.GetAt(i);
    BYTE AD_L = ByteArray.GetAt(i + 1);
    ValueArray[j] = AD_H << 8;
    ValueArray[j] = ValueArray[j] + AD_L;unsigned long Temp = ValueArray[j] >> 12; Volts[j] = ((float)ValueArray[j]) * 0.0048875;Message.Format("%X , %X - %X, -- %d, +%.3f Volts", AD_H, AD_L, ValueArray[j], ValueArray[j], Volts[j]); m_output_ep1i.InsertString(0,Message);
    j = j + 1;
    Thanks
    Solved!
    Go to Solution.

    Your code will not work.
    You are replacing elements of an empty array. A no-op in LabVIEW.
    Besides there is a lot easier way to do this:
    I just hope this is not a homework assignment.
    And for completeness sake here is Mikes solution (seen below):
    Ton
    Message Edited by TonP on 11-14-2008 12:55 PM
    Message Edited by TonP on 11-14-2008 01:03 PM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    Read as U16.png ‏2 KB

  • How to modify this JSP code?

    Below is my code in my JSP, I would like to put my codes that I had underline after the "confirm1"(bold color) line if I click "confirm1" in my codes.How should I change it because I am very confusing on it.If I simply cut my codes into there,it will occured error,so I need to be careful on it...anyone can help?I will appreciate your help....
    <%-- start web service invocation --%><hr/>
    <%
    try {
    if(request.getParameter("btnCancel")!=null)
         if(e.equals("No booking record found!"))
    {%>
    <label style="z-index: 118; left: 300px; position: absolute; top: 700px">Please enter your booking ID.</label>
    <%}
    else
    {%>
    <script type="text/javascript">
    var confirm1 = window.confirm("-------------")
    if(confirm1)
    </script>
    <% }
         org.tempuri.CancelTravelBooking service = new    org.tempuri.CancelTravelBooking();
    _     org.tempuri.CancelTravelBookingSoap port = service.getCancelTravelBookingSoap();_
    _     // TODO initialize WS operation arguments here_
    _     java.lang.String bookingID = c;_
    _     java.lang.String destination = a;_
    _     java.lang.String date = b;_
    _     java.lang.String personAvailable = d;_
    _     // TODO process result here_
    _     java.lang.String result = port.cancelBooking(bookingID, destination, date, personAvailable);_
    } catch (Exception ex)
    %>
    <%-- end web service invocation --%><hr/>

    Ravi,I really hope that you could help you and thanks to you first...
    <%-- start web service invocation --%><hr/>
    <%
    try {
    if(request.getParameter("btnCancel")!=null)
    if(e.equals("No booking record found!"))
    {%>
    <label style="z-index: 118; left: 300px; position: absolute; top: 700px">Please enter your booking ID.</label>
    <%}
    else
    {%>
    <script type="text/javascript">
    var confirm1 = window.confirm("-------------")
    if(confirm1)
    </script>
    <% }
    org.tempuri.CancelTravelBooking service = new org.tempuri.CancelTravelBooking();
    _ org.tempuri.CancelTravelBookingSoap port = service.getCancelTravelBookingSoap();_
    _ // TODO initialize WS operation arguments here_
    _ java.lang.String bookingID = c;_
    _ java.lang.String destination = a;_
    _ java.lang.String date = b;_
    _ java.lang.String personAvailable = d;_
    _ // TODO process result here_
    _ java.lang.String result = port.cancelBooking(bookingID, destination, date, personAvailable);_
    } catch (Exception ex)
    %>
    <%-- end web service invocation --%><hr/>

  • How to write this sql code ?

    for example below shows:
    create table temp
    order_type varchar2(30),
    order_num number);
    insert into temp values('apple',000001);
    insert into temp values('banana',000002);
    insert into temp values('chair',000003);
    select *
    from temp
    where instr(order_type,decode(x,1,'a',2,'b',2,'c',order_type)) >0
    if i let x equals 2 and i want to get b and c from above querying .
    why above query could not get 'c' and only get 'b' if i give 2 to x ?
    how to write above select clause ?
    who can help me ?
    thanks!

    Decode will return the first match;
    SQL> select decode(2,1,'a',2,'b',2,'c')
    from dual
    D
    b
    1 row selected.This may help;
    old: select *
    from temp
    where regexp_like(order_type, case to_number(&x)
                                     when 1 then 'a'
                                     when 2 then 'b|c'
                                  end)
    new: select *
    from temp
    where regexp_like(order_type, case to_number(2)
                                     when 1 then 'a'
                                     when 2 then 'b|c'
                                  end)
    ORDER_TYPE                      ORDER_NUM
    banana                                  2
    chair                                   3
    2 rows selected.

  • How to optimize this RW code? (full version)

    Hello: (Sorry for the wrong previous post, hope the moderator delete it)
    I have this code:
    import java.io.*;
    class Number
        private byte val=0;
        public void Read(DataInputStream ar) throws Exception {val=ar.readByte();}
        public void Read(RandomAccessFile ar) throws Exception {val=ar.readByte();}
        public void Write(RandomAccessFile ar) throws Exception {ar.writeByte(val);}
        public void Write(DataOutputStream ar) throws Exception {ar.writeByte(val);}
    }As you can see, I have methods for storing and writing into RandomAccessFiles and DataStreams. The code for RW is the same for both media. Is there any way to use the same code for Read(DataInputStream ar) and Read(RandomAccessFile ar)? Note that actually my class is more complex and can contain many data for RW: integers, doubles, objects, so that's why I want to simplify it. I thought about this possibility:
    public void Read(Object ar)  throws Exception  
          if(ar instanceof RandomAccessFile) val= ((RandomAccessFile)ar).readByte();
          if(ar instanceof DataInputStream ) val= ((DataInputStream )ar).readByte();
    public void Write(Object ar)  throws Exception  
          if(ar instanceof RandomAccessFile) val= ((RandomAccessFile)ar).writeByte(val);
          if(ar instanceof DataOutputStream ) val= ((DataOutputStream )ar).writeByte(val);
    }But as you can see I have to make casts and repeat the code, I only got the advantage of having one single method.
    Any suggestion?
    Thanks!

    Both DataOutputStream and RandomAccessFile implement the interfaces DataOutput, so you could do:
    public void write(DataOutput out) throws Exception  
      out.writeByte(value);
    }(the other case, RandomAccessFile and DataInputStream, use DataInput)

Maybe you are looking for

  • Sent e-mail messages do not appear in the sent box

    sent e-mail messages do not appear in the sent box

  • Stops Reading at Random Intervals

    hello,  we wrote a program for our hot plate and for some reason it will suddenly stop reading at random intervals and give a result of 0's for heating and stirring. we're not sure why this is? is it a hardware problem or a visa read/buffer problem?

  • Only 24 transitions in FCP 10.1.1 ??

    Hi, I have recently had to deleted and reinstall fcp 10.1.1 and I only seem to have 24 transitions available (I seem to be missing flash/lens glare transitions). I'm sure I'm missing something obvious but can anyone tell me how to find these- I have

  • Aperture Vault and Time Machine

    Does anyone know how this will operate ? Will the Aperture Vault be TM 'unaware' ? Roger

  • IR Receiver On Older mac

    I have an iBook (running leopard) with no IR receiver, i want to know if i get a reciever, and use an apple remote is there any software required? I know there are alot of apps that provide extended functionality, but if i just want to use front row