Avoiding using instanceof operator

I've heard that using the instanceof operator isn't such a great code technique, and since I'm in the design phase, I feel like I should be able to avoid this. Right now, part of my design requires use of the instanceof operator as well as casting.
Let's say you have a common notifier interface and two abstract classes which extend from this interface:
com.example.Notifier Interface:
public void doNotify(Notification notif, List notifiables);
public boolean canSend(Notification notif, Notifiable person);
com.example.SerialNotifier (abstract)
public void doNotify(Notification notif, List people)
    for (Iterator itList = people.iterator(); itList.hasNext();)
         Notifiable person = (Notifiable)itList.next();
         doNotify(person, notif);
public abstract doNotify(Notification notif, Notifiable person);
com.example.MulticastNotifier (abstract)
public abstract void doNotify(Notification notif, List notifiables);MulticastNotifier purposefully doesn't define a way to send a message to a single person, so that developers don't implement a non-multicast solution for a multicast protocol.
Here's the part that seems to require an "instanceof" clause. Now let's say you have a list of Notifiers. The list of notifiers is mixed, containing both Serial and Multicast Notifiers. Before you send out the notification, you need to filter the list (because for example, someone doesn't want to be notified at all):
    for (Iterator itNotifiers = notifiers.iterator(); itNotifiers.hasNext();)
         Notifier notifier= (Notifier)itNotifiers.next();
         List buildPeopleList = new ArrayList();
         for (Iterator itPeople = people.iterator(); itPeople.hasNext())
               Notifiable person= (Notifiable)itPeople.next();
               if (notifier.canSend(person, notification))
                       if (notifier instanceof MulticastNotifier)
                              buildPeopleList.add(person);
                       } else
                               SerialNotifier serialNotif = (SerialNotifier)notifier;
                               serialNotif.doNotify(notification, person);
         if (notifier instanceof MulticastNotifier)
                  notifier.doNotify(notification, buildPeopleList)
    }Is this bad design? Another option is to just iterate through the list essentially twice, but this is of course, less efficient for the serial notifier case:
    for (Iterator itNotifiers = notifiers.iterator(); itNotifiers.hasNext();)
         Notifier notifier= (Notifier)itNotifiers.next();
         List buildPeopleList = new ArrayList();
         for (Iterator itPeople = people.iterator(); itPeople.hasNext())
               Notifiable person= (Notifiable)itPeople.next();
               if (notifier.canSend(person, notification))
                       buildPeopleList.add(person);
         notifier.doNotify(notification, buildPeopleList);
    }Any suggestions?

I'm not sure what you mean. I moved a loop from your
code to a different class. AFAICT, it's a
one-for-one. My solution has the same number of
iterations as yours.Yeah, your code is actually missing a loop, because, as I explained earlier, the design supports filtering at both a parent notifier and a child notifier. To filter, it needs to loop through the list of people
So, your code actually will look like: (forgive me, doing code in a textarea is kinda a pain)
public void ParentNotifier implements Notifier
// member var for simplicity
protected Filter myFilter = new ExampleFilter();
protected List notifiers = // list of notifiers
public void doNotify(Notification n, List people)
  List intermediateList= new ArrayList();
  for (Iterator itPeople = people.iterator(); itPeople.hasNext();)
        Notifiable person = (Notifiable); itPeople.next()
        if (myFilter.canSend(n, person) // parent's filter
             intermediateList.add(person);
   for (Iterator itNotifiers = notifiers.iterator(); itNotifiers.hasNext();)
                Notifier notif = (Notifier)itNotifiers.next();
                notif.doNotify(n, intermediateList); // 2nd loop is in here where additional filtering takes place
}If you assume a serial notifier, you don't need this additional iteration:
public void ParentNotifier implements Notifier
// member var for simplicity
protected Filter myFilter = new ExampleFilter();
protected List notifiers = // list of notifiers
public void doNotify(Notification n, List people)
  for (Iterator itPeople = people.iterator(); itPeople.hasNext();)
        Notifiable person = (Notifiable); itPeople.next()
        if (myFilter.canSend(n, person) // parent's filter
             for (Iterator itNotifiers = notifiers.iterator(); itNotifiers.hasNext();)
                     Notifier notif = (Notifier)itNotifiers.next();
                     // PROBLEM HERE: assumes serial notifier
                     notif.doNotify(n, person); // child will do own filtering
}Edit: Corrected logic error in code

Similar Messages

  • Is the 'instanceof' operator discouraged ?

    Hi,
    I have heard that the instanceof operator is not recommended and should be used only as a last resort. Can someone throw some light into it ? is there an alternative ?
    thanx and regards

    hi,
    thanx for the response.
    well, the BaseException and its subclasses belong to a different applicaiton, and my application calls this application thru remote interface.
    For each of the 5 sub-exceptions, we need to log a different message, and then propogate the same to our client.
    There is too much code repetetion-- My session bean has 10 methods, each of these catch the 5 sub-classes, log a message and throw a new exception.
    To avoid code repetetion, i ll catch the BaseException in each of the 10 methods of session bean, and then in the catch block, i ll call a method say -- handleExeption, which will identify the type of exception and take the action that were taken earlier by the multiple catch blocks.
    Now, I need to use the instanceof operator to identify the specific type of exception. Will it be recommended practice ?
    thanx and regards

  • Java InstanceOf operator

    I am writing a program that runs on a simulated network, that exposes my data to potential corruption. So, if I send an object across the network and some of the bytes in that object get corrupted will the instanceof operator still recognize that object as a member of a particular class even though some of the data is corrupted, or does it depend on which actual bytes are corrupted?

    When an object is serialized part of what's sent is the name of the class, and that's all that determines what class of object it will attempt to reconstruct..
    If you're using an unreliable connection stream then you should probably add a CRC check of some kind. Most of the channels you migh use have that built in.

  • To re-write query using 'ANY' operator

    Hi,
    How to write the given query using 'ANY ' operator , I dont need to fetch to grade_master table twice in database, just need to fetch within the result set.
    SELECT dsg_code,dsg_name,dsg_grade FROM designation_master WHERE dsg_orgn='&&Orgn' and dsg_ctry='&&ctry'
    And dsg_loc ='&&loc' And dsg_oru = '&&oru' and dsg_grade in decode('&&radio_group',
    1, SELECT grd_code FROM grade_master WHERE grd_osm_code in (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&Orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'),
    2, SELECT grd_code FROM grade_master WHERE grd_osm_code > (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' and grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code),
    3, SELECT grd_code FROM grade_master WHERE grd_osm_code < (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'))
    thanks
    rincy

    Tubby is correct that data and create statements are required to analyze it correctly.
    Still I worked on it and created something using WITH clause
    with grd_query
    as
    (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' and grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade')
    ,grd_mst_query
    as
    (SELECT grd_code, grd_osm_code FROM grade_master)
    SELECT dsg_code, dsg_name, dsg_grade
      FROM designation_master
    WHERE dsg_orgn = '&&Orgn'
       AND dsg_ctry = '&&ctry'
       AND dsg_loc = '&&loc'
       AND dsg_oru = '&&oru'
       AND dsg_grade in   
       decode('&&radio_group',1, (SELECT grd_code FROM grd_mst_query WHERE grd_osm_code in (select * from grd_query)),
    2, (SELECT grd_code FROM grd_mst_query WHERE grd_osm_code > (select * from grd_query)),
    3, (SELECT grd_code FROM grd_mst_query WHERE grd_osm_code < (select * from grd_query)))this should avoid multiple scans on same table.
    thanks

  • Instanceof operator, please help!

    I am reading the codes written by others. I am confused on instanceof operator here.
    (A instanceof B) where A and B are interfaces. I found a definition in a book such that the
    instanceof operator returns true or false based on whether the object is an instance of the named
    class or any of that class's subclass. However, I didn't find the relationship between A and B is
    established in the codes. In this case, I wonder if instanceof operator can still be used because I am thinking that it will always evaluate to be false.
    Thank you for your help!
    Cathy

    The instanceof operator can always be used - a return value of false is still a valid return value!
    However, when it comes to interfaces it is possible for a class to implement both interfaces even though there may be no direct relationship between those interfaces.
    Have a look at this:
    public interface MyInterface
    public interface YourInterface
    public class MyClass implements MyInterface, YourInterface
    }There is no relationship between the two interfaces but I can still do this:
    public void check(MyInterface myObj)
      if(obj instanceof YourInterface)
        YourInterface yourObj = (YourInterface)myObj;
        System.out.println("Woo hoo - an instance of MyInterface that's also an instance of YourInterface!");
    }Essentially the instanceof operator is asking if the value passed can be cast to something else for the method to use it more specifically.
    There could be classes other than MyClass that implement both interfaces, particularly if a system is designed to be flexible.
    I hope this makes sense!

  • Error while using between operator with sql stmts in obiee 11g analytics

    Hi All,
    when I try to use between operator with two select queries in OBIEE 11g analytics, I'm getting the below error:
    Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Location: saw.views.evc.activate, saw.httpserver.processrequest, saw.rpc.server.responder, saw.rpc.server, saw.rpc.server.handleConnection, saw.rpc.server.dispatch, saw.threadpool.socketrpcserver, saw.threads
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 27002] Near <select>: Syntax error [nQSError: 26012] . (HY000)
    can anyone help me out in resolving this issue.

    Hi All,
    Thank u all for ur replies, but I dint the exact solution for what I'm searching for.
    If I use the condition as
    "WHERE "Workforce Budget"."Used Budget Amount" BETWEEN MAX("Workforce Budget"."Total Eligible Salaries") AND MAX("Workforce Budget"."Published Worksheet Budget Amount"",
    all the data will be grouped with the two columns which I'm considering in the condition.
    my actual requirement with this query is to get the required date from a table to generate the report either as daily or weekly or monthly report. If I use repository variables, variables are not getting refreshed until I regenerate the server(which I should not do in my project). Hence I have created a table to hold weekly start and end dates and monthly start and end dates to pass the value to the actual report using between operator.
    please could anyone help me on this, my release date is fast approaching.

  • How to avoid using constants ?

    Hello,
    I am starting a new project and I am thinking of a way to avoid using constants.
    For example, in a report, it selects all the order with types ZLN and ZLB.
    I know that I have several possibilities :
    - hard code it in the program (using constants which I want to avoid)
    - create a specific table with all the types that I want to select (this may be the best solution but it can be very long -> too much table to create)
    - put the parameter in the selection screen (but then we have to put default values which come back to the same problem)
    So, I didn't found any perfect solution, Do you know what is the method recommended by SAP ?
    What kind of technics did you use in you projects ?
    Thank you for your help !

    Hi Friend ,
    As you taught , there are  multiple  ways to handle the constants in the program.
    But finally time & efficency matters alot  .
    so my  idea would be  i will  list all the constant & get the quick understanding of the constant type's.
    For example : Order type is Customizing data  which will maintained  by Fun.Consultant  , so i will give work for him to maitain the Varient against  Order type in the TVARC table .so that  in the program  i will declare one order type vraible  under atselection-screen event i will write select Query to get the vaule from the TVARC table which will be maintaine . we can write the execption also with sy-subrc <> o.if it is not maintianed .so far all customizing data fields  this would be the best way for constants maintaining outside your program  .
    Similarly if any system constants then we can get it in runtime  with SYST table parameters .
    if there are any  ABAP Program Constants  ( Titles,labels ,case condition parameters,ect) maintain in the tprogram ext elements , or you can generically maintain a Utility class where you can create an attribute  so that whereeven you want you can reuse the same  .
    Regards,

  • I am new in using Mac operating system, kindly suggest ebooks , videos or audio books to me so that i can learn more about it?

    i am new in using Mac operating system, kindly suggest ebooks, videos or audio books to me so that i can learn more about it.
    any kind of help would be appriciated. i am very eager to learn.how to make ios application? and how to effectively use terminal? where does the basic programming start in Mac? what are the different tools that can help me make an Mac application and ios application.
    -Thank you
    Shailendra (India)

    Apple has got some great guides to start developing in Objective-C, used for programming OS X and iOS apps > http://developer.apple.com/library/mac/#referencelibrary/GettingStarted/RoadMapO SX/chapters/01_Introduction.html

  • Problem when using About Operator in Contains Query

    Hi,
    I'm new to Oracle and this forums too. I have a problem when using about operator in contains query.
    I create a table with some records and then create a context index on 'name' column.
    CREATE TABLE my_items (
      id           NUMBER(10)      NOT NULL,
      name         VARCHAR2(200)   NOT NULL,
      description  VARCHAR2(4000)  NOT NULL,
      price        NUMBER(7,2)     NOT NULL
    ALTER TABLE my_items ADD (
      CONSTRAINT my_items_pk PRIMARY KEY (id)
    CREATE SEQUENCE my_items_seq;
    INSERT INTO my_items VALUES(my_items_seq.nextval, 'Car', 'Car description', 1);
    INSERT INTO my_items VALUES(my_items_seq.nextval, 'Train', 'Train description', 2);
    INSERT INTO my_items VALUES(my_items_seq.nextval, 'Japan', 'Japan description', 3);
    INSERT INTO my_items VALUES(my_items_seq.nextval, 'China', 'China description', 4);
    COMMIT;
    EXEC ctx_ddl.create_preference('english_lexer','basic_lexer');
    EXEC ctx_ddl.set_attribute('english_lexer','index_themes','yes');
    EXEC ctx_ddl.set_attribute('english_lexer','theme_language','english');
    CREATE INDEX my_items_name_idx ON my_items(name) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('lexer english_lexer');
    EXEC ctx_ddl.sync_index('my_items_name_idx');Then I perform contains query to retrieve record :
    SELECT count(*) FROM my_items WHERE contains(name, 'Japan', 1) > 0;
    COUNT(*)
          1
    SELECT count(*) FROM my_items WHERE contains(name, 'about(Japan)', 1) > 0;
    COUNT(*)
          1But the problem is when I using ABOUT operator like in Oracle's English Knowledge Base Category Hierarchy it return 0
    SELECT count(*) FROM my_items WHERE contains(name, 'about(Asia)', 1) > 0;
    COUNT(*)
          0
    SELECT count(*) FROM my_items WHERE contains(name, 'about(transportation)', 1) > 0;
    COUNT(*)
          0I can't figure out what 's wrong in my query or in my index.
    Any help will be appreciated.
    Thanks,
    Hieu Nguyen
    Edited by: user2944391 on Jul 10, 2009 3:25 AM

    Hello (and welcome),
    You'd be best asking this question in the Oracle Text forum, here:
    Text
    And by the way, it will help others to analyse if you put {noformat}{noformat} (lowercase code in curly brackets) before and after your code snippets.
    Good luck!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Why do we use Allowed Operations in DML Process

    Hello,
    Why do we use Allowed Operations in DML Process ??
    Can you please clear this confusion:
    I am using apex 4.1. oracle 11g R2 SOE ...
    Using the Wizard, I created a Form and IR on Dept Table...
    In the form page:
    - Create Button
    The name is "CREATE"
    NO Database Action
    - DML Process
    Allowed Operations: nothing is checked
    This will insert a new row in the Dept table
    In the form page:
    - Create Button
    The name is "CREATE2"
    Database Action : insert
    - DML Process
    Allowed Operations: nothing is checked
    This will insert a new row in the Dept table
    So, What difference does it make if INSERT check box in Allowed Operations of DML Process is TICKED OR NOT ??
    Regards,
    Fateh

    kdm7 wrote:
    Okay.
    So can we keep a web button to access the www.ni.com ? So that web site opens only when button pressed?
    P.S  I,m a newbie.
    Yes, you can also, e.g. include a help file or manual as html and open that in the browser.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Error (Error when starting a SWITCH branch) while using container operation

    HI Experts,
    I am using container operation step for moving internal table (ref to sflight) to workarea.The error I found in the log is ' Error when starting a SWITCH branch'.Kindly help me in finding the solution.Below are the steps and code.
    Result Element = lw_sflight             (Element ref to sflight with export and Import)
    Assignment     =    =                     (Assign (contents of table are deleted first)
    Expression      = &FLIGHT&             (Multi line container ref to sflight)
    Operator          = Assignment
    Expression      =                                 (Blank)
    Thanks and Regards,
    Srini

    Hello,
    Maybe you should show more information about the condition step instead of the container operation step.
    A previous poster in SDN said they solved their problem by changing the order of the conditions.
    regards
    Paultje Bakker
    Hanabi Technology

  • Problem in JDBC , when using LIKE operator. - VERY URGENT

    Problem in JDBC , when using LIKE operator.
    LINE 1 : String temp = "AA";
    LINE 2 : String query = "select * from emp where EMPNAME like '*temp*' ";
    LINE 3 : Staement st = con.createStaement();
    LINE 4 : ResultSet rs = st.executeQuery(query);
    '*' character is not getting evaluated. In MS ACCESS2000 only * is accepted instead of '%'. Moreover in MS ACCESS the like operator has to be used within double quotes as a String. whereas in other databases, it accepts single quotes as a String.
    Ex:
    In MS ACCESS
         select * from emp where ename like "*aa*";
    Other Databases
         select * from emp where ename like '%aa%';
    In my situation iam passing a Variable inside a like operator and '*' is used.
    For the above Scenario, Please help me out.
    If possible Kindly let me know the exact Syntax.
    Please give me the answer as LINE1,LINE2,LINE3,LINE4,
    I have verified in JDBC Spec also, it has been specified to use escape sequence.that too did not work.
    Due to this, My project is in hold for about 4 days. I could not find a suitable solution.
    Please help me out.

    I made a LIKE clause work with M$ Access, using PreparedStatement and the % wildcard:
                escapeStr                   = "%";
                String sql                  = "SELECT USERNAME, PASSWORD FROM USERS WHERE USERNAME LIKE ?";
                PreparedStatement statement = connection.prepareStatement(sql);
                statement.setString(1, ("user" + escapeStr));
                ResultSet resultSet         = statement.executeQuery();
                while (resultSet.next())
                    System.out.println("username: " + resultSet.getObject("USERNAME") + " password: " + resultSet.getObject("PASSWORD"));

  • How can I file share with another person if both of us are using Mac operating systems?  Do we need to use a third party file sharing system or does apple have this capability?

    How can I file share with another personif both of us are using Mac operating systems (one of us using a Mac laptop and the other using iMac).  Our intention is to have a working document that can be changed by both parties over time and both parties will have visibility to the others changes.

    Use SugarSync

  • Need help to retrieve the message from MQ using get operation

    Hi
    Used MQ adapter to Post a message to queue.
    And used Received activity in bpel to retrieve the message using MQ adapter from same queue(used get operation) , got an error message as timed
    out exception.
    Could some one assist in retrieving the message from MQ using get operation.
    Regards
    Raja

    Hi Raja,
    Is the process a empty bpel process which is used to get the message from the MQ?
    Regards
    Surya

  • Transformations not occuring properly using PIVOT operator in OWB mapping.

    Hi ,
    In our project we have a OWB Map UII_D_MAP_SPC_CUST_FAULT_NATTR which is used to populate UII_CUSTOMER_FAULT table in our target side.
    The source table which populate UII_CUSTOMER_FAULT is SR_S_TABLE_N_ATTRIBUTEVALUE (a materialized view in another External Db)
    This Mview has 2 columns: S_N_STRINGVALUE & N_NAME.
    When N_NAME is 'FAULT_REPORT_CODE' the corresponding S_N_STRINGVALUE value should populate the REPORT_CODE field in UII_CUSTOMER_FAULTin the target sde.
    This source to target transformations is being done by using UNPIVOT operator in this mapping UII_MAP_SPC_CUST_FAULT_NATTR.
    In ideal case when S_N_STRINGVALUE is NOT NULL, REPORT_CODE value should be populated with the value of source field value (ie the value of S_N_STRINGVALUE) and when S_N_STRINGVALUE is NULL , REPORT_CODE should be populated with 'XX'.
    But in some cases REPORT_CODE value in UII_CUSTOMER_FAULT table is populated as NULL when S_N_STRINGVALUE is NOT NULL
    which should not happen.
    We suspect that there is some prpblem in the UNPIVOT operator, but we are not able to track down the exact location where it is failing. Can you please help in resolving this problem?
    Shall we remove Unpivot operator and use CASE statement in some package that will be called through Expression operator?
    Please advise.
    Regards
    Arinjit Dhar

    Arinjit,
    Have got any solution forthis. Today I ran into exactly the same problem. If you have got the solution, can you please post it in the forum.
    Ott Karesz,
    I have posted my SQL which got generated. The problem is when I am running the SQL just for the particular data set, it is giving the output properly. But what confuses me more is, when I run the mapping just for few records, it is populating the values correctly, but when running the mapping for all the records, then it populates null values for those records.
    Generated SQL:
    INSERT
    INTO
    "TB_PIPE_1"
    ("ASSETNUM",
    "SITEID",
    "TYPE",
    "STATUS",
    "YEARLAID",
    "MATERIALCODE",
    "PRESSURECODE",
    "DIAMETER",
    "METHODLAID",
    "JOINTTYPE",
    "SDRCOL",
    "LENGTHLAID",
    "LENGTHDIGITISED",
    "MEASUREUNITID")
    SELECT
    "UNPIVOT"."ASSETNUM" "ASSETNUM$1",
    "UNPIVOT"."SITEID" "SITEID$1",
    "UNPIVOT"."CLASSIFICATIONID" "CLASSIFICATIONID$1",
    "UNPIVOT"."STATUS" "STATUS$1",
    "UNPIVOT"."YEAR_LAID" "YEAR_LAID$1",
    "UNPIVOT"."MATERIAL" "MATERIAL$1",
    "UNPIVOT"."PRESSURE" "PRESSURE$1",
    "UNPIVOT"."DIAMETER" "DIAMETER$1",
    "UNPIVOT"."METHODLAID" "METHODLAID$1",
    "UNPIVOT"."JOINTTYPE" "JOINTTYPE$1",
    "UNPIVOT"."SDR" "SDR$1",
    "UNPIVOT"."LENGTHLAID" "LENGTHLAID$1",
    "UNPIVOT"."LENGTHDIGITESED" "LENGTHDIGITESED$1",
    "UNPIVOT"."MESUREUNIT" "MESUREUNIT$1"
    FROM (SELECT
    "ASSETNUM" "ASSETNUM",
    "SITEID" "SITEID",
    "STATUS" "STATUS",
    "YEAR_LAID" "YEAR_LAID",
    "CLASSIFICATIONID" "CLASSIFICATIONID",
    MIN(CASE WHEN "ASSETATTRID" = 'MATERIAL' THEN "ALNVALUE" ELSE NULL END) "MATERIAL",
    MIN(CASE WHEN "ASSETATTRID" = 'PRESSUREREGIME' THEN "ALNVALUE" ELSE NULL END) "PRESSURE",
    MIN(CASE WHEN "ASSETATTRID" = 'DIAMETER' THEN "NUMVALUE" ELSE NULL END) "DIAMETER",
    MIN(CASE WHEN "ASSETATTRID" = 'METHODLAID' THEN "ALNVALUE" ELSE NULL END) "METHODLAID",
    MIN(CASE WHEN "ASSETATTRID" = 'JOINTTYPE' THEN "ALNVALUE" ELSE NULL END) "JOINTTYPE",
    MIN(CASE WHEN "ASSETATTRID" = 'SDR' THEN "ALNVALUE" ELSE NULL END) "SDR",
    MIN(CASE WHEN "ASSETATTRID" = 'LENGTHLAID' THEN "NUMVALUE" ELSE NULL END) "LENGTHLAID",
    MIN(CASE WHEN "ASSETATTRID" = 'LENGTHDIGITISED' THEN "NUMVALUE" ELSE NULL END) "LENGTHDIGITESED",
    MIN(CASE WHEN "ASSETATTRID" = 'DIAMETER' THEN "MEASUREUNITID" ELSE NULL END) "MESUREUNIT"
    FROM (SELECT
    "MV_PIPE"."ASSETNUM" "ASSETNUM",
    "MV_PIPE"."SITEID" "SITEID",
    "MV_PIPE"."STATUS" "STATUS",
    "MV_PIPE"."YEAR_LAID" "YEAR_LAID",
    "MV_PIPE_SPEC"."ASSETATTRID" "ASSETATTRID",
    "MV_PIPE_SPEC"."NUMVALUE" "NUMVALUE",
    "MV_PIPE_SPEC"."ALNVALUE" "ALNVALUE",
    "MV_PIPE_SPEC"."MEASUREUNITID" "MEASUREUNITID",
    "MV_PIPE"."CLASSIFICATIONID" "CLASSIFICATIONID"
    FROM "MV_PIPE_SYN" "MV_PIPE",
    "MV_PIPE_SPEC_SYN" "MV_PIPE_SPEC" WHERE "MV_PIPE"."ASSETNUM" in ('466651706','606703143') and ( "MV_PIPE"."ASSETNUM" = "MV_PIPE_SPEC"."ASSETNUM" )) "OUTGRP1"
    GROUP BY
    "ASSETNUM", "SITEID", "STATUS", "YEAR_LAID", "CLASSIFICATIONID") "UNPIVOT"

Maybe you are looking for